From 0868a29b6563617254b21553f1607814ceb89d68 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 26 Jul 2024 23:43:52 -0400 Subject: [PATCH] Rename Player struct variables: InvBody --- Source/control.cpp | 10 +-- Source/inv.cpp | 126 +++++++++++++++--------------- Source/inv_iterators.hpp | 4 +- Source/items.cpp | 32 ++++---- Source/loadsave.cpp | 8 +- Source/msg.cpp | 4 +- Source/objects.cpp | 30 +++---- Source/pack.cpp | 12 +-- Source/pack.h | 4 +- Source/panels/charpanel.cpp | 4 +- Source/panels/spell_book.cpp | 2 +- Source/panels/spell_list.cpp | 2 +- Source/pfile.cpp | 2 +- Source/player.cpp | 82 +++++++++---------- Source/player.h | 22 +++--- Source/stores.cpp | 48 ++++++------ Source/sync.cpp | 2 +- test/fixtures/memory_map/hero.txt | 2 +- test/pack_test.cpp | 32 ++++---- test/player_test.cpp | 2 +- test/writehero_test.cpp | 20 ++--- 21 files changed, 225 insertions(+), 225 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index d5c8edae227..3368aa87808 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1080,7 +1080,7 @@ void CheckPanelInfo() } break; case SpellType::Charges: AddPanelString(fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", GetSpellData(spellId).sNameText))); - AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)), myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)); + AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", myPlayer.bodySlot[INVLOC_HAND_LEFT]._iCharges)), myPlayer.bodySlot[INVLOC_HAND_LEFT]._iCharges)); break; case SpellType::Invalid: break; @@ -1343,10 +1343,10 @@ void DrawDurIcon(const Surface &out) } Player &myPlayer = *MyPlayer; - x = DrawDurIcon4Item(out, myPlayer.InvBody[INVLOC_HEAD], x, 3); - x = DrawDurIcon4Item(out, myPlayer.InvBody[INVLOC_CHEST], x, 2); - x = DrawDurIcon4Item(out, myPlayer.InvBody[INVLOC_HAND_LEFT], x, 0); - DrawDurIcon4Item(out, myPlayer.InvBody[INVLOC_HAND_RIGHT], x, 0); + x = DrawDurIcon4Item(out, myPlayer.bodySlot[INVLOC_HEAD], x, 3); + x = DrawDurIcon4Item(out, myPlayer.bodySlot[INVLOC_CHEST], x, 2); + x = DrawDurIcon4Item(out, myPlayer.bodySlot[INVLOC_HAND_LEFT], x, 0); + DrawDurIcon4Item(out, myPlayer.bodySlot[INVLOC_HAND_RIGHT], x, 0); } void RedBack(const Surface &out) diff --git a/Source/inv.cpp b/Source/inv.cpp index 19c9ca78516..2aebb2ced59 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -187,8 +187,8 @@ bool CanWield(Player &player, const Item &item) if (!CanEquip(item) || IsNoneOf(player.GetItemLocation(item), ILOC_ONEHAND, ILOC_TWOHAND)) return false; - Item &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; - Item &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; + Item &leftHandItem = player.bodySlot[INVLOC_HAND_LEFT]; + Item &rightHandItem = player.bodySlot[INVLOC_HAND_RIGHT]; if (leftHandItem.isEmpty() && rightHandItem.isEmpty()) { return true; @@ -229,7 +229,7 @@ bool CanWield(Player &player, const Item &item) */ bool CanEquip(Player &player, const Item &item, inv_body_loc bodyLocation) { - if (!CanEquip(item) || player._pmode > PM_WALK_SIDEWAYS || !player.InvBody[bodyLocation].isEmpty()) { + if (!CanEquip(item) || player._pmode > PM_WALK_SIDEWAYS || !player.bodySlot[bodyLocation].isEmpty()) { return false; } @@ -258,7 +258,7 @@ bool CanEquip(Player &player, const Item &item, inv_body_loc bodyLocation) void ChangeEquipment(Player &player, inv_body_loc bodyLocation, const Item &item, bool sendNetworkMessage) { - player.InvBody[bodyLocation] = item; + player.bodySlot[bodyLocation] = item; if (sendNetworkMessage) { NetSendCmdChItem(false, bodyLocation, true); @@ -341,7 +341,7 @@ void ChangeBodyEquipment(Player &player, int slot, item_equip_type location) app_fatal("Unexpected equipment type"); } }(location); - const Item previouslyEquippedItem = player.InvBody[slot]; + const Item previouslyEquippedItem = player.bodySlot[slot]; ChangeEquipment(player, bodyLocation, player.HoldItem.pop(), &player == MyPlayer); if (!previouslyEquippedItem.isEmpty()) { player.HoldItem = previouslyEquippedItem; @@ -353,13 +353,13 @@ void ChangeEquippedItem(Player &player, uint8_t slot) const inv_body_loc selectedHand = slot == SLOTXY_HAND_LEFT ? INVLOC_HAND_LEFT : INVLOC_HAND_RIGHT; const inv_body_loc otherHand = slot == SLOTXY_HAND_LEFT ? INVLOC_HAND_RIGHT : INVLOC_HAND_LEFT; - const bool pasteIntoSelectedHand = (player.InvBody[otherHand].isEmpty() || player.InvBody[otherHand]._iClass != player.HoldItem._iClass) - || (player._pClass == HeroClass::Bard && player.InvBody[otherHand]._iClass == ICLASS_WEAPON && player.HoldItem._iClass == ICLASS_WEAPON); + const bool pasteIntoSelectedHand = (player.bodySlot[otherHand].isEmpty() || player.bodySlot[otherHand]._iClass != player.HoldItem._iClass) + || (player._pClass == HeroClass::Bard && player.bodySlot[otherHand]._iClass == ICLASS_WEAPON && player.HoldItem._iClass == ICLASS_WEAPON); - const bool dequipTwoHandedWeapon = (!player.InvBody[otherHand].isEmpty() && player.GetItemLocation(player.InvBody[otherHand]) == ILOC_TWOHAND); + const bool dequipTwoHandedWeapon = (!player.bodySlot[otherHand].isEmpty() && player.GetItemLocation(player.bodySlot[otherHand]) == ILOC_TWOHAND); const inv_body_loc pasteHand = pasteIntoSelectedHand ? selectedHand : otherHand; - const Item previouslyEquippedItem = dequipTwoHandedWeapon ? player.InvBody[otherHand] : player.InvBody[pasteHand]; + const Item previouslyEquippedItem = dequipTwoHandedWeapon ? player.bodySlot[otherHand] : player.bodySlot[pasteHand]; if (dequipTwoHandedWeapon) { RemoveEquipment(player, otherHand, false); } @@ -371,30 +371,30 @@ void ChangeEquippedItem(Player &player, uint8_t slot) void ChangeTwoHandItem(Player &player) { - if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() && !player.InvBody[INVLOC_HAND_RIGHT].isEmpty()) { + if (!player.bodySlot[INVLOC_HAND_LEFT].isEmpty() && !player.bodySlot[INVLOC_HAND_RIGHT].isEmpty()) { inv_body_loc locationToUnequip = INVLOC_HAND_LEFT; - if (player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { + if (player.bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { locationToUnequip = INVLOC_HAND_RIGHT; } - if (!AutoPlaceItemInInventory(player, player.InvBody[locationToUnequip], true)) { + if (!AutoPlaceItemInInventory(player, player.bodySlot[locationToUnequip], true)) { return; } if (locationToUnequip == INVLOC_HAND_RIGHT) { RemoveEquipment(player, INVLOC_HAND_RIGHT, false); } else { - player.InvBody[INVLOC_HAND_LEFT].clear(); + player.bodySlot[INVLOC_HAND_LEFT].clear(); } } - if (player.InvBody[INVLOC_HAND_RIGHT].isEmpty()) { - Item previouslyEquippedItem = player.InvBody[INVLOC_HAND_LEFT]; + if (player.bodySlot[INVLOC_HAND_RIGHT].isEmpty()) { + Item previouslyEquippedItem = player.bodySlot[INVLOC_HAND_LEFT]; ChangeEquipment(player, INVLOC_HAND_LEFT, player.HoldItem.pop(), &player == MyPlayer); if (!previouslyEquippedItem.isEmpty()) { player.HoldItem = previouslyEquippedItem; } } else { - Item previouslyEquippedItem = player.InvBody[INVLOC_HAND_RIGHT]; + Item previouslyEquippedItem = player.bodySlot[INVLOC_HAND_RIGHT]; RemoveEquipment(player, INVLOC_HAND_RIGHT, false); ChangeEquipment(player, INVLOC_HAND_LEFT, player.HoldItem, &player == MyPlayer); player.HoldItem = previouslyEquippedItem; @@ -636,7 +636,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool bool automaticallyEquipped = false; bool automaticallyUnequip = false; - Item &headItem = player.InvBody[INVLOC_HEAD]; + Item &headItem = player.bodySlot[INVLOC_HEAD]; if (r == SLOTXY_HEAD && !headItem.isEmpty()) { holdItem = headItem; if (automaticMove) { @@ -649,7 +649,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &leftRingItem = player.InvBody[INVLOC_RING_LEFT]; + Item &leftRingItem = player.bodySlot[INVLOC_RING_LEFT]; if (r == SLOTXY_RING_LEFT && !leftRingItem.isEmpty()) { holdItem = leftRingItem; if (automaticMove) { @@ -662,7 +662,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &rightRingItem = player.InvBody[INVLOC_RING_RIGHT]; + Item &rightRingItem = player.bodySlot[INVLOC_RING_RIGHT]; if (r == SLOTXY_RING_RIGHT && !rightRingItem.isEmpty()) { holdItem = rightRingItem; if (automaticMove) { @@ -675,7 +675,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &amuletItem = player.InvBody[INVLOC_AMULET]; + Item &amuletItem = player.bodySlot[INVLOC_AMULET]; if (r == SLOTXY_AMULET && !amuletItem.isEmpty()) { holdItem = amuletItem; if (automaticMove) { @@ -688,7 +688,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; + Item &leftHandItem = player.bodySlot[INVLOC_HAND_LEFT]; if (r == SLOTXY_HAND_LEFT && !leftHandItem.isEmpty()) { holdItem = leftHandItem; if (automaticMove) { @@ -701,7 +701,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; + Item &rightHandItem = player.bodySlot[INVLOC_HAND_RIGHT]; if (r == SLOTXY_HAND_RIGHT && !rightHandItem.isEmpty()) { holdItem = rightHandItem; if (automaticMove) { @@ -714,7 +714,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool } } - Item &chestItem = player.InvBody[INVLOC_CHEST]; + Item &chestItem = player.bodySlot[INVLOC_CHEST]; if (r == SLOTXY_CHEST && !chestItem.isEmpty()) { holdItem = chestItem; if (automaticMove) { @@ -739,9 +739,9 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool automaticallyMoved = AutoPlaceItemInBelt(player, holdItem, true, &player == MyPlayer); } else if (CanEquip(holdItem)) { /* - * Move the respective InvBodyItem to inventory before moving the item from inventory - * to InvBody with AutoEquip. AutoEquip requires the InvBody slot to be empty. - * First identify the correct InvBody slot and store it in invloc. + * Move the respective bodySlotItem to inventory before moving the item from inventory + * to bodySlot with AutoEquip. AutoEquip requires the bodySlot slot to be empty. + * First identify the correct bodySlot slot and store it in invloc. */ automaticallyUnequip = true; // Switch to say "I have no room when inventory is too full" int invloc = NUM_INVLOC; @@ -757,32 +757,32 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool break; case ILOC_ONEHAND: // User is attempting to move a weapon (left hand) - if (player.InvList[iv - 1]._iClass == player.InvBody[INVLOC_HAND_LEFT]._iClass - && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.InvBody[INVLOC_HAND_LEFT])) { + if (player.InvList[iv - 1]._iClass == player.bodySlot[INVLOC_HAND_LEFT]._iClass + && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.bodySlot[INVLOC_HAND_LEFT])) { invloc = INVLOC_HAND_LEFT; } // User is attempting to move a shield (right hand) - if (player.InvList[iv - 1]._iClass == player.InvBody[INVLOC_HAND_RIGHT]._iClass - && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.InvBody[INVLOC_HAND_RIGHT])) { + if (player.InvList[iv - 1]._iClass == player.bodySlot[INVLOC_HAND_RIGHT]._iClass + && player.GetItemLocation(player.InvList[iv - 1]) == player.GetItemLocation(player.bodySlot[INVLOC_HAND_RIGHT])) { invloc = INVLOC_HAND_RIGHT; } // A two-hand item can always be replaced with a one-hand item - if (player.GetItemLocation(player.InvBody[INVLOC_HAND_LEFT]) == ILOC_TWOHAND) { + if (player.GetItemLocation(player.bodySlot[INVLOC_HAND_LEFT]) == ILOC_TWOHAND) { invloc = INVLOC_HAND_LEFT; } break; case ILOC_TWOHAND: - // Moving a two-hand item from inventory to InvBody requires emptying both hands - if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty()) { - holdItem = player.InvBody[INVLOC_HAND_RIGHT]; + // Moving a two-hand item from inventory to bodySlot requires emptying both hands + if (!player.bodySlot[INVLOC_HAND_RIGHT].isEmpty()) { + holdItem = player.bodySlot[INVLOC_HAND_RIGHT]; if (!AutoPlaceItemInInventory(player, holdItem, true)) { // No space to move right hand item to inventory, abort. break; } - holdItem = player.InvBody[INVLOC_HAND_LEFT]; + holdItem = player.bodySlot[INVLOC_HAND_LEFT]; if (!AutoPlaceItemInInventory(player, holdItem, false)) { // No space for left item. Move back right item to right hand and abort. - player.InvBody[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1]; + player.bodySlot[INVLOC_HAND_RIGHT] = player.InvList[player._pNumInv - 1]; player.RemoveInvItem(player._pNumInv - 1, false); break; } @@ -796,12 +796,12 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool automaticallyUnequip = false; // Switch to say "I can't do that" break; } - // Empty the identified InvBody slot (invloc) and hand over to AutoEquip + // Empty the identified bodySlot slot (invloc) and hand over to AutoEquip if (invloc != NUM_INVLOC) { - holdItem = player.InvBody[invloc]; - if (player.InvBody[invloc]._itype != ItemType::None) { + holdItem = player.bodySlot[invloc]; + if (player.bodySlot[invloc]._itype != ItemType::None) { if (AutoPlaceItemInInventory(player, holdItem, true)) { - player.InvBody[invloc].clear(); + player.bodySlot[invloc].clear(); } } } @@ -1124,12 +1124,12 @@ void DrawInv(const Surface &out) Player &myPlayer = *InspectPlayer; for (int slot = INVLOC_HEAD; slot < NUM_INVLOC; slot++) { - if (!myPlayer.InvBody[slot].isEmpty()) { + if (!myPlayer.bodySlot[slot].isEmpty()) { int screenX = slotPos[slot].x; int screenY = slotPos[slot].y; - InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, { screenX, screenY }), { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }, myPlayer.InvBody[slot]._iMagical); + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, { screenX, screenY }), { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }, myPlayer.bodySlot[slot]._iMagical); - const int cursId = myPlayer.InvBody[slot]._iCurs + CURSOR_FIRSTITEM; + const int cursId = myPlayer.bodySlot[slot]._iCurs + CURSOR_FIRSTITEM; Size frameSize = GetInvItemSize(cursId); @@ -1143,14 +1143,14 @@ void DrawInv(const Surface &out) const Point position = GetPanelPosition(UiPanels::Inventory, { screenX, screenY }); if (pcursinvitem == slot) { - ClxDrawOutline(out, GetOutlineColor(myPlayer.InvBody[slot], true), position, sprite); + ClxDrawOutline(out, GetOutlineColor(myPlayer.bodySlot[slot], true), position, sprite); } - DrawItem(myPlayer.InvBody[slot], out, position, sprite); + DrawItem(myPlayer.bodySlot[slot], out, position, sprite); if (slot == INVLOC_HAND_LEFT) { - if (myPlayer.GetItemLocation(myPlayer.InvBody[slot]) == ILOC_TWOHAND) { - InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, slotPos[INVLOC_HAND_RIGHT]), { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }, myPlayer.InvBody[slot]._iMagical); + if (myPlayer.GetItemLocation(myPlayer.bodySlot[slot]) == ILOC_TWOHAND) { + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, slotPos[INVLOC_HAND_RIGHT]), { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }, myPlayer.bodySlot[slot]._iMagical); LightTableIndex = 0; const int dstX = GetRightPanel().position.x + slotPos[INVLOC_HAND_RIGHT].x + (frameSize.width == InventorySlotSizeInPixels.width ? INV_SLOT_HALF_SIZE_PX : 0) - 1; @@ -1232,7 +1232,7 @@ void RemoveEquipment(Player &player, inv_body_loc bodyLocation, bool hiPri) NetSendCmdDelItem(hiPri, bodyLocation); } - player.InvBody[bodyLocation].clear(); + player.bodySlot[bodyLocation].clear(); } bool AutoPlaceItemInBelt(Player &player, const Item &item, bool persistItem, bool sendNetworkMessage) @@ -1540,12 +1540,12 @@ bool GoldAutoPlace(Player &player, Item &goldStack) void CheckInvSwap(Player &player, inv_body_loc bLoc) { - Item &item = player.InvBody[bLoc]; + Item &item = player.bodySlot[bLoc]; if (bLoc == INVLOC_HAND_LEFT && player.GetItemLocation(item) == ILOC_TWOHAND) { - player.InvBody[INVLOC_HAND_RIGHT].clear(); + player.bodySlot[INVLOC_HAND_RIGHT].clear(); } else if (bLoc == INVLOC_HAND_RIGHT && player.GetItemLocation(item) == ILOC_TWOHAND) { - player.InvBody[INVLOC_HAND_LEFT].clear(); + player.bodySlot[INVLOC_HAND_LEFT].clear(); } CalcPlrInv(player, true); @@ -1553,7 +1553,7 @@ void CheckInvSwap(Player &player, inv_body_loc bLoc) void inv_update_rem_item(Player &player, inv_body_loc iv) { - player.InvBody[iv].clear(); + player.bodySlot[iv].clear(); CalcPlrInv(player, player._pmode != PM_DEATH); } @@ -1932,30 +1932,30 @@ int8_t CheckInvHLight() if (r == SLOTXY_HEAD) { rv = INVLOC_HEAD; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r == SLOTXY_RING_LEFT) { rv = INVLOC_RING_LEFT; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r == SLOTXY_RING_RIGHT) { rv = INVLOC_RING_RIGHT; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r == SLOTXY_AMULET) { rv = INVLOC_AMULET; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r == SLOTXY_HAND_LEFT) { rv = INVLOC_HAND_LEFT; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r == SLOTXY_HAND_RIGHT) { - pi = &myPlayer.InvBody[INVLOC_HAND_LEFT]; + pi = &myPlayer.bodySlot[INVLOC_HAND_LEFT]; if (pi->isEmpty() || myPlayer.GetItemLocation(*pi) != ILOC_TWOHAND) { rv = INVLOC_HAND_RIGHT; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else { rv = INVLOC_HAND_LEFT; } } else if (r == SLOTXY_CHEST) { rv = INVLOC_CHEST; - pi = &myPlayer.InvBody[rv]; + pi = &myPlayer.bodySlot[rv]; } else if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) { int8_t itemId = std::abs(myPlayer.InvGrid[r - SLOTXY_INV_FIRST]); if (itemId == 0) @@ -2036,7 +2036,7 @@ bool CanUseScroll(Player &player, SpellID spell) void ConsumeStaffCharge(Player &player) { - Item &staff = player.InvBody[INVLOC_HAND_LEFT]; + Item &staff = player.bodySlot[INVLOC_HAND_LEFT]; if (!CanUseStaff(staff, player.executedSpell.spellId)) return; @@ -2047,13 +2047,13 @@ void ConsumeStaffCharge(Player &player) bool CanUseStaff(Player &player, SpellID spellId) { - return CanUseStaff(player.InvBody[INVLOC_HAND_LEFT], spellId); + return CanUseStaff(player.bodySlot[INVLOC_HAND_LEFT], spellId); } Item &GetInventoryItem(Player &player, int location) { if (location < INVITEM_INV_FIRST) - return player.InvBody[location]; + return player.bodySlot[location]; if (location <= INVITEM_INV_LAST) return player.InvList[location - INVITEM_INV_FIRST]; diff --git a/Source/inv_iterators.hpp b/Source/inv_iterators.hpp index b11c9310d90..d08adb3e851 100644 --- a/Source/inv_iterators.hpp +++ b/Source/inv_iterators.hpp @@ -205,7 +205,7 @@ class EquippedPlayerItemsRange { [[nodiscard]] Iterator begin() const { - return Iterator { &player_->InvBody[0], containerSize(), 0 }; + return Iterator { &player_->bodySlot[0], containerSize(), 0 }; } [[nodiscard]] Iterator end() const @@ -216,7 +216,7 @@ class EquippedPlayerItemsRange { private: [[nodiscard]] std::size_t containerSize() const { - return sizeof(player_->InvBody) / sizeof(player_->InvBody[0]); + return sizeof(player_->bodySlot) / sizeof(player_->bodySlot[0]); } PlayerT *player_; diff --git a/Source/items.cpp b/Source/items.cpp index ac61ba57e9f..501af40e8af 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2615,8 +2615,8 @@ void CalcPlrLightRadius(Player &player, int lrad) void CalcPlrDamageMod(Player &player) { const uint8_t playerLevel = player.getCharacterLevel(); - const Item &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; - const Item &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; + const Item &leftHandItem = player.bodySlot[INVLOC_HAND_LEFT]; + const Item &rightHandItem = player.bodySlot[INVLOC_HAND_RIGHT]; const int strMod = playerLevel * player._pStrength; const int strDexMod = playerLevel * (player._pStrength + player._pDexterity); @@ -2714,8 +2714,8 @@ void CalcPlrLifeMana(Player &player, int vitality, int magic, int life, int mana void CalcPlrBlockFlag(Player &player) { - const auto &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; - const auto &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; + const auto &leftHandItem = player.bodySlot[INVLOC_HAND_LEFT]; + const auto &rightHandItem = player.bodySlot[INVLOC_HAND_RIGHT]; player._pBlockFlag = false; @@ -2733,8 +2733,8 @@ void CalcPlrBlockFlag(Player &player) PlayerWeaponGraphic GetPlrAnimWeaponId(const Player &player) { - const Item &leftHandItem = player.InvBody[INVLOC_HAND_LEFT]; - const Item &rightHandItem = player.InvBody[INVLOC_HAND_RIGHT]; + const Item &leftHandItem = player.bodySlot[INVLOC_HAND_LEFT]; + const Item &rightHandItem = player.bodySlot[INVLOC_HAND_RIGHT]; bool holdsShield = player.isHoldingItem(ItemType::Shield); bool leftHandUsable = player.CanUseItem(leftHandItem); bool rightHandUsable = player.CanUseItem(rightHandItem); @@ -2766,7 +2766,7 @@ PlayerWeaponGraphic GetPlrAnimWeaponId(const Player &player) PlayerArmorGraphic GetPlrAnimArmorId(Player &player) { - const Item &chestItem = player.InvBody[INVLOC_CHEST]; + const Item &chestItem = player.bodySlot[INVLOC_CHEST]; bool chestUsable = player.CanUseItem(chestItem); const uint8_t playerLevel = player.getCharacterLevel(); @@ -2822,7 +2822,7 @@ void CalcPlrAuricBonus(Player &player) { if (&player == MyPlayer) { - if (player.InvBody[INVLOC_AMULET].isEmpty() || player.InvBody[INVLOC_AMULET].IDidx != IDI_AURIC) { + if (player.bodySlot[INVLOC_AMULET].isEmpty() || player.bodySlot[INVLOC_AMULET].IDidx != IDI_AURIC) { int half = MaxGold; MaxGold = GOLD_MAX_LIMIT; @@ -2874,7 +2874,7 @@ void CalcPlrItemVals(Player &player, bool loadgfx) int minLightDam = 0; int maxLightDam = 0; - for (const Item &item : player.InvBody) { + for (const Item &item : player.bodySlot) { if (!item.isEmpty() && item._iStatFlag) { minDamage += item._iMinDam; @@ -3045,7 +3045,7 @@ void CreateStartingItem(Player &player, _item_indexes itemData) void CreatePlrItems(Player &player) { - for (auto &item : player.InvBody) { + for (auto &item : player.bodySlot) { item.clear(); } @@ -3769,7 +3769,7 @@ void CheckIdentify(Player &player, int cii) if (cii >= NUM_INVLOC) pi = &player.InvList[cii - NUM_INVLOC]; else - pi = &player.InvBody[cii]; + pi = &player.bodySlot[cii]; pi->_iIdentified = true; CalcPlrInv(player, true); @@ -3784,7 +3784,7 @@ void DoRepair(Player &player, int cii) if (cii >= NUM_INVLOC) { pi = &player.InvList[cii - NUM_INVLOC]; } else { - pi = &player.InvBody[cii]; + pi = &player.bodySlot[cii]; } RepairItem(*pi, player.getCharacterLevel()); @@ -3798,7 +3798,7 @@ void DoRecharge(Player &player, int cii) if (cii >= NUM_INVLOC) { pi = &player.InvList[cii - NUM_INVLOC]; } else { - pi = &player.InvBody[cii]; + pi = &player.bodySlot[cii]; } RechargeItem(*pi, player); @@ -3811,7 +3811,7 @@ bool DoOil(Player &player, int cii) if (cii >= NUM_INVLOC) { pi = &player.InvList[cii - NUM_INVLOC]; } else { - pi = &player.InvBody[cii]; + pi = &player.bodySlot[cii]; } if (!ApplyOilToItem(*pi, player)) return false; @@ -4968,11 +4968,11 @@ void RechargeItem(Item &item, Player &player) if (&player != MyPlayer) return; - if (&item == &player.InvBody[INVLOC_HAND_LEFT]) { + if (&item == &player.bodySlot[INVLOC_HAND_LEFT]) { NetSendCmdChItem(true, INVLOC_HAND_LEFT); return; } - if (&item == &player.InvBody[INVLOC_HAND_RIGHT]) { + if (&item == &player.bodySlot[INVLOC_HAND_RIGHT]) { NetSendCmdChItem(true, INVLOC_HAND_RIGHT); return; } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 0c0dd1533ad..f1140b85354 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -516,7 +516,7 @@ void LoadPlayer(LoadHelper &file, Player &player) player._pBFrames = file.NextLENarrow(); file.Skip(); // skip _pBWidth - for (Item &item : player.InvBody) + for (Item &item : player.bodySlot) LoadAndValidateItemData(file, item); for (Item &item : player.InvList) @@ -1340,7 +1340,7 @@ void SavePlayer(SaveHelper &file, const Player &player) file.WriteLE(player._pBFrames); file.Skip(); // Skip _pBWidth - for (const Item &item : player.InvBody) + for (const Item &item : player.bodySlot) SaveItem(file, item); for (const Item &item : player.InvList) @@ -2289,7 +2289,7 @@ void LoadHeroItems(Player &player) gbIsHellfireSaveGame = file.NextBool8(); - LoadMatchingItems(file, player, NUM_INVLOC, player.InvBody); + LoadMatchingItems(file, player, NUM_INVLOC, player.bodySlot); LoadMatchingItems(file, player, InventoryGridCells, player.InvList); LoadMatchingItems(file, player, MaxBeltItems, player.SpdList); @@ -2567,7 +2567,7 @@ void SaveHeroItems(SaveWriter &saveWriter, Player &player) file.WriteLE(gbIsHellfire ? 1 : 0); - for (const Item &item : player.InvBody) + for (const Item &item : player.bodySlot) SaveItem(file, item); for (const Item &item : player.InvList) SaveItem(file, item); diff --git a/Source/msg.cpp b/Source/msg.cpp index 17b09942e40..45d404c80f0 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1922,7 +1922,7 @@ size_t OnChangePlayerItems(const TCmd *pCmd, Player &player) if (gbBufferMsgs == 1) { SendPacket(player, &message, sizeof(message)); } else if (&player != MyPlayer && IsItemAvailable(static_cast<_item_indexes>(SDL_SwapLE16(message.def.wIndx)))) { - Item &item = player.InvBody[message.bLoc]; + Item &item = player.bodySlot[message.bLoc]; item = {}; RecreateItem(player, message, item); CheckInvSwap(player, bodyLocation); @@ -3087,7 +3087,7 @@ void NetSendCmdChItem(bool bHiPri, uint8_t bLoc, bool forceSpellChange) { TCmdChItem cmd {}; - Item &item = MyPlayer->InvBody[bLoc]; + Item &item = MyPlayer->bodySlot[bLoc]; cmd.bCmd = CMD_CHANGEPLRITEMS; cmd.bLoc = bLoc; diff --git a/Source/objects.cpp b/Source/objects.cpp index 2cd1d279b3b..88e18605eb8 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2275,12 +2275,12 @@ void OperateShrineHidden(DiabloGenerator &rng, Player &player) return; int cnt = 0; - for (const auto &item : player.InvBody) { + for (const auto &item : player.bodySlot) { if (!item.isEmpty()) cnt++; } if (cnt > 0) { - for (auto &item : player.InvBody) { + for (auto &item : player.bodySlot) { if (!item.isEmpty() && item._iMaxDur != DUR_INDESTRUCTIBLE && item._iMaxDur != 0) { @@ -2292,7 +2292,7 @@ void OperateShrineHidden(DiabloGenerator &rng, Player &player) } while (true) { cnt = 0; - for (auto &item : player.InvBody) { + for (auto &item : player.bodySlot) { if (!item.isEmpty() && item._iMaxDur != DUR_INDESTRUCTIBLE && item._iMaxDur != 0) { cnt++; } @@ -2300,15 +2300,15 @@ void OperateShrineHidden(DiabloGenerator &rng, Player &player) if (cnt == 0) break; int r = rng.generateRnd(NUM_INVLOC); - if (player.InvBody[r].isEmpty() || player.InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || player.InvBody[r]._iMaxDur == 0) + if (player.bodySlot[r].isEmpty() || player.bodySlot[r]._iMaxDur == DUR_INDESTRUCTIBLE || player.bodySlot[r]._iMaxDur == 0) continue; - player.InvBody[r]._iDurability -= 20; - player.InvBody[r]._iMaxDur -= 20; - if (player.InvBody[r]._iDurability <= 0) - player.InvBody[r]._iDurability = 1; - if (player.InvBody[r]._iMaxDur <= 0) - player.InvBody[r]._iMaxDur = 1; + player.bodySlot[r]._iDurability -= 20; + player.bodySlot[r]._iMaxDur -= 20; + if (player.bodySlot[r]._iDurability <= 0) + player.bodySlot[r]._iDurability = 1; + if (player.bodySlot[r]._iMaxDur <= 0) + player.bodySlot[r]._iMaxDur = 1; break; } } @@ -2355,10 +2355,10 @@ void OperateShrineWeird(Player &player) if (&player != MyPlayer) return; - if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() && player.InvBody[INVLOC_HAND_LEFT]._itype != ItemType::Shield) - player.InvBody[INVLOC_HAND_LEFT]._iMaxDam++; - if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._itype != ItemType::Shield) - player.InvBody[INVLOC_HAND_RIGHT]._iMaxDam++; + if (!player.bodySlot[INVLOC_HAND_LEFT].isEmpty() && player.bodySlot[INVLOC_HAND_LEFT]._itype != ItemType::Shield) + player.bodySlot[INVLOC_HAND_LEFT]._iMaxDam++; + if (!player.bodySlot[INVLOC_HAND_RIGHT].isEmpty() && player.bodySlot[INVLOC_HAND_RIGHT]._itype != ItemType::Shield) + player.bodySlot[INVLOC_HAND_RIGHT]._iMaxDam++; for (Item &item : InventoryPlayerItemsRange { player }) { switch (item._itype) { @@ -2959,7 +2959,7 @@ void OperateShrineMurphys(DiabloGenerator &rng, Player &player) return; bool broke = false; - for (auto &item : player.InvBody) { + for (auto &item : player.bodySlot) { if (!item.isEmpty() && rng.flipCoin(3)) { if (item._iDurability != DUR_INDESTRUCTIBLE) { if (item._iDurability > 0) { diff --git a/Source/pack.cpp b/Source/pack.cpp index d1c0f37c2c6..b79a81d2579 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -281,7 +281,7 @@ void PackPlayer(PlayerPack &packed, const Player &player) packed.pSplLvl2[i - 37] = player._pSplLvl[i]; for (int i = 0; i < NUM_INVLOC; i++) - PackItem(packed.InvBody[i], player.InvBody[i], gbIsHellfire); + PackItem(packed.bodySlot[i], player.bodySlot[i], gbIsHellfire); packed._pNumInv = player._pNumInv; for (int i = 0; i < packed._pNumInv; i++) @@ -338,7 +338,7 @@ void PackNetPlayer(PlayerNetPack &packed, const Player &player) packed.pSplLvl[i] = player._pSplLvl[i]; for (int i = 0; i < NUM_INVLOC; i++) - PackNetItem(player.InvBody[i], packed.InvBody[i]); + PackNetItem(player.bodySlot[i], packed.bodySlot[i]); packed._pNumInv = player._pNumInv; for (int i = 0; i < packed._pNumInv; i++) @@ -510,7 +510,7 @@ void UnPackPlayer(const PlayerPack &packed, Player &player) bool isHellfire = packed.bIsHellfire != 0; for (int i = 0; i < NUM_INVLOC; i++) - UnPackItem(packed.InvBody[i], player, player.InvBody[i], isHellfire); + UnPackItem(packed.bodySlot[i], player, player.bodySlot[i], isHellfire); player._pNumInv = packed._pNumInv; for (int i = 0; i < player._pNumInv; i++) @@ -623,11 +623,11 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player) player._pSplLvl[i] = packed.pSplLvl[i]; for (int i = 0; i < NUM_INVLOC; i++) { - if (!UnPackNetItem(player, packed.InvBody[i], player.InvBody[i])) + if (!UnPackNetItem(player, packed.bodySlot[i], player.bodySlot[i])) return false; - if (player.InvBody[i].isEmpty()) + if (player.bodySlot[i].isEmpty()) continue; - auto loc = static_cast(player.GetItemLocation(player.InvBody[i])); + auto loc = static_cast(player.GetItemLocation(player.bodySlot[i])); switch (i) { case INVLOC_HEAD: ValidateField(loc, loc == ILOC_HELM); diff --git a/Source/pack.h b/Source/pack.h index 5ed545c6435..d1e3b2ab950 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -55,7 +55,7 @@ struct PlayerPack { int32_t pMaxManaBase; uint8_t pSplLvl[37]; // Should be MAX_SPELLS but set to 37 to make save games compatible uint64_t pMemSpells; - ItemPack InvBody[NUM_INVLOC]; + ItemPack bodySlot[NUM_INVLOC]; ItemPack InvList[InventoryGridCells]; int8_t InvGrid[InventoryGridCells]; uint8_t _pNumInv; @@ -104,7 +104,7 @@ struct PlayerNetPack { int32_t pMaxManaBase; uint8_t pSplLvl[MAX_SPELLS]; uint64_t pMemSpells; - ItemNetPack InvBody[NUM_INVLOC]; + ItemNetPack bodySlot[NUM_INVLOC]; ItemNetPack InvList[InventoryGridCells]; int8_t InvGrid[InventoryGridCells]; uint8_t _pNumInv; diff --git a/Source/panels/charpanel.cpp b/Source/panels/charpanel.cpp index 10c3e513963..092e912e193 100644 --- a/Source/panels/charpanel.cpp +++ b/Source/panels/charpanel.cpp @@ -85,7 +85,7 @@ UiFlags GetMaxHealthColor() std::pair GetDamage() { int damageMod = InspectPlayer->_pIBonusDamMod; - if (InspectPlayer->InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Bow && InspectPlayer->_pClass != HeroClass::Rogue) { + if (InspectPlayer->bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Bow && InspectPlayer->_pClass != HeroClass::Rogue) { damageMod += InspectPlayer->_pDamageMod / 2; } else { damageMod += InspectPlayer->_pDamageMod; @@ -171,7 +171,7 @@ PanelEntry panelEntries[] = { { N_("Armor class"), { RightColumnLabelX, 163 }, 57, RightColumnLabelWidth, []() { return StyledText { GetValueColor(InspectPlayer->_pIBonusAC), StrCat(InspectPlayer->GetArmor() + InspectPlayer->getCharacterLevel() * 2) }; } }, { N_("To hit"), { RightColumnLabelX, 191 }, 57, RightColumnLabelWidth, - []() { return StyledText { GetValueColor(InspectPlayer->_pIBonusToHit), StrCat(InspectPlayer->InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Bow ? InspectPlayer->GetRangedToHit() : InspectPlayer->GetMeleeToHit(), "%") }; } }, + []() { return StyledText { GetValueColor(InspectPlayer->_pIBonusToHit), StrCat(InspectPlayer->bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Bow ? InspectPlayer->GetRangedToHit() : InspectPlayer->GetMeleeToHit(), "%") }; } }, { N_("Damage"), { RightColumnLabelX, 219 }, 57, RightColumnLabelWidth, []() { const auto [dmgMin, dmgMax] = GetDamage(); diff --git a/Source/panels/spell_book.cpp b/Source/panels/spell_book.cpp index aab487ba249..cf6a1f7c983 100644 --- a/Source/panels/spell_book.cpp +++ b/Source/panels/spell_book.cpp @@ -183,7 +183,7 @@ void DrawSpellBook(const Surface &out) PrintSBookStr(out, line1, _("Skill")); break; case SpellType::Charges: { - const int charges = player.InvBody[INVLOC_HAND_LEFT]._iCharges; + const int charges = player.bodySlot[INVLOC_HAND_LEFT]._iCharges; PrintSBookStr(out, line1, fmt::format(fmt::runtime(ngettext("Staff ({:d} charge)", "Staff ({:d} charges)", charges)), charges)); } break; default: { diff --git a/Source/panels/spell_list.cpp b/Source/panels/spell_list.cpp index 26da82c5452..044530ec8d8 100644 --- a/Source/panels/spell_list.cpp +++ b/Source/panels/spell_list.cpp @@ -182,7 +182,7 @@ void DrawSpellList(const Surface &out) } PrintSBookSpellType(out, spellListItem.location, _("Staff"), spellColor); InfoString = fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", spellDataItem.sNameText)); - int charges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges; + int charges = myPlayer.bodySlot[INVLOC_HAND_LEFT]._iCharges; AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", charges)), charges)); } break; case SpellType::Invalid: diff --git a/Source/pfile.cpp b/Source/pfile.cpp index f2baa6c75ce..37cc6b0ec28 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -518,7 +518,7 @@ void pfile_write_hero(SaveWriter &saveWriter, bool writeGameData) void RemoveAllInvalidItems(Player &player) { for (int i = 0; i < NUM_INVLOC; i++) - RemoveInvalidItem(player.InvBody[i]); + RemoveInvalidItem(player.bodySlot[i]); for (int i = 0; i < player._pNumInv; i++) RemoveInvalidItem(player.InvList[i]); for (int i = 0; i < MaxBeltItems; i++) diff --git a/Source/player.cpp b/Source/player.cpp index 7f21af54eff..12e15abddfe 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -446,9 +446,9 @@ bool DoWalk(Player &player) bool WeaponDecay(Player &player, int ii) { - if (!player.InvBody[ii].isEmpty() && player.InvBody[ii]._iClass == ICLASS_WEAPON && HasAnyOf(player.InvBody[ii]._iDamAcFlags, ItemSpecialEffectHf::Decay)) { - player.InvBody[ii]._iPLDam -= 5; - if (player.InvBody[ii]._iPLDam <= -100) { + if (!player.bodySlot[ii].isEmpty() && player.bodySlot[ii]._iClass == ICLASS_WEAPON && HasAnyOf(player.bodySlot[ii]._iDamAcFlags, ItemSpecialEffectHf::Decay)) { + player.bodySlot[ii]._iPLDam -= 5; + if (player.bodySlot[ii]._iPLDam <= -100) { RemoveEquipment(player, static_cast(ii), true); CalcPlrInv(player, true); return true; @@ -473,52 +473,52 @@ bool DamageWeapon(Player &player, unsigned damageFrequency) return false; } - if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() && player.InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + if (!player.bodySlot[INVLOC_HAND_LEFT].isEmpty() && player.bodySlot[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { return false; } - player.InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability <= 0) { + player.bodySlot[INVLOC_HAND_LEFT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability <= 0) { RemoveEquipment(player, INVLOC_HAND_LEFT, true); CalcPlrInv(player, true); return true; } } - if (!player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) { - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + if (!player.bodySlot[INVLOC_HAND_RIGHT].isEmpty() && player.bodySlot[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) { + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { return false; } - player.InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + player.bodySlot[INVLOC_HAND_RIGHT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability == 0) { RemoveEquipment(player, INVLOC_HAND_RIGHT, true); CalcPlrInv(player, true); return true; } } - if (player.InvBody[INVLOC_HAND_LEFT].isEmpty() && player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + if (player.bodySlot[INVLOC_HAND_LEFT].isEmpty() && player.bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { return false; } - player.InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + player.bodySlot[INVLOC_HAND_RIGHT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability == 0) { RemoveEquipment(player, INVLOC_HAND_RIGHT, true); CalcPlrInv(player, true); return true; } } - if (player.InvBody[INVLOC_HAND_RIGHT].isEmpty() && player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Shield) { - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + if (player.bodySlot[INVLOC_HAND_RIGHT].isEmpty() && player.bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Shield) { + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { return false; } - player.InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + player.bodySlot[INVLOC_HAND_LEFT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability == 0) { RemoveEquipment(player, INVLOC_HAND_LEFT, true); CalcPlrInv(player, true); return true; @@ -578,10 +578,10 @@ bool PlrHitMonst(Player &player, Monster &monster, bool adjacentDamage = false) } ItemType phanditype = ItemType::None; - if (player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Sword || player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Sword) { + if (player.bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Sword || player.bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Sword) { phanditype = ItemType::Sword; } - if (player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Mace || player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Mace) { + if (player.bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Mace || player.bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Mace) { phanditype = ItemType::Mace; } @@ -920,22 +920,22 @@ void DamageParryItem(Player &player) return; } - if (player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Shield || player.InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Staff) { - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + if (player.bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Shield || player.bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Staff) { + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { return; } - player.InvBody[INVLOC_HAND_LEFT]._iDurability--; - if (player.InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + player.bodySlot[INVLOC_HAND_LEFT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_LEFT]._iDurability == 0) { RemoveEquipment(player, INVLOC_HAND_LEFT, true); CalcPlrInv(player, true); } } - if (player.InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) { - player.InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if (player.InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + if (player.bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Shield) { + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) { + player.bodySlot[INVLOC_HAND_RIGHT]._iDurability--; + if (player.bodySlot[INVLOC_HAND_RIGHT]._iDurability == 0) { RemoveEquipment(player, INVLOC_HAND_RIGHT, true); CalcPlrInv(player, true); } @@ -964,23 +964,23 @@ void DamageArmor(Player &player) return; } - if (player.InvBody[INVLOC_CHEST].isEmpty() && player.InvBody[INVLOC_HEAD].isEmpty()) { + if (player.bodySlot[INVLOC_CHEST].isEmpty() && player.bodySlot[INVLOC_HEAD].isEmpty()) { return; } bool targetHead = FlipCoin(3); - if (!player.InvBody[INVLOC_CHEST].isEmpty() && player.InvBody[INVLOC_HEAD].isEmpty()) { + if (!player.bodySlot[INVLOC_CHEST].isEmpty() && player.bodySlot[INVLOC_HEAD].isEmpty()) { targetHead = false; } - if (player.InvBody[INVLOC_CHEST].isEmpty() && !player.InvBody[INVLOC_HEAD].isEmpty()) { + if (player.bodySlot[INVLOC_CHEST].isEmpty() && !player.bodySlot[INVLOC_HEAD].isEmpty()) { targetHead = true; } Item *pi; if (targetHead) { - pi = &player.InvBody[INVLOC_HEAD]; + pi = &player.bodySlot[INVLOC_HEAD]; } else { - pi = &player.InvBody[INVLOC_CHEST]; + pi = &player.bodySlot[INVLOC_CHEST]; } if (pi->_iDurability == DUR_INDESTRUCTIBLE) { return; @@ -1781,7 +1781,7 @@ void Player::RestorePartialMana() void Player::ReadySpellFromEquipment(inv_body_loc bodyLocation, bool forceSpell) { - Item &item = InvBody[bodyLocation]; + Item &item = bodySlot[bodyLocation]; if (item._itype == ItemType::Staff && IsValidSpell(item._iSpell) && item._iCharges > 0 && item._iStatFlag) { if (forceSpell || _pRSpell == SpellID::Invalid || _pRSplType == SpellType::Invalid) { _pRSpell = item._iSpell; @@ -2680,7 +2680,7 @@ StartPlayerKill(Player &player, DeathReason deathReason) if (&player != MyPlayer && dropItems) { // Ensure that items are removed for remote players // The dropped items will be synced seperatly (by the remote client) - for (Item &item : player.InvBody) { + for (Item &item : player.bodySlot) { item.clear(); } CalcPlrInv(player, false); @@ -2734,7 +2734,7 @@ StartPlayerKill(Player &player, DeathReason deathReason) } if (dropItems) { Direction pdd = player._pdir; - for (Item &item : player.InvBody) { + for (Item &item : player.bodySlot) { pdd = Left(pdd); DeadItem(player, item.pop(), Displacement(pdd)); } @@ -3106,10 +3106,10 @@ void MakePlrPath(Player &player, Point targetPosition, bool endspace) void CalcPlrStaff(Player &player) { player._pISpells = 0; - if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() - && player.InvBody[INVLOC_HAND_LEFT]._iStatFlag - && player.InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { - player._pISpells |= GetSpellBitmask(player.InvBody[INVLOC_HAND_LEFT]._iSpell); + if (!player.bodySlot[INVLOC_HAND_LEFT].isEmpty() + && player.bodySlot[INVLOC_HAND_LEFT]._iStatFlag + && player.bodySlot[INVLOC_HAND_LEFT]._iCharges > 0) { + player._pISpells |= GetSpellBitmask(player.bodySlot[INVLOC_HAND_LEFT]._iSpell); } } diff --git a/Source/player.h b/Source/player.h index a6c392c5413..d493dad89e0 100644 --- a/Source/player.h +++ b/Source/player.h @@ -218,7 +218,7 @@ struct Player { Player &operator=(Player &&) noexcept = default; char _pName[PlayerNameLength]; - Item InvBody[NUM_INVLOC]; + Item bodySlot[NUM_INVLOC]; // InvBody Item InvList[InventoryGridCells]; Item SpdList[MaxBeltItems]; Item HoldItem; @@ -415,7 +415,7 @@ struct Player { case HeroClass::Monk: return isEquipped(ItemType::Staff); case HeroClass::Bard: - return InvBody[INVLOC_HAND_LEFT]._itype == ItemType::Sword && InvBody[INVLOC_HAND_RIGHT]._itype == ItemType::Sword; + return bodySlot[INVLOC_HAND_LEFT]._itype == ItemType::Sword && bodySlot[INVLOC_HAND_RIGHT]._itype == ItemType::Sword; case HeroClass::Barbarian: return isEquipped(ItemType::Axe) || (!isEquipped(ItemType::Shield) && (isEquipped(ItemType::Mace, true) || isEquipped(ItemType::Sword, true))); default: @@ -432,18 +432,18 @@ struct Player { case ItemType::Mace: case ItemType::Shield: case ItemType::Staff: - return (InvBody[INVLOC_HAND_LEFT]._itype == itemType && (!isTwoHanded || InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND)) - || (InvBody[INVLOC_HAND_RIGHT]._itype == itemType && (!isTwoHanded || InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND)); + return (bodySlot[INVLOC_HAND_LEFT]._itype == itemType && (!isTwoHanded || bodySlot[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND)) + || (bodySlot[INVLOC_HAND_RIGHT]._itype == itemType && (!isTwoHanded || bodySlot[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND)); case ItemType::LightArmor: case ItemType::MediumArmor: case ItemType::HeavyArmor: - return InvBody[INVLOC_CHEST]._itype == itemType; + return bodySlot[INVLOC_CHEST]._itype == itemType; case ItemType::Helm: - return InvBody[INVLOC_HEAD]._itype == itemType; + return bodySlot[INVLOC_HEAD]._itype == itemType; case ItemType::Ring: - return InvBody[INVLOC_RING_LEFT]._itype == itemType || InvBody[INVLOC_RING_RIGHT]._itype == itemType; + return bodySlot[INVLOC_RING_LEFT]._itype == itemType || bodySlot[INVLOC_RING_RIGHT]._itype == itemType; case ItemType::Amulet: - return InvBody[INVLOC_AMULET]._itype == itemType; + return bodySlot[INVLOC_AMULET]._itype == itemType; default: return false; } @@ -487,7 +487,7 @@ struct Player { }; const Item *mostValuableItem = getMostValuableItem(SpdList, SpdList + MaxBeltItems); - mostValuableItem = getMostValuableItem(InvBody, InvBody + inv_body_loc::NUM_INVLOC, mostValuableItem); + mostValuableItem = getMostValuableItem(bodySlot, bodySlot + inv_body_loc::NUM_INVLOC, mostValuableItem); mostValuableItem = getMostValuableItem(InvList, InvList + _pNumInv, mostValuableItem); return mostValuableItem; @@ -898,8 +898,8 @@ struct Player { /** @brief Checks if the player is holding an item of the provided type, and is usable. */ bool isHoldingItem(const ItemType type) const { - const Item &leftHandItem = InvBody[INVLOC_HAND_LEFT]; - const Item &rightHandItem = InvBody[INVLOC_HAND_RIGHT]; + const Item &leftHandItem = bodySlot[INVLOC_HAND_LEFT]; + const Item &rightHandItem = bodySlot[INVLOC_HAND_RIGHT]; return (type == leftHandItem._itype && leftHandItem._iStatFlag) || (type == rightHandItem._itype && rightHandItem._iStatFlag); } diff --git a/Source/stores.cpp b/Source/stores.cpp index baa6afb9a09..6757d560952 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -606,22 +606,22 @@ void StartSmithRepair() Player &myPlayer = *MyPlayer; - auto &helmet = myPlayer.InvBody[INVLOC_HEAD]; + auto &helmet = myPlayer.bodySlot[INVLOC_HEAD]; if (!helmet.isEmpty() && helmet._iDurability != helmet._iMaxDur) { AddStoreHoldRepair(&helmet, -1); } - auto &armor = myPlayer.InvBody[INVLOC_CHEST]; + auto &armor = myPlayer.bodySlot[INVLOC_CHEST]; if (!armor.isEmpty() && armor._iDurability != armor._iMaxDur) { AddStoreHoldRepair(&armor, -2); } - auto &leftHand = myPlayer.InvBody[INVLOC_HAND_LEFT]; + auto &leftHand = myPlayer.bodySlot[INVLOC_HAND_LEFT]; if (!leftHand.isEmpty() && leftHand._iDurability != leftHand._iMaxDur) { AddStoreHoldRepair(&leftHand, -3); } - auto &rightHand = myPlayer.InvBody[INVLOC_HAND_RIGHT]; + auto &rightHand = myPlayer.bodySlot[INVLOC_HAND_RIGHT]; if (!rightHand.isEmpty() && rightHand._iDurability != rightHand._iMaxDur) { AddStoreHoldRepair(&rightHand, -4); } @@ -863,7 +863,7 @@ void StartWitchRecharge() } const Player &myPlayer = *MyPlayer; - const auto &leftHand = myPlayer.InvBody[INVLOC_HAND_LEFT]; + const auto &leftHand = myPlayer.bodySlot[INVLOC_HAND_LEFT]; if ((leftHand._itype == ItemType::Staff || leftHand._iMiscId == IMISC_UNIQUE) && leftHand._iCharges != leftHand._iMaxCharges) { rechargeok = true; @@ -1110,43 +1110,43 @@ void StartStorytellerIdentify() Player &myPlayer = *MyPlayer; - auto &helmet = myPlayer.InvBody[INVLOC_HEAD]; + auto &helmet = myPlayer.bodySlot[INVLOC_HEAD]; if (IdItemOk(&helmet)) { idok = true; AddStoreHoldId(helmet, -1); } - auto &armor = myPlayer.InvBody[INVLOC_CHEST]; + auto &armor = myPlayer.bodySlot[INVLOC_CHEST]; if (IdItemOk(&armor)) { idok = true; AddStoreHoldId(armor, -2); } - auto &leftHand = myPlayer.InvBody[INVLOC_HAND_LEFT]; + auto &leftHand = myPlayer.bodySlot[INVLOC_HAND_LEFT]; if (IdItemOk(&leftHand)) { idok = true; AddStoreHoldId(leftHand, -3); } - auto &rightHand = myPlayer.InvBody[INVLOC_HAND_RIGHT]; + auto &rightHand = myPlayer.bodySlot[INVLOC_HAND_RIGHT]; if (IdItemOk(&rightHand)) { idok = true; AddStoreHoldId(rightHand, -4); } - auto &leftRing = myPlayer.InvBody[INVLOC_RING_LEFT]; + auto &leftRing = myPlayer.bodySlot[INVLOC_RING_LEFT]; if (IdItemOk(&leftRing)) { idok = true; AddStoreHoldId(leftRing, -5); } - auto &rightRing = myPlayer.InvBody[INVLOC_RING_RIGHT]; + auto &rightRing = myPlayer.bodySlot[INVLOC_RING_RIGHT]; if (IdItemOk(&rightRing)) { idok = true; AddStoreHoldId(rightRing, -6); } - auto &amulet = myPlayer.InvBody[INVLOC_AMULET]; + auto &amulet = myPlayer.bodySlot[INVLOC_AMULET]; if (IdItemOk(&amulet)) { idok = true; AddStoreHoldId(amulet, -7); @@ -1494,13 +1494,13 @@ void SmithRepairItem(int price) if (i < 0) { if (i == -1) - myPlayer.InvBody[INVLOC_HEAD]._iDurability = myPlayer.InvBody[INVLOC_HEAD]._iMaxDur; + myPlayer.bodySlot[INVLOC_HEAD]._iDurability = myPlayer.bodySlot[INVLOC_HEAD]._iMaxDur; if (i == -2) - myPlayer.InvBody[INVLOC_CHEST]._iDurability = myPlayer.InvBody[INVLOC_CHEST]._iMaxDur; + myPlayer.bodySlot[INVLOC_CHEST]._iDurability = myPlayer.bodySlot[INVLOC_CHEST]._iMaxDur; if (i == -3) - myPlayer.InvBody[INVLOC_HAND_LEFT]._iDurability = myPlayer.InvBody[INVLOC_HAND_LEFT]._iMaxDur; + myPlayer.bodySlot[INVLOC_HAND_LEFT]._iDurability = myPlayer.bodySlot[INVLOC_HAND_LEFT]._iMaxDur; if (i == -4) - myPlayer.InvBody[INVLOC_HAND_RIGHT]._iDurability = myPlayer.InvBody[INVLOC_HAND_RIGHT]._iMaxDur; + myPlayer.bodySlot[INVLOC_HAND_RIGHT]._iDurability = myPlayer.bodySlot[INVLOC_HAND_RIGHT]._iMaxDur; return; } @@ -1646,7 +1646,7 @@ void WitchRechargeItem(int price) int8_t i = storehidx[idx]; if (i < 0) { - myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iMaxCharges; + myPlayer.bodySlot[INVLOC_HAND_LEFT]._iCharges = myPlayer.bodySlot[INVLOC_HAND_LEFT]._iMaxCharges; NetSendCmdChItem(true, INVLOC_HAND_LEFT); } else { myPlayer.InvList[i]._iCharges = myPlayer.InvList[i]._iMaxCharges; @@ -1791,19 +1791,19 @@ void StorytellerIdentifyItem(Item &item) int8_t idx = storehidx[((stextlhold - stextup) / 4) + stextvhold]; if (idx < 0) { if (idx == -1) - myPlayer.InvBody[INVLOC_HEAD]._iIdentified = true; + myPlayer.bodySlot[INVLOC_HEAD]._iIdentified = true; if (idx == -2) - myPlayer.InvBody[INVLOC_CHEST]._iIdentified = true; + myPlayer.bodySlot[INVLOC_CHEST]._iIdentified = true; if (idx == -3) - myPlayer.InvBody[INVLOC_HAND_LEFT]._iIdentified = true; + myPlayer.bodySlot[INVLOC_HAND_LEFT]._iIdentified = true; if (idx == -4) - myPlayer.InvBody[INVLOC_HAND_RIGHT]._iIdentified = true; + myPlayer.bodySlot[INVLOC_HAND_RIGHT]._iIdentified = true; if (idx == -5) - myPlayer.InvBody[INVLOC_RING_LEFT]._iIdentified = true; + myPlayer.bodySlot[INVLOC_RING_LEFT]._iIdentified = true; if (idx == -6) - myPlayer.InvBody[INVLOC_RING_RIGHT]._iIdentified = true; + myPlayer.bodySlot[INVLOC_RING_RIGHT]._iIdentified = true; if (idx == -7) - myPlayer.InvBody[INVLOC_AMULET]._iIdentified = true; + myPlayer.bodySlot[INVLOC_AMULET]._iIdentified = true; } else { myPlayer.InvList[idx]._iIdentified = true; } diff --git a/Source/sync.cpp b/Source/sync.cpp index d758212d667..8a0279a486b 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -136,7 +136,7 @@ void SyncPlrInv(TSyncHeader *pHdr) pHdr->bPInvLoc = -1; assert(sgnSyncPInv > -1 && sgnSyncPInv < NUM_INVLOC); - const auto &item = MyPlayer->InvBody[sgnSyncPInv]; + const auto &item = MyPlayer->bodySlot[sgnSyncPInv]; if (!item.isEmpty()) { pHdr->bPInvLoc = sgnSyncPInv; pHdr->wPInvIndx = SDL_SwapLE16(item.IDidx); diff --git a/test/fixtures/memory_map/hero.txt b/test/fixtures/memory_map/hero.txt index 3211f57829c..f97062ed25a 100644 --- a/test/fixtures/memory_map/hero.txt +++ b/test/fixtures/memory_map/hero.txt @@ -24,7 +24,7 @@ R 32 pManaBase R 32 pMaxManaBase M 37 8 pSplLvl R 64 pMemSpells -C 7 itemPack InvBody +C 7 itemPack bodySlot C 40 itemPack InvList M 40 8 InvGrid R 8 _pNumInv diff --git a/test/pack_test.cpp b/test/pack_test.cpp index 79d78e8d23b..1f39b2ce01f 100644 --- a/test/pack_test.cpp +++ b/test/pack_test.cpp @@ -31,7 +31,7 @@ void SwapLE(PlayerPack &pack) pack.pManaBase = SDL_SwapLE32(pack.pManaBase); pack.pMaxManaBase = SDL_SwapLE32(pack.pMaxManaBase); pack.pMemSpells = SDL_SwapLE64(pack.pMemSpells); - for (ItemPack &item : pack.InvBody) + for (ItemPack &item : pack.bodySlot) SwapLE(item); for (ItemPack &item : pack.InvList) SwapLE(item); @@ -1125,7 +1125,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iMinDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iMinDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iMinDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1138,7 +1138,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iMaxDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iMaxDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iMaxDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1151,7 +1151,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iAC) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_CHEST]._iAC++; + MyPlayer->bodySlot[INVLOC_CHEST]._iAC++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1164,7 +1164,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iBonusDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iPLDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iPLDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1177,7 +1177,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iBonusToHit) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iPLToHit++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iPLToHit++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1190,7 +1190,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iBonusAC) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_CHEST]._iPLAC++; + MyPlayer->bodySlot[INVLOC_CHEST]._iPLAC++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1203,7 +1203,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iBonusDamMod) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iPLDamMod++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iPLDamMod++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1216,7 +1216,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iGetHit) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_CHEST]._iPLGetHit++; + MyPlayer->bodySlot[INVLOC_CHEST]._iPLGetHit++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1229,7 +1229,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iEnAc) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_CHEST]._iPLEnAc++; + MyPlayer->bodySlot[INVLOC_CHEST]._iPLEnAc++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1242,7 +1242,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iFMinDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iFMinDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iFMinDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1255,7 +1255,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iFMaxDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iFMaxDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iFMaxDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1268,7 +1268,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iLMinDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iLMinDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iLMinDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1281,7 +1281,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_iLMaxDam) CalcPlrItemVals(*MyPlayer, false); ASSERT_TRUE(TestNetPackValidation()); - MyPlayer->InvBody[INVLOC_HAND_LEFT]._iLMaxDam++; + MyPlayer->bodySlot[INVLOC_HAND_LEFT]._iLMaxDam++; CalcPlrItemVals(*MyPlayer, false); ASSERT_FALSE(TestNetPackValidation()); } @@ -1360,7 +1360,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_townItemLevel) { size_t boyCount = 0; size_t otherCount = 0; - for (Item &item : MyPlayer->InvBody) { + for (Item &item : MyPlayer->bodySlot) { if (item.isEmpty()) continue; if (IsAnyOf(item.IDidx, IDI_GOLD, IDI_EAR)) @@ -1406,7 +1406,7 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_uniqueMonsterItemLevel) TEST_F(NetPackTest, UnPackNetPlayer_invalid_monsterItemLevel) { size_t count = 0; - for (Item &item : MyPlayer->InvBody) { + for (Item &item : MyPlayer->bodySlot) { if (item.isEmpty()) continue; if (IsAnyOf(item.IDidx, IDI_GOLD, IDI_EAR)) diff --git a/test/player_test.cpp b/test/player_test.cpp index 40dec523fac..8b88900de81 100644 --- a/test/player_test.cpp +++ b/test/player_test.cpp @@ -94,7 +94,7 @@ static void AssertPlayer(Player &player) { ASSERT_EQ(CountU8(player._pSplLvl, 64), 0); ASSERT_EQ(Count8(player.InvGrid, InventoryGridCells), 1); - ASSERT_EQ(CountItems(player.InvBody, NUM_INVLOC), 1); + ASSERT_EQ(CountItems(player.bodySlot, NUM_INVLOC), 1); ASSERT_EQ(CountItems(player.InvList, InventoryGridCells), 1); ASSERT_EQ(CountItems(player.SpdList, MaxBeltItems), 2); ASSERT_EQ(CountItems(&player.HoldItem, 1), 0); diff --git a/test/writehero_test.cpp b/test/writehero_test.cpp index adef0be6db6..19fbadf0b15 100644 --- a/test/writehero_test.cpp +++ b/test/writehero_test.cpp @@ -46,7 +46,7 @@ void SwapLE(PlayerPack &player) player.pManaBase = SDL_SwapLE32(player.pManaBase); player.pMaxManaBase = SDL_SwapLE32(player.pMaxManaBase); player.pMemSpells = SDL_SwapLE64(player.pMemSpells); - for (ItemPack &item : player.InvBody) { + for (ItemPack &item : player.bodySlot) { SwapLE(item); } for (ItemPack &item : player.InvList) { @@ -219,7 +219,7 @@ void PackPlayerTest(PlayerPack *pPack) for (auto i = 0; i < 40; i++) pPack->InvList[i].idx = -1; for (auto i = 0; i < 7; i++) - pPack->InvBody[i].idx = -1; + pPack->bodySlot[i].idx = -1; for (auto i = 0; i < MaxBeltItems; i++) PackItemFullRejuv(pPack->SpdList + i, i); for (auto i = 1; i < 37; i++) { @@ -229,7 +229,7 @@ void PackPlayerTest(PlayerPack *pPack) } } for (auto i = 0; i < 7; i++) - pPack->InvBody[i].idx = -1; + pPack->bodySlot[i].idx = -1; strcpy(pPack->pName, "TestPlayer"); pPack->pClass = static_cast(HeroClass::Rogue); pPack->pBaseStr = 20 + 35; @@ -241,12 +241,12 @@ void PackPlayerTest(PlayerPack *pPack) pPack->pManaBase = (15 << 6) + (15 << 5) + 48 * 128 + (55 << 6); pPack->pMaxManaBase = pPack->pManaBase; - PackItemUnique(pPack->InvBody + INVLOC_HEAD, 52); - PackItemRing1(pPack->InvBody + INVLOC_RING_LEFT); - PackItemRing2(pPack->InvBody + INVLOC_RING_RIGHT); - PackItemAmulet(pPack->InvBody + INVLOC_AMULET); - PackItemArmor(pPack->InvBody + INVLOC_CHEST); - PackItemBow(pPack->InvBody + INVLOC_HAND_LEFT); + PackItemUnique(pPack->bodySlot + INVLOC_HEAD, 52); + PackItemRing1(pPack->bodySlot + INVLOC_RING_LEFT); + PackItemRing2(pPack->bodySlot + INVLOC_RING_RIGHT); + PackItemAmulet(pPack->bodySlot + INVLOC_AMULET); + PackItemArmor(pPack->bodySlot + INVLOC_CHEST); + PackItemBow(pPack->bodySlot + INVLOC_HAND_LEFT); PackItemStaff(pPack->InvList + PrepareInvSlot(pPack, 28, 2, 1)); PackItemSword(pPack->InvList + PrepareInvSlot(pPack, 20, 1)); @@ -260,7 +260,7 @@ void AssertPlayer(Player &player) { ASSERT_EQ(CountU8(player._pSplLvl, 64), 23); ASSERT_EQ(Count8(player.InvGrid, InventoryGridCells), 9); - ASSERT_EQ(CountItems(player.InvBody, NUM_INVLOC), 6); + ASSERT_EQ(CountItems(player.bodySlot, NUM_INVLOC), 6); ASSERT_EQ(CountItems(player.InvList, InventoryGridCells), 2); ASSERT_EQ(CountItems(player.SpdList, MaxBeltItems), 8); ASSERT_EQ(CountItems(&player.HoldItem, 1), 0);