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: SpdList #7221

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
2 changes: 1 addition & 1 deletion Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ void plrctrls_after_game_logic()
void UseBeltItem(int type)
{
for (int i = 0; i < MaxBeltItems; i++) {
Item &item = MyPlayer->SpdList[i];
Item &item = MyPlayer->beltSlot[i];
if (item.isEmpty()) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/controls/touch/renderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void PotionButtonRenderer::RenderPotion(RenderFunction renderFunction, const But

std::optional<VirtualGamepadPotionType> PotionButtonRenderer::GetPotionType()
{
for (const Item &item : InspectPlayer->SpdList) {
for (const Item &item : InspectPlayer->beltSlot) {
if (item.isEmpty()) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ void InitKeymapActions()
'1' + i,
[i] {
Player &myPlayer = *MyPlayer;
if (!myPlayer.SpdList[i].isEmpty() && myPlayer.SpdList[i]._itype != ItemType::Gold) {
if (!myPlayer.beltSlot[i].isEmpty() && myPlayer.beltSlot[i]._itype != ItemType::Gold) {
UseInvItem(INVITEM_BELT_FIRST + i);
}
},
Expand Down Expand Up @@ -1993,7 +1993,7 @@ void InitPadmapActions()
ControllerButton_NONE,
[i] {
Player &myPlayer = *MyPlayer;
if (!myPlayer.SpdList[i].isEmpty() && myPlayer.SpdList[i]._itype != ItemType::Gold) {
if (!myPlayer.beltSlot[i].isEmpty() && myPlayer.beltSlot[i]._itype != ItemType::Gold) {
UseInvItem(INVITEM_BELT_FIRST + i);
}
},
Expand Down
40 changes: 20 additions & 20 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ bool ChangeInvItem(Player &player, int slot, Size itemSize)
void ChangeBeltItem(Player &player, int slot)
{
const int ii = slot - SLOTXY_BELT_FIRST;
if (player.SpdList[ii].isEmpty()) {
player.SpdList[ii] = player.HoldItem.pop();
if (player.beltSlot[ii].isEmpty()) {
player.beltSlot[ii] = player.HoldItem.pop();
} else {
std::swap(player.SpdList[ii], player.HoldItem);
std::swap(player.beltSlot[ii], player.HoldItem);

if (player.HoldItem._itype == ItemType::Gold)
player._pGold = CalculateGold(player);
Expand Down Expand Up @@ -817,7 +817,7 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool
}

if (r >= SLOTXY_BELT_FIRST) {
Item &beltItem = player.SpdList[r - SLOTXY_BELT_FIRST];
Item &beltItem = player.beltSlot[r - SLOTXY_BELT_FIRST];
if (!beltItem.isEmpty()) {
holdItem = beltItem;
if (automaticMove) {
Expand Down Expand Up @@ -1000,7 +1000,7 @@ void StartGoldDrop()

const int max = (invIndex <= INVITEM_INV_LAST)
? myPlayer.InvList[invIndex - INVITEM_INV_FIRST]._ivalue
: myPlayer.SpdList[invIndex - INVITEM_BELT_FIRST]._ivalue;
: myPlayer.beltSlot[invIndex - INVITEM_BELT_FIRST]._ivalue;

if (talkflag)
control_reset_talk();
Expand Down Expand Up @@ -1200,26 +1200,26 @@ void DrawInvBelt(const Surface &out)
Player &myPlayer = *InspectPlayer;

for (int i = 0; i < MaxBeltItems; i++) {
if (myPlayer.SpdList[i].isEmpty()) {
if (myPlayer.beltSlot[i].isEmpty()) {
continue;
}

const Point position { InvRect[i + SLOTXY_BELT_FIRST].position.x + mainPanelPosition.x, InvRect[i + SLOTXY_BELT_FIRST].position.y + mainPanelPosition.y + InventorySlotSizeInPixels.height };
InvDrawSlotBack(out, position, InventorySlotSizeInPixels, myPlayer.SpdList[i]._iMagical);
const int cursId = myPlayer.SpdList[i]._iCurs + CURSOR_FIRSTITEM;
InvDrawSlotBack(out, position, InventorySlotSizeInPixels, myPlayer.beltSlot[i]._iMagical);
const int cursId = myPlayer.beltSlot[i]._iCurs + CURSOR_FIRSTITEM;

const ClxSprite sprite = GetInvItemSprite(cursId);

if (pcursinvitem == i + INVITEM_BELT_FIRST) {
if (ControlMode == ControlTypes::KeyboardAndMouse || invflag) {
ClxDrawOutline(out, GetOutlineColor(myPlayer.SpdList[i], true), position, sprite);
ClxDrawOutline(out, GetOutlineColor(myPlayer.beltSlot[i], true), position, sprite);
}
}

DrawItem(myPlayer.SpdList[i], out, position, sprite);
DrawItem(myPlayer.beltSlot[i], out, position, sprite);

if (myPlayer.SpdList[i].isUsable()
&& myPlayer.SpdList[i]._itype != ItemType::Gold) {
if (myPlayer.beltSlot[i].isUsable()
&& myPlayer.beltSlot[i]._itype != ItemType::Gold) {
DrawString(out, StrCat(i + 1), { position - Displacement { 0, 12 }, InventorySlotSizeInPixels },
{ .flags = UiFlags::ColorWhite | UiFlags::AlignRight });
}
Expand All @@ -1241,14 +1241,14 @@ bool AutoPlaceItemInBelt(Player &player, const Item &item, bool persistItem, boo
return false;
}

for (Item &beltItem : player.SpdList) {
for (Item &beltItem : player.beltSlot) {
if (beltItem.isEmpty()) {
if (persistItem) {
beltItem = item;
player.CalcScrolls();
RedrawComponent(PanelDrawComponent::Belt);
if (sendNetworkMessage) {
const auto beltIndex = static_cast<int>(std::distance<const Item *>(&player.SpdList[0], &beltItem));
const auto beltIndex = static_cast<int>(std::distance<const Item *>(&player.beltSlot[0], &beltItem));
NetSendCmdChBeltItem(false, beltIndex);
}
}
Expand Down Expand Up @@ -1966,7 +1966,7 @@ int8_t CheckInvHLight()
} else if (r >= SLOTXY_BELT_FIRST) {
r -= SLOTXY_BELT_FIRST;
RedrawComponent(PanelDrawComponent::Belt);
pi = &myPlayer.SpdList[r];
pi = &myPlayer.beltSlot[r];
if (pi->isEmpty())
return -1;
rv = r + INVITEM_BELT_FIRST;
Expand Down Expand Up @@ -2010,7 +2010,7 @@ void ConsumeScroll(Player &player)
}
} else if (itemSlot >= INVITEM_BELT_FIRST && itemSlot <= INVITEM_BELT_LAST) {
const int itemIndex = itemSlot - INVITEM_BELT_FIRST;
const Item *item = &player.SpdList[itemIndex];
const Item *item = &player.beltSlot[itemIndex];
if (!item->isEmpty() && isCurrentSpell(*item)) {
player.RemoveSpdBarItem(itemIndex);
return;
Expand Down Expand Up @@ -2058,7 +2058,7 @@ Item &GetInventoryItem(Player &player, int location)
if (location <= INVITEM_INV_LAST)
return player.InvList[location - INVITEM_INV_FIRST];

return player.SpdList[location - INVITEM_BELT_FIRST];
return player.beltSlot[location - INVITEM_BELT_FIRST];
}

bool UseInvItem(int cii)
Expand Down Expand Up @@ -2088,7 +2088,7 @@ bool UseInvItem(int cii)
return true;
c = cii - INVITEM_BELT_FIRST;

item = &player.SpdList[c];
item = &player.beltSlot[c];
speedlist = true;

// If selected speedlist item exists in InvList, use the InvList item.
Expand All @@ -2105,7 +2105,7 @@ bool UseInvItem(int cii)
// If speedlist item is not inventory, use same item at the end of the speedlist if exists.
if (speedlist && *sgOptions.Gameplay.autoRefillBelt) {
for (int i = INVITEM_BELT_LAST - INVITEM_BELT_FIRST; i > c; i--) {
Item &candidate = player.SpdList[i];
Item &candidate = player.beltSlot[i];

if (!candidate.isEmpty() && candidate._iMiscId == item->_iMiscId && candidate._iSpell == item->_iSpell) {
c = i;
Expand Down Expand Up @@ -2179,7 +2179,7 @@ bool UseInvItem(int cii)
UseItem(player, item->_iMiscId, item->_iSpell, cii);

if (speedlist) {
if (player.SpdList[c]._iMiscId == IMISC_NOTE) {
if (player.beltSlot[c]._iMiscId == IMISC_NOTE) {
InitQTextMsg(TEXT_BOOK9);
CloseInventory();
return true;
Expand Down
4 changes: 2 additions & 2 deletions Source/inv_iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class BeltPlayerItemsRange {

[[nodiscard]] Iterator begin() const
{
return Iterator { &player_->SpdList[0], containerSize(), 0 };
return Iterator { &player_->beltSlot[0], containerSize(), 0 };
}

[[nodiscard]] Iterator end() const
Expand All @@ -286,7 +286,7 @@ class BeltPlayerItemsRange {
private:
[[nodiscard]] std::size_t containerSize() const
{
return sizeof(player_->SpdList) / sizeof(player_->SpdList[0]);
return sizeof(player_->beltSlot) / sizeof(player_->beltSlot[0]);
}

PlayerT *player_;
Expand Down
2 changes: 1 addition & 1 deletion Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,7 @@ void CreatePlrItems(Player &player)

player._pNumInv = 0;

for (auto &item : player.SpdList) {
for (auto &item : player.beltSlot) {
item.clear();
}

Expand Down
8 changes: 4 additions & 4 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
for (int8_t &cell : player.InvGrid)
cell = file.NextLE<int8_t>();

for (Item &item : player.SpdList)
for (Item &item : player.beltSlot)
LoadAndValidateItemData(file, item);

LoadAndValidateItemData(file, player.HoldItem);
Expand Down Expand Up @@ -1351,7 +1351,7 @@ void SavePlayer(SaveHelper &file, const Player &player)
for (int8_t cell : player.InvGrid)
file.WriteLE<int8_t>(cell);

for (const Item &item : player.SpdList)
for (const Item &item : player.beltSlot)
SaveItem(file, item);

SaveItem(file, player.HoldItem);
Expand Down Expand Up @@ -2291,7 +2291,7 @@ void LoadHeroItems(Player &player)

LoadMatchingItems(file, player, NUM_INVLOC, player.InvBody);
LoadMatchingItems(file, player, InventoryGridCells, player.InvList);
LoadMatchingItems(file, player, MaxBeltItems, player.SpdList);
LoadMatchingItems(file, player, MaxBeltItems, player.beltSlot);

gbIsHellfireSaveGame = gbIsHellfire;
}
Expand Down Expand Up @@ -2571,7 +2571,7 @@ void SaveHeroItems(SaveWriter &saveWriter, Player &player)
SaveItem(file, item);
for (const Item &item : player.InvList)
SaveItem(file, item);
for (const Item &item : player.SpdList)
for (const Item &item : player.beltSlot)
SaveItem(file, item);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/lua/modules/dev/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::string DebugCmdItemInfo()
if (pcursinvitem <= INVITEM_INV_LAST)
pItem = &myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST];
else
pItem = &myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST];
pItem = &myPlayer.beltSlot[pcursinvitem - INVITEM_BELT_FIRST];
} else if (pcursitem != -1) {
pItem = &Items[pcursitem];
}
Expand Down
2 changes: 1 addition & 1 deletion Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ void AddStealPotions(Missile &missile, AddMissileParameter & /*parameter*/)

bool hasPlayedSFX = false;
for (int si = 0; si < MaxBeltItems; si++) {
Item &beltItem = player->SpdList[si];
Item &beltItem = player->beltSlot[si];
_item_indexes ii = IDI_NONE;
if (beltItem._itype == ItemType::Misc) {
if (FlipCoin())
Expand Down
4 changes: 2 additions & 2 deletions Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ size_t OnChangeBeltItems(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.SpdList[message.bLoc];
Item &item = player.beltSlot[message.bLoc];
item = {};
RecreateItem(player, message, item);
}
Expand Down Expand Up @@ -3146,7 +3146,7 @@ void NetSendCmdChBeltItem(bool bHiPri, int beltIndex)
{
TCmdChItem cmd {};

const Item &item = MyPlayer->SpdList[beltIndex];
const Item &item = MyPlayer->beltSlot[beltIndex];

cmd.bCmd = CMD_CHANGEBELTITEMS;
cmd.bLoc = beltIndex;
Expand Down
10 changes: 5 additions & 5 deletions Source/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void PackPlayer(PlayerPack &packed, const Player &player)
packed.InvGrid[i] = player.InvGrid[i];

for (int i = 0; i < MaxBeltItems; i++)
PackItem(packed.SpdList[i], player.SpdList[i], gbIsHellfire);
PackItem(packed.beltSlot[i], player.beltSlot[i], gbIsHellfire);

packed.wReflections = SDL_SwapLE16(player.wReflections);
packed.pDamAcFlags = SDL_SwapLE32(static_cast<uint32_t>(player.pDamAcFlags));
Expand Down Expand Up @@ -348,7 +348,7 @@ void PackNetPlayer(PlayerNetPack &packed, const Player &player)
packed.InvGrid[i] = player.InvGrid[i];

for (int i = 0; i < MaxBeltItems; i++)
PackNetItem(player.SpdList[i], packed.SpdList[i]);
PackNetItem(player.beltSlot[i], packed.beltSlot[i]);

packed.wReflections = SDL_SwapLE16(player.wReflections);
packed.pDiabloKillLevel = player.pDiabloKillLevel;
Expand Down Expand Up @@ -522,7 +522,7 @@ void UnPackPlayer(const PlayerPack &packed, Player &player)
VerifyGoldSeeds(player);

for (int i = 0; i < MaxBeltItems; i++)
UnPackItem(packed.SpdList[i], player, player.SpdList[i], isHellfire);
UnPackItem(packed.beltSlot[i], player, player.beltSlot[i], isHellfire);

CalcPlrInv(player, false);
player.wReflections = SDL_SwapLE16(packed.wReflections);
Expand Down Expand Up @@ -659,8 +659,8 @@ bool UnPackNetPlayer(const PlayerNetPack &packed, Player &player)
player.InvGrid[i] = packed.InvGrid[i];

for (int i = 0; i < MaxBeltItems; i++) {
Item &item = player.SpdList[i];
if (!UnPackNetItem(player, packed.SpdList[i], item))
Item &item = player.beltSlot[i];
if (!UnPackNetItem(player, packed.beltSlot[i], item))
return false;
if (item.isEmpty())
continue;
Expand Down
4 changes: 2 additions & 2 deletions Source/pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct PlayerPack {
ItemPack InvList[InventoryGridCells];
int8_t InvGrid[InventoryGridCells];
uint8_t _pNumInv;
ItemPack SpdList[MaxBeltItems];
ItemPack beltSlot[MaxBeltItems];
int8_t pTownWarps;
int8_t pDungMsgs;
int8_t pLvlLoad;
Expand Down Expand Up @@ -108,7 +108,7 @@ struct PlayerNetPack {
ItemNetPack InvList[InventoryGridCells];
int8_t InvGrid[InventoryGridCells];
uint8_t _pNumInv;
ItemNetPack SpdList[MaxBeltItems];
ItemNetPack beltSlot[MaxBeltItems];
uint8_t pManaShield;
uint16_t wReflections;
uint8_t pDiabloKillLevel;
Expand Down
2 changes: 1 addition & 1 deletion Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void RemoveAllInvalidItems(Player &player)
for (int i = 0; i < player._pNumInv; i++)
RemoveInvalidItem(player.InvList[i]);
for (int i = 0; i < MaxBeltItems; i++)
RemoveInvalidItem(player.SpdList[i]);
RemoveInvalidItem(player.beltSlot[i]);
RemoveEmptyInventory(player);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ void Player::RemoveSpdBarItem(int iv)
NetSendCmdParam1(false, CMD_DELBELTITEMS, iv);
}

SpdList[iv].clear();
beltSlot[iv].clear();

CalcScrolls();
RedrawEverything();
Expand Down
4 changes: 2 additions & 2 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ struct Player {
char _pName[PlayerNameLength];
Item InvBody[NUM_INVLOC];
Item InvList[InventoryGridCells];
Item SpdList[MaxBeltItems];
Item beltSlot[MaxBeltItems]; // SpdList
Item HoldItem;

int lightId;
Expand Down Expand Up @@ -486,7 +486,7 @@ struct Player {
return mostValuableItem;
};

const Item *mostValuableItem = getMostValuableItem(SpdList, SpdList + MaxBeltItems);
const Item *mostValuableItem = getMostValuableItem(beltSlot, beltSlot + MaxBeltItems);
mostValuableItem = getMostValuableItem(InvBody, InvBody + inv_body_loc::NUM_INVLOC, mostValuableItem);
mostValuableItem = getMostValuableItem(InvList, InvList + _pNumInv, mostValuableItem);

Expand Down
Loading
Loading