From: Kenny G. <ken...@us...> - 2007-04-02 05:27:47
|
Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5042/src/server/bulkobjects Modified Files: pscharacter.cpp pscharacter.h pscharinventory.cpp pscharinventory.h Log Message: - Initial stab at encumbrance: Characters exceeding their max weights will immediately sit, unable to move, until they solve the problem. This can be done via dropping items, exchanging items, or raising your stats again via spells & potions. Prevents combat, spell casting, and all other actions. Index: pscharacter.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.cpp,v retrieving revision 1.470 retrieving revision 1.471 diff -C2 -d -r1.470 -r1.471 *** pscharacter.cpp 1 Apr 2007 19:34:25 -0000 1.470 --- pscharacter.cpp 2 Apr 2007 05:25:50 -0000 1.471 *************** *** 89,93 **** const char * psCharacter::player_mode_to_str[] = ! {"unknown","peace","combat","spell casting","working","dead","sitting","exhausted"}; void *psCharacter::operator new(size_t allocSize) --- 89,93 ---- const char * psCharacter::player_mode_to_str[] = ! {"unknown","peace","combat","spell casting","working","dead","sitting","exhausted","carrying too much"}; void *psCharacter::operator new(size_t allocSize) *************** *** 1098,1101 **** --- 1098,1102 ---- case PSCHARACTER_MODE_WORK: msgmode = psModeMessage::WORK; break; case PSCHARACTER_MODE_EXHAUSTED: msgmode = psModeMessage::EXHAUSTED; break; + case PSCHARACTER_MODE_OVERWEIGHT: msgmode = psModeMessage::OVERWEIGHT; break; case PSCHARACTER_MODE_COMBAT: msgmode = psModeMessage::COMBAT; break; case PSCHARACTER_MODE_DEAD: msgmode = psModeMessage::DEAD; break; *************** *** 1103,1106 **** --- 1104,1112 ---- } + // Force mode to be OVERWEIGHT if encumbered, but allow DEAD to work as + // required. + if (player_mode != PSCHARACTER_MODE_DEAD && !inventory.HasEnoughUnusedWeight(0)) + newmode = PSCHARACTER_MODE_OVERWEIGHT; + if (newmode != PSCHARACTER_MODE_COMBAT) SetCombatStance(PSCHARACTER_STANCE_NORMAL); *************** *** 1111,1115 **** actor->SetAllowedToMove(newmode != PSCHARACTER_MODE_DEAD && newmode != PSCHARACTER_MODE_SIT && ! newmode != PSCHARACTER_MODE_EXHAUSTED); actor->SetAlive(newmode != PSCHARACTER_MODE_DEAD); --- 1117,1122 ---- actor->SetAllowedToMove(newmode != PSCHARACTER_MODE_DEAD && newmode != PSCHARACTER_MODE_SIT && ! newmode != PSCHARACTER_MODE_EXHAUSTED && ! newmode != PSCHARACTER_MODE_OVERWEIGHT); actor->SetAlive(newmode != PSCHARACTER_MODE_DEAD); *************** *** 1132,1135 **** --- 1139,1143 ---- case PSCHARACTER_MODE_COMBAT: case PSCHARACTER_MODE_DEAD: + case PSCHARACTER_MODE_OVERWEIGHT: SetStaminaRegenerationNone(); // no stamina regen while busy break; Index: pscharacter.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.h,v retrieving revision 1.227 retrieving revision 1.228 diff -C2 -d -r1.227 -r1.228 *** pscharacter.h 1 Apr 2007 19:34:26 -0000 1.227 --- pscharacter.h 2 Apr 2007 05:25:50 -0000 1.228 *************** *** 138,141 **** --- 138,142 ---- PSCHARACTER_MODE_SIT, PSCHARACTER_MODE_EXHAUSTED, + PSCHARACTER_MODE_OVERWEIGHT, PSCHARACTER_MODE_COUNT }; Index: pscharinventory.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharinventory.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pscharinventory.cpp 27 Mar 2007 12:03:12 -0000 1.17 --- pscharinventory.cpp 2 Apr 2007 05:25:50 -0000 1.18 *************** *** 94,98 **** } ! void psCharacterInventory::RecalculateLimitFormulas() { // The max total weight that a player can carry --- 94,98 ---- } ! void psCharacterInventory::CalculateLimits() { // The max total weight that a player can carry *************** *** 125,133 **** printf("Calculated maxSize to be %1.2f", maxSize); } } ! void psCharacterInventory::CalculateLimits() { ! RecalculateLimitFormulas(); /*************************************************** ReassessInventoryDimensions(); --- 125,149 ---- printf("Calculated maxSize to be %1.2f", maxSize); } + + UpdateEncumbrance(); } ! void psCharacterInventory::UpdateEncumbrance() { ! if (!owner->GetActor()) ! return; ! ! // TODO: Check requirements of equipped items... ! ! int cnum = owner->GetActor()->GetClientID(); ! if (doRestrictions && GetCurrentTotalWeight() > MaxWeight()) ! { ! owner->SetMode(PSCHARACTER_MODE_OVERWEIGHT, cnum); ! } ! else if (owner->GetMode() == PSCHARACTER_MODE_OVERWEIGHT) ! { ! owner->SetMode(PSCHARACTER_MODE_PEACE, cnum); ! } ! /*************************************************** ReassessInventoryDimensions(); *************** *** 465,468 **** --- 481,485 ---- return -1; } + // FIXME: Doesn't check weight of containers... if ( !HasEnoughUnusedWeight(item->GetWeight()) ) { *************** *** 733,737 **** inventory.DeleteIndex(itemIndex); // Take out of inventory master list ! // SubtractDimensionsFromInventory(currentItem); return currentItem; } --- 750,754 ---- inventory.DeleteIndex(itemIndex); // Take out of inventory master list ! UpdateEncumbrance(); return currentItem; } *************** *** 740,747 **** psItem* newItem = currentItem->SplitStack((unsigned short)count); currentItem->Save(false); ! if (!newItem) ! return NULL; - // SubtractDimensionsFromInventory(newItem); return newItem; } --- 757,763 ---- psItem* newItem = currentItem->SplitStack((unsigned short)count); currentItem->Save(false); ! if (newItem) ! UpdateEncumbrance(); return newItem; } *************** *** 1029,1032 **** --- 1045,1050 ---- if (doRestrictions) CalculateLimits(); + else + UpdateEncumbrance(); // this will unlock if already encumbered } Index: pscharinventory.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharinventory.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pscharinventory.h 27 Mar 2007 12:03:12 -0000 1.8 --- pscharinventory.h 2 Apr 2007 05:25:50 -0000 1.9 *************** *** 306,310 **** uint32 GetContainedSize(psItem *container); ! /// Run the math scripts to calculate inventory max values. void CalculateLimits(); --- 306,310 ---- uint32 GetContainedSize(psItem *container); ! /// Uses Mathscript formulas to determine the proper max weight and max space limits void CalculateLimits(); *************** *** 383,389 **** private: ! /// Uses Mathscript formulas to determine the proper max weight and max space limits ! void RecalculateLimitFormulas(); ! void WriteItem(csRef<iDocumentNode> equipmentNode, psItem* item, int bulk, INVENTORY_SLOT_NUMBER slot); --- 383,389 ---- private: ! /// Update encumbrance/OVERWEIGHT mode to match current status. ! void UpdateEncumbrance(); ! void WriteItem(csRef<iDocumentNode> equipmentNode, psItem* item, int bulk, INVENTORY_SLOT_NUMBER slot); |