From: Keith F. <ven...@us...> - 2007-04-03 04:34:01
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv795/src/server Modified Files: entitymanager.cpp entitymanager.h psserverchar.cpp Log Message: - Fix attempt to make dropping containers into the world from inventory work, and have the contents of the container also follow. Index: entitymanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/entitymanager.cpp,v retrieving revision 1.204 retrieving revision 1.205 diff -C2 -d -r1.204 -r1.205 *** entitymanager.cpp 11 Mar 2007 22:26:00 -0000 1.204 --- entitymanager.cpp 3 Apr 2007 04:33:59 -0000 1.205 *************** *** 763,789 **** } ! bool EntityManager::MoveItemToWorld(psItem *chrItem, ! int instance, ! psSectorInfo *sectorinfo, ! float loc_x, ! float loc_y, ! float loc_z, ! float loc_yrot, ! psCharacter *owner, ! bool transient) { chrItem->SetLocationInWorld(instance,sectorinfo,loc_x,loc_y,loc_z,loc_yrot); chrItem->UpdateInventoryStatus(owner,0,PSCHARACTER_SLOT_NONE); ! if (!CreateItem(chrItem,true)) { delete chrItem; ! return false; } chrItem->Save(false); ! return true; } ! bool EntityManager::CreateItem( psItem *& iteminstance, bool transient ) { const char *meshname; --- 763,791 ---- } ! gemObject *EntityManager::MoveItemToWorld(psItem *chrItem, ! int instance, ! psSectorInfo *sectorinfo, ! float loc_x, ! float loc_y, ! float loc_z, ! float loc_yrot, ! psCharacter *owner, ! bool transient) { chrItem->SetLocationInWorld(instance,sectorinfo,loc_x,loc_y,loc_z,loc_yrot); chrItem->UpdateInventoryStatus(owner,0,PSCHARACTER_SLOT_NONE); ! ! gemObject *obj = CreateItem(chrItem,true); ! if (!obj) { delete chrItem; ! return NULL; } chrItem->Save(false); ! return obj; } ! gemObject *EntityManager::CreateItem( psItem *& iteminstance, bool transient ) { const char *meshname; *************** *** 797,804 **** iteminstance->GetLocationInWorld(instance, §orinfo,newpos.x,newpos.y,newpos.z,yrot); if (sectorinfo==NULL) ! return false; isec = FindSector(sectorinfo->name); if (isec==NULL) ! return false; // Try to stack this first --- 799,806 ---- iteminstance->GetLocationInWorld(instance, §orinfo,newpos.x,newpos.y,newpos.z,yrot); if (sectorinfo==NULL) ! return NULL; isec = FindSector(sectorinfo->name); if (isec==NULL) ! return NULL; // Try to stack this first *************** *** 826,830 **** } else ! return true; // Done } } --- 828,832 ---- } else ! return nearitem->GetGemObject(); // Done } } *************** *** 896,900 **** psserver->npcmanager->AddEntity(obj); ! return true; } --- 898,902 ---- psserver->npcmanager->AddEntity(obj); ! return obj; } Index: entitymanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/entitymanager.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** entitymanager.h 22 Feb 2007 07:06:39 -0000 1.38 --- entitymanager.h 3 Apr 2007 04:33:59 -0000 1.39 *************** *** 91,104 **** bool CreateActionLocation(psActionLocation *instance, bool transient); ! bool CreateItem(psItem *& iteminstance, bool transient); ! bool MoveItemToWorld(psItem *keyItem, ! int instance, ! psSectorInfo *sectorinfo, ! float loc_x, ! float loc_y, ! float loc_z, ! float loc_yrot, ! psCharacter *owner, ! bool transient); virtual void HandleMessage(MsgEntry* me,Client *client); --- 91,104 ---- bool CreateActionLocation(psActionLocation *instance, bool transient); ! gemObject *CreateItem(psItem *& iteminstance, bool transient); ! gemObject *MoveItemToWorld(psItem *keyItem, ! int instance, ! psSectorInfo *sectorinfo, ! float loc_x, ! float loc_y, ! float loc_z, ! float loc_yrot, ! psCharacter *owner, ! bool transient); virtual void HandleMessage(MsgEntry* me,Client *client); Index: psserverchar.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psserverchar.cpp,v retrieving revision 1.491 retrieving revision 1.492 diff -C2 -d -r1.491 -r1.492 *** psserverchar.cpp 2 Apr 2007 06:45:32 -0000 1.491 --- psserverchar.cpp 3 Apr 2007 04:33:59 -0000 1.492 *************** *** 1906,1919 **** if (dropItem) { ! EntityManager::GetSingleton().MoveItemToWorld(dropItem, ! instance, ! sectorinfo, ! msg.posWorld.x, ! msg.posWorld.y, ! msg.posWorld.z, ! loc_yrot, ! chr, ! true); ! return true; } return false; --- 1906,1930 ---- if (dropItem) { ! gemObject *obj = EntityManager::GetSingleton().MoveItemToWorld(dropItem,instance,sectorinfo, ! msg.posWorld.x,msg.posWorld.y, msg.posWorld.z,loc_yrot, ! chr,true); ! if (!obj) ! return false; ! ! gemContainer *cont = dynamic_cast<gemContainer*> (obj); ! if (cont) ! { ! for (size_t i=0; i < chr->Inventory().GetInventoryIndexCount(); i++) ! { ! psItem *item = chr->Inventory().GetInventoryIndexItem(i); ! if (item->GetContainerID() == cont->GetItem()->GetUID() ) ! { ! // This item is in the dropped container ! chr->Inventory().RemoveItemIndex(i); ! cont->AddToContainer(item); ! item->Save(false); ! } ! } ! } } return false; |