From: Keith F. <ven...@us...> - 2007-02-26 05:57:43
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29776/src/server Modified Files: command.cpp exchangemanager.cpp gem.cpp psserverchar.cpp spellmanager.cpp Log Message: - Took out a lot more unnecessary code, mostly related to items containing items. All item hierarchy is now implied by parent item instance id (GetContainerID() ) but stored in the same flat inventory[] array. - Also started work on re-enabling weight and space tracking, so please test this if you are one of the people testing my stuff, for which I thank you. :-) Index: command.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/command.cpp,v retrieving revision 1.243 retrieving revision 1.244 diff -C2 -d -r1.243 -r1.244 *** command.cpp 22 Feb 2007 07:06:39 -0000 1.243 --- command.cpp 26 Feb 2007 05:56:58 -0000 1.244 *************** *** 1181,1189 **** indent(depth); CPrintf(CON_CMDOUTPUT ,"Weight:%g Size:%d ContainerMaxSize:%d VisDistance:%g DecayResist:%g\n", ! item->GetWeight(), ! item->GetSize(), ! item->GetContainerMaxSize(), ! item->GetVisibleDistance(), ! item->GetDecayResistance()); if (item->GetMeshName()) { --- 1181,1190 ---- indent(depth); CPrintf(CON_CMDOUTPUT ,"Weight:%g Size:%d ContainerMaxSize:%d VisDistance:%g DecayResist:%g\n", ! item->GetWeight(), ! item->GetItemSize(), ! item->GetContainerMaxSize(), ! item->GetVisibleDistance(), ! item->GetDecayResistance()); ! if (item->GetMeshName()) { *************** *** 1297,1302 **** { int depth=0; ! psItem *workingset[5]; ! unsigned int positionset[5]; csString output; --- 1298,1303 ---- { int depth=0; ! // psItem *workingset[5]; ! // unsigned int positionset[5]; csString output; *************** *** 1329,1332 **** --- 1330,1334 ---- show_item_stats(currentitem,0); + /******************************************************************************************* if (currentitem->GetIsContainer()) { *************** *** 1375,1378 **** --- 1377,1381 ---- } } + *********************************************************/ } } Index: exchangemanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/exchangemanager.cpp,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** exchangemanager.cpp 21 Feb 2007 07:27:27 -0000 1.156 --- exchangemanager.cpp 26 Feb 2007 05:56:58 -0000 1.157 *************** *** 551,555 **** if (item != NULL) { ! size += item->GetSumSize(); } } --- 551,555 ---- if (item != NULL) { ! size += item->GetTotalStackSize(); } } *************** *** 1060,1065 **** float capacityNetChange = targetChar.GetSumSize()- playerChar.GetSumSize(); float weightNetChange = targetChar.GetSumWeight() - playerChar.GetSumWeight(); ! if ( starterClient->GetCharacterData()->Inventory().HasSpace( capacityNetChange ) && ! starterClient->GetCharacterData()->Inventory().HasWeight( weightNetChange ) ) { playerAccepted = true; --- 1060,1065 ---- float capacityNetChange = targetChar.GetSumSize()- playerChar.GetSumSize(); float weightNetChange = targetChar.GetSumWeight() - playerChar.GetSumWeight(); ! if ( starterClient->GetCharacterData()->Inventory().HasEnoughUnusedSpace( capacityNetChange ) && ! starterClient->GetCharacterData()->Inventory().HasEnoughUnusedWeight( weightNetChange ) ) { playerAccepted = true; *************** *** 1074,1079 **** float capacityNetChange = playerChar.GetSumSize()- targetChar.GetSumSize(); float weightNetChange = playerChar.GetSumWeight() - targetChar.GetSumWeight(); ! if ( targetClient->GetCharacterData()->Inventory().HasSpace( capacityNetChange ) && ! targetClient->GetCharacterData()->Inventory().HasWeight( weightNetChange ) ) { targetAccepted = true; --- 1074,1079 ---- float capacityNetChange = playerChar.GetSumSize()- targetChar.GetSumSize(); float weightNetChange = playerChar.GetSumWeight() - targetChar.GetSumWeight(); ! if ( targetClient->GetCharacterData()->Inventory().HasEnoughUnusedSpace( capacityNetChange ) && ! targetClient->GetCharacterData()->Inventory().HasEnoughUnusedWeight( weightNetChange ) ) { targetAccepted = true; Index: gem.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/gem.cpp,v retrieving revision 1.419 retrieving revision 1.420 diff -C2 -d -r1.419 -r1.420 *** gem.cpp 24 Feb 2007 17:38:31 -0000 1.419 --- gem.cpp 26 Feb 2007 05:56:58 -0000 1.420 *************** *** 162,166 **** psCharacter* psChar = client->GetActor()->GetCharacterData(); ! psStatsMessage msg( client->GetClientNum(), psChar->GetHitPointsMax(), psChar->GetManaMax(), psChar->Inventory().MaxWeight(), psChar->Inventory().MaxCapacity() ); msg.SendMessage(); --- 162,170 ---- psCharacter* psChar = client->GetActor()->GetCharacterData(); ! psStatsMessage msg(client->GetClientNum(), ! psChar->GetHitPointsMax(), ! psChar->GetManaMax(), ! psChar->Inventory().MaxWeight(), ! psChar->Inventory().GetCurrentMaxSpace() ); msg.SendMessage(); Index: psserverchar.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psserverchar.cpp,v retrieving revision 1.457 retrieving revision 1.458 diff -C2 -d -r1.457 -r1.458 *** psserverchar.cpp 25 Feb 2007 19:19:32 -0000 1.457 --- psserverchar.cpp 26 Feb 2007 05:56:58 -0000 1.458 *************** *** 498,504 **** outgoing = new psGUIInventoryMessage(toClientNumber, ! psGUIInventoryMessage::LIST, ! (uint32_t)chardata->Inventory().GetInventoryIndexCount()-1, // skip item 0 ! (uint32_t)0, chardata->Inventory().MaxWeight() ); printf("Sending %d items...\n", chardata->Inventory().GetInventoryIndexCount()-1); --- 498,504 ---- outgoing = new psGUIInventoryMessage(toClientNumber, ! psGUIInventoryMessage::LIST, ! (uint32_t)chardata->Inventory().GetInventoryIndexCount()-1, // skip item 0 ! (uint32_t)0, chardata->Inventory().MaxWeight() ); printf("Sending %d items...\n", chardata->Inventory().GetInventoryIndexCount()-1); *************** *** 513,525 **** invType = CONTAINER_INVENTORY_EQUIPMENT; ! // printf(" Inv item %s, slot %d\n",item->GetName(), slot); ! outgoing->AddItem( item->GetName(), ! invType, ! slot, ! item->GetStackCount(), ! 0,////////////item->GetSumWeight(), ! item->GetSumSize(), ! item->GetImageName(), ! item->GetPurifyStatus()); } --- 513,525 ---- invType = CONTAINER_INVENTORY_EQUIPMENT; ! printf(" Inv item %s, slot %d, weight %1.1f, stack count %u\n",item->GetName(), slot, item->GetWeight(), item->GetStackCount() ); ! outgoing->AddItem(item->GetName(), ! invType, ! slot, ! item->GetStackCount(), ! item->GetWeight(), ! item->GetTotalStackSize(), ! item->GetImageName(), ! item->GetPurifyStatus()); } *************** *** 869,873 **** } ! int canFit = (int)character->Inventory().CanFit(item); // count that actually fit into buyer's inventory if (count > canFit) --- 869,873 ---- } ! int canFit = (int)character->Inventory().HowManyCanFit(item); // count that actually fit into buyer's inventory if (count > canFit) *************** *** 1368,1373 **** desc.AppendFmt("\n\nWeight: %.2f\nCapacity: %u/%u", 0, ////////////item->GetSumWeight(), ! item->GetContainedSize(), ! item->GetContainerMaxSize() ); psViewItemDescription outgoing( client->GetClientNum(), --- 1368,1373 ---- desc.AppendFmt("\n\nWeight: %.2f\nCapacity: %u/%u", 0, ////////////item->GetSumWeight(), ! 0,///////////item->GetContainedSize(), ! 0);/////////////////item->GetContainerMaxSize() ); psViewItemDescription outgoing( client->GetClientNum(), *************** *** 1903,1909 **** if ( parentID != 0 ) { ! psItem* container = FindItem(client,parentID,slotID,containerID); ! if ( container ) ! return container->GetItemInSlot(slotID); else Error3("Could not find container %d inside parent %d", containerID, parentID); --- 1903,1912 ---- if ( parentID != 0 ) { ! psItem *parent = FindItem(client,parentID,slotID,containerID); ! if (parent) ! { ! slotID = (INVENTORY_SLOT_NUMBER)(parent->GetLocInParent() * 100 + slotID); // adjust slot number to contained slot ! return FindItem(client, containerID, slotID, 0); ! } else Error3("Could not find container %d inside parent %d", containerID, parentID); Index: spellmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/spellmanager.cpp,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** spellmanager.cpp 21 Feb 2007 07:27:28 -0000 1.125 --- spellmanager.cpp 26 Feb 2007 05:56:58 -0000 1.126 *************** *** 437,441 **** if (glyph->GetStackCount() > 1) { ! if ( !character->Inventory().CanFit(glyph) || !character->Inventory().HasEmptyBulkSlots() ) { psserver->SendSystemError(client->GetClientNum(), "Your inventory is full!" ); --- 437,441 ---- if (glyph->GetStackCount() > 1) { ! if ( !character->Inventory().HowManyCanFit(glyph) ) { psserver->SendSystemError(client->GetClientNum(), "Your inventory is full!" ); |