Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Player struct variables: InvBody #7219

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
126 changes: 63 additions & 63 deletions Source/inv.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Source/inv_iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_;
Expand Down
32 changes: 16 additions & 16 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
player._pBFrames = file.NextLENarrow<int32_t, int8_t>();
file.Skip<uint32_t>(); // skip _pBWidth

for (Item &item : player.InvBody)
for (Item &item : player.bodySlot)
LoadAndValidateItemData(file, item);

for (Item &item : player.InvList)
Expand Down Expand Up @@ -1340,7 +1340,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
file.WriteLE<int32_t>(player._pBFrames);
file.Skip<uint32_t>(); // Skip _pBWidth

for (const Item &item : player.InvBody)
for (const Item &item : player.bodySlot)
SaveItem(file, item);

for (const Item &item : player.InvList)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -2567,7 +2567,7 @@ void SaveHeroItems(SaveWriter &saveWriter, Player &player)

file.WriteLE<uint8_t>(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);
Expand Down
4 changes: 2 additions & 2 deletions Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 15 additions & 15 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -2292,23 +2292,23 @@ 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++;
}
}
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;
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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<int8_t>(player.GetItemLocation(player.InvBody[i]));
auto loc = static_cast<int8_t>(player.GetItemLocation(player.bodySlot[i]));
switch (i) {
case INVLOC_HEAD:
ValidateField(loc, loc == ILOC_HELM);
Expand Down
4 changes: 2 additions & 2 deletions Source/pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Source/panels/charpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ UiFlags GetMaxHealthColor()
std::pair<int, int> 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;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Source/panels/spell_book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion Source/panels/spell_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
Loading
Loading