diff --git a/Source/control.cpp b/Source/control.cpp index d9eb3df9c..0f72dc181 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -437,7 +437,7 @@ void PrintInfo(const Surface &out) } } -int CapStatPointsToAdd(int remainingStatPoints, const PlayerStruct &player, CharacterAttribute attribute) +int CapStatPointsToAdd(int remainingStatPoints, const Player &player, CharacterAttribute attribute) { int pointsToReachCap = player.GetMaximumAttributeValue(attribute) - player.GetBaseAttributeValue(attribute); @@ -510,7 +510,7 @@ spell_type GetSBookTrans(spell_id ii, bool townok) return st; } -void ControlSetGoldCurs(PlayerStruct &player) +void ControlSetGoldCurs(Player &player) { SetPlrHandGoldCurs(player.HoldItem); NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM); @@ -571,7 +571,7 @@ void ControlUpDown(int v) } } -void RemoveGold(PlayerStruct &player, int goldIndex) +void RemoveGold(Player &player, int goldIndex) { int gi = goldIndex - INVITEM_INV_FIRST; player.InvList[gi]._ivalue -= dropGoldValue; diff --git a/Source/control.h b/Source/control.h index 0874605d2..8b2c7cec4 100644 --- a/Source/control.h +++ b/Source/control.h @@ -102,7 +102,7 @@ void DrawManaFlaskLower(const Surface &out); * * This is used to ensure that DrawFlask routines display an accurate representation of the players health/mana * - * @see PlayerStruct::UpdateHitPointPercentage() and PlayerStruct::UpdateManaPercentage() + * @see Player::UpdateHitPointPercentage() and Player::UpdateManaPercentage() */ void control_update_life_mana(); diff --git a/Source/inv.cpp b/Source/inv.cpp index 91e8d0c0a..c1d1dfe9d 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -162,7 +162,7 @@ void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size) * @param invListIndex The item's InvList index (it's expected this already has +1 added to it since InvGrid can't store a 0 index) * @param itemSize Size of item */ -void AddItemToInvGrid(PlayerStruct &player, int invGridIndex, int invListIndex, Size itemSize) +void AddItemToInvGrid(Player &player, int invGridIndex, int invListIndex, Size itemSize) { const int pitch = 10; for (int y = 0; y < itemSize.height; y++) { @@ -233,7 +233,7 @@ bool CanEquip(const ItemStruct &item) * @return 'True' if the player can currently equip the item in either one of his hands (i.e. the required hands are empty and * allow the item), and 'False' otherwise. */ -bool CanWield(PlayerStruct &player, const ItemStruct &item) +bool CanWield(Player &player, const ItemStruct &item) { if (!CanEquip(item) || (item._iLoc != ILOC_ONEHAND && item._iLoc != ILOC_TWOHAND)) return false; @@ -285,7 +285,7 @@ bool CanWield(PlayerStruct &player, const ItemStruct &item) * @return 'True' if the player can currently equip the item in the specified body location (i.e. the body location is empty and * allows the item), and 'False' otherwise. */ -bool CanEquip(PlayerStruct &player, const ItemStruct &item, inv_body_loc bodyLocation) +bool CanEquip(Player &player, const ItemStruct &item, inv_body_loc bodyLocation) { if (!CanEquip(item) || player._pmode > PM_WALK3 || !player.InvBody[bodyLocation].isEmpty()) { return false; @@ -896,7 +896,7 @@ void CheckInvCut(int pnum, Point cursorPosition, bool automaticMove) } } -void CheckBookLevel(PlayerStruct &player) +void CheckBookLevel(Player &player) { if (player.HoldItem._iMiscId != IMISC_BOOK) return; @@ -913,7 +913,7 @@ void CheckBookLevel(PlayerStruct &player) } } -void CheckNaKrulNotes(PlayerStruct &player) +void CheckNaKrulNotes(Player &player) { int idx = player.HoldItem.IDidx; _item_indexes notes[] = { IDI_NOTE1, IDI_NOTE2, IDI_NOTE3 }; @@ -945,7 +945,7 @@ void CheckNaKrulNotes(PlayerStruct &player) Items[itemNum] = tmp; } -void CheckQuestItem(PlayerStruct &player) +void CheckQuestItem(Player &player) { auto &myPlayer = Players[MyPlayerId]; @@ -1021,7 +1021,7 @@ void CleanupItems(ItemStruct *item, int ii) } } -bool PutItem(PlayerStruct &player, Point &position) +bool PutItem(Player &player, Point &position) { if (ActiveItemCount >= MAXITEMS) return false; @@ -1272,7 +1272,7 @@ void DrawInvBelt(const Surface &out) * @param persistItem Pass 'True' to actually place the item in the belt. The default is 'False'. * @return 'True' in case the item can be placed on the player's belt and 'False' otherwise. */ -bool AutoPlaceItemInBelt(PlayerStruct &player, const ItemStruct &item, bool persistItem) +bool AutoPlaceItemInBelt(Player &player, const ItemStruct &item, bool persistItem) { if (!CanBePlacedOnBelt(item)) { return false; @@ -1323,7 +1323,7 @@ bool AutoEquip(int playerId, const ItemStruct &item, bool persistItem) * @param item The item to check. * @return 'True' if auto-equipping behavior is enabled for the player and item and 'False' otherwise. */ -bool AutoEquipEnabled(const PlayerStruct &player, const ItemStruct &item) +bool AutoEquipEnabled(const Player &player, const ItemStruct &item) { if (item.isWeapon()) { // Monk can use unarmed attack as an encouraged option, thus we do not automatically equip weapons on him so as to not @@ -1357,7 +1357,7 @@ bool AutoEquipEnabled(const PlayerStruct &player, const ItemStruct &item) * @param persistItem Pass 'True' to actually place the item in the inventory. The default is 'False'. * @return 'True' in case the item can be placed on the player's inventory and 'False' otherwise. */ -bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool persistItem) +bool AutoPlaceItemInInventory(Player &player, const ItemStruct &item, bool persistItem) { Size itemSize = GetInventorySize(item); @@ -1425,7 +1425,7 @@ bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool * @param persistItem Pass 'True' to actually place the item in the inventory slot. The default is 'False'. * @return 'True' in case the item can be placed on the specified player's inventory slot and 'False' otherwise. */ -bool AutoPlaceItemInInventorySlot(PlayerStruct &player, int slotIndex, const ItemStruct &item, bool persistItem) +bool AutoPlaceItemInInventorySlot(Player &player, int slotIndex, const ItemStruct &item, bool persistItem) { int yy = (slotIndex > 0) ? (10 * (slotIndex / 10)) : 0; @@ -1455,7 +1455,7 @@ bool AutoPlaceItemInInventorySlot(PlayerStruct &player, int slotIndex, const Ite return true; } -bool GoldAutoPlace(PlayerStruct &player) +bool GoldAutoPlace(Player &player) { bool done = false; @@ -1493,7 +1493,7 @@ bool GoldAutoPlace(PlayerStruct &player) return done; } -bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex) +bool GoldAutoPlaceInInventorySlot(Player &player, int slotIndex) { if (player.InvGrid[slotIndex] != 0) { return false; @@ -1521,7 +1521,7 @@ bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex) return true; } -void CheckInvSwap(PlayerStruct &player, BYTE bLoc, int idx, uint16_t wCI, int seed, bool bId, uint32_t dwBuff) +void CheckInvSwap(Player &player, BYTE bLoc, int idx, uint16_t wCI, int seed, bool bId, uint32_t dwBuff) { auto &item = Items[MAXITEMS]; memset(&item, 0, sizeof(item)); @@ -1546,7 +1546,7 @@ void CheckInvSwap(PlayerStruct &player, BYTE bLoc, int idx, uint16_t wCI, int se CalcPlrInv(player, true); } -void inv_update_rem_item(PlayerStruct &player, BYTE iv) +void inv_update_rem_item(Player &player, BYTE iv) { if (iv < NUM_INVLOC) { player.InvBody[iv]._itype = ITYPE_NONE; @@ -1575,7 +1575,7 @@ void CheckInvScrn(bool isShiftHeld) } } -void CheckItemStats(PlayerStruct &player) +void CheckItemStats(Player &player) { ItemStruct &item = player.HoldItem; @@ -1774,7 +1774,7 @@ bool TryInvPut() return CanPut(myPlayer.position.tile); } -int InvPutItem(PlayerStruct &player, Point position) +int InvPutItem(Player &player, Point position) { if (!PutItem(player, position)) return -1; @@ -1824,7 +1824,7 @@ int InvPutItem(PlayerStruct &player, Point position) return ii; } -int SyncPutItem(PlayerStruct &player, Point position, int idx, uint16_t icreateinfo, int iseed, int id, int dur, int mdur, int ch, int mch, int ivalue, uint32_t ibuff, int toHit, int maxDam, int minStr, int minMag, int minDex, int ac) +int SyncPutItem(Player &player, Point position, int idx, uint16_t icreateinfo, int iseed, int id, int dur, int mdur, int ch, int mch, int ivalue, uint32_t ibuff, int toHit, int maxDam, int minStr, int minMag, int minDex, int ac) { if (!PutItem(player, position)) return -1; @@ -1958,7 +1958,7 @@ int8_t CheckInvHLight() return rv; } -void RemoveScroll(PlayerStruct &player) +void RemoveScroll(Player &player) { for (int i = 0; i < player._pNumInv; i++) { if (!player.InvList[i].isEmpty() @@ -2008,7 +2008,7 @@ bool UseScroll() return false; } -void UseStaffCharge(PlayerStruct &player) +void UseStaffCharge(Player &player) { auto &staff = player.InvBody[INVLOC_HAND_LEFT]; @@ -2142,7 +2142,7 @@ void DoTelekinesis() NewCursor(CURSOR_HAND); } -int CalculateGold(PlayerStruct &player) +int CalculateGold(Player &player) { int gold = 0; diff --git a/Source/inv.h b/Source/inv.h index c9a0fa202..a027350b1 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -97,34 +97,34 @@ void InitInv(); void DrawInv(const Surface &out); void DrawInvBelt(const Surface &out); -bool AutoEquipEnabled(const PlayerStruct &player, const ItemStruct &item); +bool AutoEquipEnabled(const Player &player, const ItemStruct &item); bool AutoEquip(int playerId, const ItemStruct &item, bool persistItem = true); -bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool persistItem = false); -bool AutoPlaceItemInInventorySlot(PlayerStruct &player, int slotIndex, const ItemStruct &item, bool persistItem); -bool AutoPlaceItemInBelt(PlayerStruct &player, const ItemStruct &item, bool persistItem = false); -bool GoldAutoPlace(PlayerStruct &player); -bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex); -void CheckInvSwap(PlayerStruct &player, BYTE bLoc, int idx, uint16_t wCI, int seed, bool bId, uint32_t dwBuff); -void inv_update_rem_item(PlayerStruct &player, BYTE iv); +bool AutoPlaceItemInInventory(Player &player, const ItemStruct &item, bool persistItem = false); +bool AutoPlaceItemInInventorySlot(Player &player, int slotIndex, const ItemStruct &item, bool persistItem); +bool AutoPlaceItemInBelt(Player &player, const ItemStruct &item, bool persistItem = false); +bool GoldAutoPlace(Player &player); +bool GoldAutoPlaceInInventorySlot(Player &player, int slotIndex); +void CheckInvSwap(Player &player, BYTE bLoc, int idx, uint16_t wCI, int seed, bool bId, uint32_t dwBuff); +void inv_update_rem_item(Player &player, BYTE iv); void CheckInvItem(bool isShiftHeld = false); void CheckInvScrn(bool isShiftHeld); -void CheckItemStats(PlayerStruct &player); +void CheckItemStats(Player &player); void InvGetItem(int pnum, ItemStruct *item, int ii); void AutoGetItem(int pnum, ItemStruct *item, int ii); int FindGetItem(int idx, uint16_t ci, int iseed); void SyncGetItem(Point position, int idx, uint16_t ci, int iseed); bool CanPut(Point position); bool TryInvPut(); -int InvPutItem(PlayerStruct &player, Point position); -int SyncPutItem(PlayerStruct &player, Point position, int idx, uint16_t icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, uint32_t ibuff, int toHit, int maxDam, int minStr, int minMag, int minDex, int ac); +int InvPutItem(Player &player, Point position); +int SyncPutItem(Player &player, Point position, int idx, uint16_t icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, uint32_t ibuff, int toHit, int maxDam, int minStr, int minMag, int minDex, int ac); int8_t CheckInvHLight(); -void RemoveScroll(PlayerStruct &player); +void RemoveScroll(Player &player); bool UseScroll(); -void UseStaffCharge(PlayerStruct &player); +void UseStaffCharge(Player &player); bool UseStaff(); bool UseInvItem(int pnum, int cii); void DoTelekinesis(); -int CalculateGold(PlayerStruct &player); +int CalculateGold(Player &player); bool DropItemBeforeTrig(); /* data */ diff --git a/Source/inv_iterators.hpp b/Source/inv_iterators.hpp index 56b39288c..6b7dce616 100644 --- a/Source/inv_iterators.hpp +++ b/Source/inv_iterators.hpp @@ -179,7 +179,7 @@ public: */ class EquippedPlayerItemsRange { public: - explicit EquippedPlayerItemsRange(PlayerStruct &player) + explicit EquippedPlayerItemsRange(Player &player) : player_(&player) { } @@ -200,7 +200,7 @@ private: return sizeof(player_->InvBody) / sizeof(player_->InvBody[0]); } - PlayerStruct *player_; + Player *player_; }; /** @@ -208,7 +208,7 @@ private: */ class InventoryPlayerItemsRange { public: - explicit InventoryPlayerItemsRange(PlayerStruct &player) + explicit InventoryPlayerItemsRange(Player &player) : player_(&player) { } @@ -229,7 +229,7 @@ private: return static_cast(player_->_pNumInv); } - PlayerStruct *player_; + Player *player_; }; /** @@ -237,7 +237,7 @@ private: */ class BeltPlayerItemsRange { public: - explicit BeltPlayerItemsRange(PlayerStruct &player) + explicit BeltPlayerItemsRange(Player &player) : player_(&player) { } @@ -258,7 +258,7 @@ private: return sizeof(player_->SpdList) / sizeof(player_->SpdList[0]); } - PlayerStruct *player_; + Player *player_; }; /** @@ -266,7 +266,7 @@ private: */ class PlayerItemsRange { public: - explicit PlayerItemsRange(PlayerStruct &player) + explicit PlayerItemsRange(Player &player) : player_(&player) { } @@ -291,7 +291,7 @@ public: } private: - PlayerStruct *player_; + Player *player_; }; } // namespace devilution diff --git a/Source/items.cpp b/Source/items.cpp index 678039152..14ccbc4c8 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -459,7 +459,7 @@ void SpawnNote() SpawnQuestItem(id, position, 0, 1); } -void CalcSelfItems(PlayerStruct &player) +void CalcSelfItems(Player &player) { int sa = 0; int ma = 0; @@ -503,7 +503,7 @@ void CalcSelfItems(PlayerStruct &player) } while (changeflag); } -bool ItemMinStats(const PlayerStruct &player, ItemStruct &x) +bool ItemMinStats(const Player &player, ItemStruct &x) { if (player._pMagic < x._iMinMag) return false; @@ -517,7 +517,7 @@ bool ItemMinStats(const PlayerStruct &player, ItemStruct &x) return true; } -void CalcPlrItemMin(PlayerStruct &player) +void CalcPlrItemMin(Player &player) { for (int i = 0; i < player._pNumInv; i++) { auto &item = player.InvList[i]; @@ -561,7 +561,7 @@ bool StoreStatOk(ItemStruct &item) return true; } -void CalcPlrBookVals(PlayerStruct &player) +void CalcPlrBookVals(Player &player) { if (currlevel == 0) { for (int i = 1; !witchitem[i].isEmpty(); i++) { @@ -1783,7 +1783,7 @@ void RechargeItem(ItemStruct &item, int r) item._iCharges = std::min(item._iCharges, item._iMaxCharges); } -bool ApplyOilToItem(ItemStruct &item, PlayerStruct &player) +bool ApplyOilToItem(ItemStruct &item, Player &player) { int r; @@ -2625,7 +2625,7 @@ void InitItems() initItemGetRecords(); } -void CalcPlrItemVals(PlayerStruct &player, bool loadgfx) +void CalcPlrItemVals(Player &player, bool loadgfx) { int mind = 0; // min damage int maxd = 0; // max damage @@ -2986,7 +2986,7 @@ void CalcPlrItemVals(PlayerStruct &player, bool loadgfx) drawhpflag = true; } -void CalcPlrInv(PlayerStruct &player, bool loadgfx) +void CalcPlrInv(Player &player, bool loadgfx) { CalcPlrItemMin(player); CalcSelfItems(player); @@ -3045,7 +3045,7 @@ void GetPlrHandSeed(ItemStruct *h) h->_iSeed = AdvanceRndSeed(); } -void SetGoldSeed(PlayerStruct &player, ItemStruct &gold) +void SetGoldSeed(Player &player, ItemStruct &gold) { int s = 0; @@ -3762,7 +3762,7 @@ void GetItemStr(ItemStruct &item) } } -void CheckIdentify(PlayerStruct &player, int cii) +void CheckIdentify(Player &player, int cii) { ItemStruct *pi; @@ -3778,7 +3778,7 @@ void CheckIdentify(PlayerStruct &player, int cii) NewCursor(CURSOR_HAND); } -void DoRepair(PlayerStruct &player, int cii) +void DoRepair(Player &player, int cii) { ItemStruct *pi; @@ -3797,7 +3797,7 @@ void DoRepair(PlayerStruct &player, int cii) NewCursor(CURSOR_HAND); } -void DoRecharge(PlayerStruct &player, int cii) +void DoRecharge(Player &player, int cii) { ItemStruct *pi; @@ -3817,7 +3817,7 @@ void DoRecharge(PlayerStruct &player, int cii) NewCursor(CURSOR_HAND); } -void DoOil(PlayerStruct &player, int cii) +void DoOil(Player &player, int cii) { ItemStruct *pi; if (cii >= NUM_INVLOC) { diff --git a/Source/items.h b/Source/items.h index bfb0a6823..59de608f9 100644 --- a/Source/items.h +++ b/Source/items.h @@ -396,7 +396,7 @@ struct CornerStoneStruct { ItemStruct item; }; -struct PlayerStruct; +struct Player; extern ItemStruct Items[MAXITEMS + 1]; extern int ActiveItems[MAXITEMS]; @@ -411,14 +411,14 @@ bool IsItemAvailable(int i); bool IsUniqueAvailable(int i); void InitItemGFX(); void InitItems(); -void CalcPlrItemVals(PlayerStruct &player, bool Loadgfx); -void CalcPlrInv(PlayerStruct &player, bool Loadgfx); +void CalcPlrItemVals(Player &player, bool Loadgfx); +void CalcPlrInv(Player &player, bool Loadgfx); void SetPlrHandItem(ItemStruct &item, int itemData); void GetPlrHandSeed(ItemStruct *h); /** * @brief Set a new unique seed value on the given item */ -void SetGoldSeed(PlayerStruct &player, ItemStruct &gold); +void SetGoldSeed(Player &player, ItemStruct &gold); int GetGoldCursor(int value); void SetPlrHandGoldCurs(ItemStruct &gold); void CreatePlrItems(int playerId); @@ -448,10 +448,10 @@ void ProcessItems(); void FreeItemGFX(); void GetItemFrm(ItemStruct &item); void GetItemStr(ItemStruct &item); -void CheckIdentify(PlayerStruct &player, int cii); -void DoRepair(PlayerStruct &player, int cii); -void DoRecharge(PlayerStruct &player, int cii); -void DoOil(PlayerStruct &player, int cii); +void CheckIdentify(Player &player, int cii); +void DoRepair(Player &player, int cii); +void DoRecharge(Player &player, int cii); +void DoOil(Player &player, int cii); void PrintItemPower(char plidx, ItemStruct *x); void DrawUniqueInfo(const Surface &out); void PrintItemDetails(ItemStruct *x); diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index de341b9bf..c1e8d77c4 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -304,7 +304,7 @@ void LoadItems(LoadHelper *file, const int n, ItemStruct *pItem) } } -void LoadPlayer(LoadHelper *file, PlayerStruct &player) +void LoadPlayer(LoadHelper *file, Player &player) { player._pmode = static_cast(file->NextLE()); @@ -969,7 +969,7 @@ void SaveItems(SaveHelper *file, ItemStruct *pItem, const int n) } } -void SavePlayer(SaveHelper *file, PlayerStruct &player) +void SavePlayer(SaveHelper *file, Player &player) { file->WriteLE(player._pmode); for (int8_t step : player.walkpath) @@ -1619,7 +1619,7 @@ void SaveHotkeys() file.WriteLE(myPlayer._pRSplType); } -void LoadHeroItems(PlayerStruct &player) +void LoadHeroItems(Player &player) { LoadHelper file("heroitems"); if (!file.IsValid()) @@ -1634,7 +1634,7 @@ void LoadHeroItems(PlayerStruct &player) gbIsHellfireSaveGame = gbIsHellfire; } -void RemoveEmptyInventory(PlayerStruct &player) +void RemoveEmptyInventory(Player &player) { for (int i = NUM_INV_GRID_ELEM; i > 0; i--) { int8_t idx = player.InvGrid[i - 1]; @@ -1853,7 +1853,7 @@ void LoadGame(bool firstflag) gbIsHellfireSaveGame = gbIsHellfire; } -void SaveHeroItems(PlayerStruct &player) +void SaveHeroItems(Player &player) { size_t itemCount = NUM_INVLOC + NUM_INV_GRID_ELEM + MAXBELTITEMS; SaveHelper file("heroitems", itemCount * (gbIsHellfire ? HellfireItemSaveSize : DiabloItemSaveSize) + sizeof(uint8_t)); diff --git a/Source/loadsave.h b/Source/loadsave.h index 59b0bac4f..343d2ffb8 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -19,15 +19,15 @@ _item_indexes RemapItemIdxFromSpawn(_item_indexes i); _item_indexes RemapItemIdxToSpawn(_item_indexes i); bool IsHeaderValid(uint32_t magicNumber); void LoadHotkeys(); -void LoadHeroItems(PlayerStruct &player); +void LoadHeroItems(Player &player); /** * @brief Remove invalid inventory items from the inventory grid * @param pnum The id of the player */ -void RemoveEmptyInventory(PlayerStruct &player); +void RemoveEmptyInventory(Player &player); void LoadGame(bool firstflag); void SaveHotkeys(); -void SaveHeroItems(PlayerStruct &player); +void SaveHeroItems(Player &player); void SaveGameData(); void SaveGame(); void SaveLevel(); diff --git a/Source/msg.cpp b/Source/msg.cpp index 450b705d9..84673f4fb 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -609,7 +609,7 @@ DWORD OnSyncData(TCmd *pCmd, int pnum) return sync_update(pnum, (const byte *)pCmd); } -DWORD OnWalk(TCmd *pCmd, PlayerStruct &player) +DWORD OnWalk(TCmd *pCmd, Player &player) { auto *p = (TCmdLoc *)pCmd; @@ -670,7 +670,7 @@ DWORD OnAddVitality(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnGotoGetItem(TCmd *pCmd, PlayerStruct &player) +DWORD OnGotoGetItem(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam1 *)pCmd; @@ -683,7 +683,7 @@ DWORD OnGotoGetItem(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnRequestGetItem(TCmd *pCmd, PlayerStruct &player) +DWORD OnRequestGetItem(TCmd *pCmd, Player &player) { auto *p = (TCmdGItem *)pCmd; @@ -737,7 +737,7 @@ DWORD OnGetItem(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnGotoAutoGetItem(TCmd *pCmd, PlayerStruct &player) +DWORD OnGotoAutoGetItem(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam1 *)pCmd; @@ -750,7 +750,7 @@ DWORD OnGotoAutoGetItem(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnRequestAutoGetItem(TCmd *pCmd, PlayerStruct &player) +DWORD OnRequestAutoGetItem(TCmd *pCmd, Player &player) { auto *p = (TCmdGItem *)pCmd; @@ -888,7 +888,7 @@ DWORD OnRespawnItem(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnAttackTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnAttackTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLoc *)pCmd; @@ -902,7 +902,7 @@ DWORD OnAttackTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnStandingAttackTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnStandingAttackTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLoc *)pCmd; @@ -916,7 +916,7 @@ DWORD OnStandingAttackTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnRangedAttackTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnRangedAttackTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLoc *)pCmd; @@ -930,7 +930,7 @@ DWORD OnRangedAttackTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnSpellWall(TCmd *pCmd, PlayerStruct &player) +DWORD OnSpellWall(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam3 *)pCmd; @@ -954,7 +954,7 @@ DWORD OnSpellWall(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnSpellTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnSpellTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam2 *)pCmd; @@ -977,7 +977,7 @@ DWORD OnSpellTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnTargetSpellTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnTargetSpellTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam2 *)pCmd; @@ -1000,7 +1000,7 @@ DWORD OnTargetSpellTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnOperateObjectTile(TCmd *pCmd, PlayerStruct &player) +DWORD OnOperateObjectTile(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam1 *)pCmd; @@ -1013,7 +1013,7 @@ DWORD OnOperateObjectTile(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnDisarm(TCmd *pCmd, PlayerStruct &player) +DWORD OnDisarm(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam1 *)pCmd; @@ -1026,7 +1026,7 @@ DWORD OnDisarm(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnOperateObjectTelekinesis(TCmd *pCmd, PlayerStruct &player) +DWORD OnOperateObjectTelekinesis(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; @@ -1038,7 +1038,7 @@ DWORD OnOperateObjectTelekinesis(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnAttackMonster(TCmd *pCmd, PlayerStruct &player) +DWORD OnAttackMonster(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; @@ -1053,7 +1053,7 @@ DWORD OnAttackMonster(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnAttackPlayer(TCmd *pCmd, PlayerStruct &player) +DWORD OnAttackPlayer(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; @@ -1066,7 +1066,7 @@ DWORD OnAttackPlayer(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnRangedAttackMonster(TCmd *pCmd, PlayerStruct &player) +DWORD OnRangedAttackMonster(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; @@ -1079,7 +1079,7 @@ DWORD OnRangedAttackMonster(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnRangedAttackPlayer(TCmd *pCmd, PlayerStruct &player) +DWORD OnRangedAttackPlayer(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; @@ -1092,7 +1092,7 @@ DWORD OnRangedAttackPlayer(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnSpellMonster(TCmd *pCmd, PlayerStruct &player) +DWORD OnSpellMonster(TCmd *pCmd, Player &player) { auto *p = (TCmdParam3 *)pCmd; @@ -1114,7 +1114,7 @@ DWORD OnSpellMonster(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnSpellPlayer(TCmd *pCmd, PlayerStruct &player) +DWORD OnSpellPlayer(TCmd *pCmd, Player &player) { auto *p = (TCmdParam3 *)pCmd; @@ -1136,7 +1136,7 @@ DWORD OnSpellPlayer(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnTargetSpellMonster(TCmd *pCmd, PlayerStruct &player) +DWORD OnTargetSpellMonster(TCmd *pCmd, Player &player) { auto *p = (TCmdParam3 *)pCmd; @@ -1158,7 +1158,7 @@ DWORD OnTargetSpellMonster(TCmd *pCmd, PlayerStruct &player) return sizeof(*p); } -DWORD OnTargetSpellPlayer(TCmd *pCmd, PlayerStruct &player) +DWORD OnTargetSpellPlayer(TCmd *pCmd, Player &player) { auto *p = (TCmdParam3 *)pCmd; @@ -1216,7 +1216,7 @@ DWORD OnHealOther(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnTalkXY(TCmd *pCmd, PlayerStruct &player) +DWORD OnTalkXY(TCmd *pCmd, Player &player) { auto *p = (TCmdLocParam1 *)pCmd; @@ -1348,7 +1348,7 @@ DWORD OnPlayerDeath(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnPlayerDamage(TCmd *pCmd, PlayerStruct &player) +DWORD OnPlayerDamage(TCmd *pCmd, Player &player) { auto *p = (TCmdDamage *)pCmd; @@ -1739,7 +1739,7 @@ DWORD OnNova(TCmd *pCmd, int pnum) return sizeof(*p); } -DWORD OnSetShield(TCmd *pCmd, PlayerStruct &player) +DWORD OnSetShield(TCmd *pCmd, Player &player) { if (gbBufferMsgs != 1) player.pManaShield = true; @@ -1747,7 +1747,7 @@ DWORD OnSetShield(TCmd *pCmd, PlayerStruct &player) return sizeof(*pCmd); } -DWORD OnRemoveShield(TCmd *pCmd, PlayerStruct &player) +DWORD OnRemoveShield(TCmd *pCmd, Player &player) { if (gbBufferMsgs != 1) player.pManaShield = false; @@ -1755,7 +1755,7 @@ DWORD OnRemoveShield(TCmd *pCmd, PlayerStruct &player) return sizeof(*pCmd); } -DWORD OnSetReflect(TCmd *pCmd, PlayerStruct &player) +DWORD OnSetReflect(TCmd *pCmd, Player &player) { auto *p = (TCmdParam1 *)pCmd; if (gbBufferMsgs != 1) diff --git a/Source/pack.cpp b/Source/pack.cpp index 8b4f083b1..334a0d462 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -15,7 +15,7 @@ namespace devilution { namespace { -void VerifyGoldSeeds(PlayerStruct &player) +void VerifyGoldSeeds(Player &player) { for (int i = 0; i < player._pNumInv; i++) { if (player.InvList[i].IDidx != IDI_GOLD) @@ -74,7 +74,7 @@ void PackItem(PkItemStruct *id, const ItemStruct *is) } } -void PackPlayer(PkPlayerStruct *pPack, const PlayerStruct &player, bool manashield) +void PackPlayer(PkPlayerStruct *pPack, const Player &player, bool manashield) { memset(pPack, 0, sizeof(*pPack)); pPack->destAction = player.destAction; @@ -197,7 +197,7 @@ void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire) *id = item; } -void UnPackPlayer(const PkPlayerStruct *pPack, PlayerStruct &player, bool netSync) +void UnPackPlayer(const PkPlayerStruct *pPack, Player &player, bool netSync) { player.position.tile = { pPack->px, pPack->py }; player.position.future = { pPack->px, pPack->py }; diff --git a/Source/pack.h b/Source/pack.h index f0a3f8497..5081b4cbc 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -79,8 +79,8 @@ struct PkPlayerStruct { }; #pragma pack(pop) -void PackPlayer(PkPlayerStruct *pPack, const PlayerStruct &player, bool manashield); -void UnPackPlayer(const PkPlayerStruct *pPack, PlayerStruct &player, bool netSync); +void PackPlayer(PkPlayerStruct *pPack, const Player &player, bool manashield); +void UnPackPlayer(const PkPlayerStruct *pPack, Player &player, bool netSync); void PackItem(PkItemStruct *id, const ItemStruct *is); void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire); diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 1bca81e61..eae20d6b4 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -189,7 +189,7 @@ void CloseArchive(HANDLE *hsArchive) *hsArchive = nullptr; } -void Game2UiPlayer(const PlayerStruct &player, _uiheroinfo *heroinfo, bool bHasSaveFile) +void Game2UiPlayer(const Player &player, _uiheroinfo *heroinfo, bool bHasSaveFile) { strncpy(heroinfo->name, player._pName, sizeof(heroinfo->name) - 1); heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; @@ -375,7 +375,7 @@ bool pfile_delete_save(_uiheroinfo *heroInfo) return true; } -void pfile_read_player_from_save(uint32_t saveNum, PlayerStruct &player) +void pfile_read_player_from_save(uint32_t saveNum, Player &player) { HANDLE archive; PkPlayerStruct pkplr; diff --git a/Source/pfile.h b/Source/pfile.h index 2056486e4..b8ffc903f 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -34,7 +34,7 @@ void pfile_ui_set_class_stats(unsigned int playerClass, _uidefaultstats *classSt uint32_t pfile_ui_get_first_unused_save_num(); bool pfile_ui_save_create(_uiheroinfo *heroinfo); bool pfile_delete_save(_uiheroinfo *heroInfo); -void pfile_read_player_from_save(uint32_t saveNum, PlayerStruct &player); +void pfile_read_player_from_save(uint32_t saveNum, Player &player); bool LevelFileExists(); void GetTempLevelNames(char *szTemp); void GetPermLevelNames(char *szPerm); diff --git a/Source/player.cpp b/Source/player.cpp index 3f1998c2c..bbb0762e2 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -33,7 +33,7 @@ namespace devilution { int MyPlayerId; -PlayerStruct Players[MAX_PLRS]; +Player Players[MAX_PLRS]; bool MyPlayerIsDead; int deathdelay; @@ -219,7 +219,7 @@ const char *const ClassPathTbl[] = { "Warrior", }; -void PmChangeLightOff(PlayerStruct &player) +void PmChangeLightOff(Player &player) { if (player._plid == NO_LIGHT) return; @@ -304,7 +304,7 @@ constexpr std::array WalkSettings { { // clang-format on } }; -void ScrollViewPort(const PlayerStruct &player, _scroll_direction dir) +void ScrollViewPort(const Player &player, _scroll_direction dir) { ScrollInfo.tile.x = player.position.tile.x - ViewX; ScrollInfo.tile.y = player.position.tile.y - ViewY; @@ -322,7 +322,7 @@ void ScrollViewPort(const PlayerStruct &player, _scroll_direction dir) } } -bool PlrDirOK(const PlayerStruct &player, Direction dir) +bool PlrDirOK(const Player &player, Direction dir) { Point position = player.position.tile; Point futurePosition = position + dir; @@ -368,7 +368,7 @@ void HandleWalkMode(int pnum, Displacement vel, Direction dir) player._pdir = dir; } -void StartWalkAnimation(PlayerStruct &player, Direction dir, bool pmWillBeCalled) +void StartWalkAnimation(Player &player, Direction dir, bool pmWillBeCalled) { int skippedFrames = -2; if (currlevel == 0 && sgGameInitInfo.bRunInTown != 0) @@ -405,7 +405,7 @@ void SetPlayerGPtrs(const char *path, std::unique_ptr &data, std::array< } } -void ClearStateVariables(PlayerStruct &player) +void ClearStateVariables(Player &player) { player.position.temp = { 0, 0 }; player.tempDirection = DIR_S; @@ -584,7 +584,7 @@ void RespawnDeadItem(ItemStruct *itm, Point target) itm->_itype = ITYPE_NONE; } -void DeadItem(PlayerStruct &player, ItemStruct *itm, Displacement direction) +void DeadItem(Player &player, ItemStruct *itm, Displacement direction) { if (itm->isEmpty()) return; @@ -768,7 +768,7 @@ bool DoWalk(int pnum, int variant) return false; } -bool WeaponDecay(PlayerStruct &player, int ii) +bool WeaponDecay(Player &player, int ii) { if (!player.InvBody[ii].isEmpty() && player.InvBody[ii]._iClass == ICLASS_WEAPON && (player.InvBody[ii]._iDamAcFlags & ISPLHF_DECAY) != 0) { player.InvBody[ii]._iPLDam -= 5; @@ -1538,7 +1538,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) int y = 0; MonsterStruct *monster; - PlayerStruct *target; + Player *target; ObjectStruct *object; ItemStruct *item; @@ -1944,7 +1944,7 @@ void ValidatePlayer() myPlayer._pMemSpells &= msk; } -void CheckCheatStats(PlayerStruct &player) +void CheckCheatStats(Player &player) { if (player._pStrength > 750) { player._pStrength = 750; @@ -1973,7 +1973,7 @@ void CheckCheatStats(PlayerStruct &player) } // namespace -void PlayerStruct::CalcScrolls() +void Player::CalcScrolls() { _pScrlSpells = 0; for (int i = 0; i < _pNumInv; i++) { @@ -1992,7 +1992,7 @@ void PlayerStruct::CalcScrolls() EnsureValidReadiedSpell(*this); } -bool PlayerStruct::HasItem(int item, int *idx) const +bool Player::HasItem(int item, int *idx) const { for (int i = 0; i < _pNumInv; i++) { if (InvList[i].IDidx == item) { @@ -2005,7 +2005,7 @@ bool PlayerStruct::HasItem(int item, int *idx) const return false; } -void PlayerStruct::RemoveInvItem(int iv, bool calcScrolls) +void Player::RemoveInvItem(int iv, bool calcScrolls) { iv++; @@ -2037,7 +2037,7 @@ void PlayerStruct::RemoveInvItem(int iv, bool calcScrolls) CalcScrolls(); } -bool PlayerStruct::TryRemoveInvItemById(int item) +bool Player::TryRemoveInvItemById(int item) { int idx; if (HasItem(item, &idx)) { @@ -2047,7 +2047,7 @@ bool PlayerStruct::TryRemoveInvItemById(int item) return false; } -void PlayerStruct::RemoveSpdBarItem(int iv) +void Player::RemoveSpdBarItem(int iv) { SpdList[iv]._itype = ITYPE_NONE; @@ -2055,7 +2055,7 @@ void PlayerStruct::RemoveSpdBarItem(int iv) force_redraw = 255; } -int PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const +int Player::GetBaseAttributeValue(CharacterAttribute attribute) const { switch (attribute) { case CharacterAttribute::Dexterity: @@ -2071,7 +2071,7 @@ int PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const } } -int PlayerStruct::GetMaximumAttributeValue(CharacterAttribute attribute) const +int Player::GetMaximumAttributeValue(CharacterAttribute attribute) const { static const int MaxStats[enum_size::value][enum_size::value] = { // clang-format off @@ -2087,7 +2087,7 @@ int PlayerStruct::GetMaximumAttributeValue(CharacterAttribute attribute) const return MaxStats[static_cast(_pClass)][static_cast(attribute)]; } -Point PlayerStruct::GetTargetPosition() const +Point Player::GetTargetPosition() const { // clang-format off constexpr int DirectionOffsetX[8] = { 0,-1, 1, 0,-1, 1, 1,-1 }; @@ -2105,14 +2105,14 @@ Point PlayerStruct::GetTargetPosition() const return target; } -void PlayerStruct::Say(HeroSpeech speechId) const +void Player::Say(HeroSpeech speechId) const { _sfx_id soundEffect = herosounds[static_cast(_pClass)][static_cast(speechId)]; PlaySfxLoc(soundEffect, position.tile); } -void PlayerStruct::SaySpecific(HeroSpeech speechId) const +void Player::SaySpecific(HeroSpeech speechId) const { _sfx_id soundEffect = herosounds[static_cast(_pClass)][static_cast(speechId)]; @@ -2122,31 +2122,31 @@ void PlayerStruct::SaySpecific(HeroSpeech speechId) const PlaySfxLoc(soundEffect, position.tile, false); } -void PlayerStruct::Say(HeroSpeech speechId, int delay) const +void Player::Say(HeroSpeech speechId, int delay) const { sfxdelay = delay; sfxdnum = herosounds[static_cast(_pClass)][static_cast(speechId)]; } -void PlayerStruct::Stop() +void Player::Stop() { ClrPlrPath(*this); destAction = ACTION_NONE; } -bool PlayerStruct::IsWalking() const +bool Player::IsWalking() const { return IsAnyOf(_pmode, PM_WALK, PM_WALK2, PM_WALK3); } -void PlayerStruct::Reset() +void Player::Reset() { - // Create empty default initialized PlayerStruct on heap to avoid excessive stack usage - auto emptyPlayer = std::make_unique(); + // Create empty default initialized Player on heap to avoid excessive stack usage + auto emptyPlayer = std::make_unique(); *this = std::move(*emptyPlayer); } -void LoadPlrGFX(PlayerStruct &player, player_graphic graphic) +void LoadPlrGFX(Player &player, player_graphic graphic) { char prefix[16]; char pszName[256]; @@ -2247,7 +2247,7 @@ void LoadPlrGFX(PlayerStruct &player, player_graphic graphic) SetPlayerGPtrs(pszName, animationData.RawData, animationData.CelSpritesForDirections, animationWidth); } -void InitPlayerGFX(PlayerStruct &player) +void InitPlayerGFX(Player &player) { if (player._pHitPoints >> 6 == 0) { player._pgfxnum = 0; @@ -2263,7 +2263,7 @@ void InitPlayerGFX(PlayerStruct &player) } } -void ResetPlayerGFX(PlayerStruct &player) +void ResetPlayerGFX(Player &player) { player.AnimInfo.pCelSprite = nullptr; for (auto &animData : player.AnimationData) { @@ -2273,7 +2273,7 @@ void ResetPlayerGFX(PlayerStruct &player) } } -void NewPlrAnim(PlayerStruct &player, player_graphic graphic, Direction dir, int numberOfFrames, int delayLen, AnimationDistributionFlags flags /*= AnimationDistributionFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/) +void NewPlrAnim(Player &player, player_graphic graphic, Direction dir, int numberOfFrames, int delayLen, AnimationDistributionFlags flags /*= AnimationDistributionFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/) { if (player.AnimationData[static_cast(graphic)].RawData == nullptr) LoadPlrGFX(player, graphic); @@ -2287,7 +2287,7 @@ void NewPlrAnim(PlayerStruct &player, player_graphic graphic, Direction dir, int player.AnimInfo.SetNewAnimation(pCelSprite, numberOfFrames, delayLen, flags, numSkippedFrames, distributeFramesBeforeFrame); } -void SetPlrAnims(PlayerStruct &player) +void SetPlrAnims(Player &player) { HeroClass pc = player._pClass; @@ -2549,7 +2549,7 @@ void CreatePlayer(int playerId, HeroClass c) SetRndSeed(0); } -int CalcStatDiff(PlayerStruct &player) +int CalcStatDiff(Player &player) { int diff = 0; for (auto attribute : enum_values()) { @@ -2690,7 +2690,7 @@ void AddPlrMonstExper(int lvl, int exp, char pmask) } } -void InitPlayer(PlayerStruct &player, bool firstTime) +void InitPlayer(Player &player, bool firstTime) { auto &myPlayer = Players[MyPlayerId]; @@ -2820,7 +2820,7 @@ void PlrDoTrans(Point position) } } -void SetPlayerOld(PlayerStruct &player) +void SetPlayerOld(Player &player) { player.position.old = player.position.tile; } @@ -3090,7 +3090,7 @@ StartPlayerKill(int pnum, int earflag) SetPlayerHitPoints(player, 0); } -void StripTopGold(PlayerStruct &player) +void StripTopGold(Player &player) { ItemStruct tmpItem = player.HoldItem; @@ -3381,7 +3381,7 @@ void ProcessPlayers() } } -void ClrPlrPath(PlayerStruct &player) +void ClrPlrPath(Player &player) { memset(player.walkpath, WALK_NONE, sizeof(player.walkpath)); } @@ -3389,12 +3389,12 @@ void ClrPlrPath(PlayerStruct &player) /** * @brief Determines if the target position is clear for the given player to stand on. * - * This requires an ID instead of a PlayerStruct& to compare with the dPlayer lookup table values. + * This requires an ID instead of a Player& to compare with the dPlayer lookup table values. * * @param position Dungeon tile coordinates. * @return False if something (other than the player themselves) is blocking the tile. */ -bool PosOkPlayer(const PlayerStruct &player, Point position) +bool PosOkPlayer(const Player &player, Point position) { if (position.x < 0 || position.x >= MAXDUNX || position.y < 0 || position.y >= MAXDUNY) return false; @@ -3424,7 +3424,7 @@ bool PosOkPlayer(const PlayerStruct &player, Point position) return true; } -void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace) +void MakePlrPath(Player &player, Point targetPosition, bool endspace) { if (player.position.future == targetPosition) { return; @@ -3442,7 +3442,7 @@ void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace) player.walkpath[path] = WALK_NONE; } -void CalcPlrStaff(PlayerStruct &player) +void CalcPlrStaff(Player &player) { player._pISpells = 0; if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() @@ -3654,7 +3654,7 @@ void SyncInitPlr(int pnum) SyncInitPlrPos(pnum); } -void CheckStats(PlayerStruct &player) +void CheckStats(Player &player) { for (auto attribute : enum_values()) { int maxStatPoint = player.GetMaximumAttributeValue(attribute); @@ -3786,7 +3786,7 @@ void ModifyPlrVit(int p, int l) } } -void SetPlayerHitPoints(PlayerStruct &player, int val) +void SetPlayerHitPoints(Player &player, int val) { player._pHitPoints = val; player._pHPBase = val + player._pMaxHPBase - player._pMaxHP; @@ -3796,13 +3796,13 @@ void SetPlayerHitPoints(PlayerStruct &player, int val) } } -void SetPlrStr(PlayerStruct &player, int v) +void SetPlrStr(Player &player, int v) { player._pBaseStr = v; CalcPlrInv(player, true); } -void SetPlrMag(PlayerStruct &player, int v) +void SetPlrMag(Player &player, int v) { player._pBaseMag = v; @@ -3818,13 +3818,13 @@ void SetPlrMag(PlayerStruct &player, int v) CalcPlrInv(player, true); } -void SetPlrDex(PlayerStruct &player, int v) +void SetPlrDex(Player &player, int v) { player._pBaseDex = v; CalcPlrInv(player, true); } -void SetPlrVit(PlayerStruct &player, int v) +void SetPlrVit(Player &player, int v) { player._pBaseVit = v; @@ -3838,7 +3838,7 @@ void SetPlrVit(PlayerStruct &player, int v) CalcPlrInv(player, true); } -void InitDungMsgs(PlayerStruct &player) +void InitDungMsgs(Player &player) { player.pDungMsgs = 0; player.pDungMsgs2 = 0; diff --git a/Source/player.h b/Source/player.h index 9d135e292..022373b40 100644 --- a/Source/player.h +++ b/Source/player.h @@ -161,10 +161,10 @@ struct PlayerAnimationData { std::unique_ptr RawData; }; -struct PlayerStruct { - PlayerStruct() = default; - PlayerStruct(PlayerStruct &&) noexcept = default; - PlayerStruct &operator=(PlayerStruct &&) noexcept = default; +struct Player { + Player() = default; + Player(Player &&) noexcept = default; + Player &operator=(Player &&) noexcept = default; PLR_MODE _pmode; int8_t walkpath[MAX_PATH_LENGTH]; @@ -392,7 +392,7 @@ struct PlayerStruct { bool IsWalking() const; /** - * @brief Resets all Data of the current PlayerStruct + * @brief Resets all Data of the current Player */ void Reset(); @@ -569,13 +569,13 @@ struct PlayerStruct { }; extern int MyPlayerId; -extern PlayerStruct Players[MAX_PLRS]; +extern Player Players[MAX_PLRS]; extern bool MyPlayerIsDead; extern int BlockBonuses[enum_size::value]; -void LoadPlrGFX(PlayerStruct &player, player_graphic graphic); -void InitPlayerGFX(PlayerStruct &player); -void ResetPlayerGFX(PlayerStruct &player); +void LoadPlrGFX(Player &player, player_graphic graphic); +void InitPlayerGFX(Player &player); +void ResetPlayerGFX(Player &player); /** * @brief Sets the new Player Animation with all relevant information for rendering @@ -587,21 +587,21 @@ void ResetPlayerGFX(PlayerStruct &player); * @param numSkippedFrames Number of Frames that will be skipped (for example with modifier "faster attack") * @param distributeFramesBeforeFrame Distribute the numSkippedFrames only before this frame */ -void NewPlrAnim(PlayerStruct &player, player_graphic graphic, Direction dir, int numberOfFrames, int delayLen, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0); -void SetPlrAnims(PlayerStruct &player); +void NewPlrAnim(Player &player, player_graphic graphic, Direction dir, int numberOfFrames, int delayLen, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0); +void SetPlrAnims(Player &player); void CreatePlayer(int playerId, HeroClass c); -int CalcStatDiff(PlayerStruct &player); +int CalcStatDiff(Player &player); #ifdef _DEBUG void NextPlrLevel(int pnum); #endif void AddPlrExperience(int pnum, int lvl, int exp); void AddPlrMonstExper(int lvl, int exp, char pmask); void ApplyPlrDamage(int pnum, int dam, int minHP = 0, int frac = 0, int earflag = 0); -void InitPlayer(PlayerStruct &player, bool FirstTime); +void InitPlayer(Player &player, bool FirstTime); void InitMultiView(); void PlrClrTrans(Point position); void PlrDoTrans(Point position); -void SetPlayerOld(PlayerStruct &player); +void SetPlayerOld(Player &player); void FixPlayerLocation(int pnum, Direction bDir); void StartStand(int pnum, Direction dir); void StartPlrBlock(int pnum, Direction dir); @@ -609,32 +609,32 @@ void FixPlrWalkTags(int pnum); void RemovePlrFromMap(int pnum); void StartPlrHit(int pnum, int dam, bool forcehit); void StartPlayerKill(int pnum, int earflag); -void StripTopGold(PlayerStruct &player); +void StripTopGold(Player &player); void SyncPlrKill(int pnum, int earflag); void RemovePlrMissiles(int pnum); void StartNewLvl(int pnum, interface_mode fom, int lvl); void RestartTownLvl(int pnum); void StartWarpLvl(int pnum, int pidx); void ProcessPlayers(); -void ClrPlrPath(PlayerStruct &player); -bool PosOkPlayer(const PlayerStruct &player, Point position); -void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace); -void CalcPlrStaff(PlayerStruct &player); +void ClrPlrPath(Player &player); +bool PosOkPlayer(const Player &player, Point position); +void MakePlrPath(Player &player, Point targetPosition, bool endspace); +void CalcPlrStaff(Player &player); void CheckPlrSpell(); void SyncPlrAnim(int pnum); void SyncInitPlrPos(int pnum); void SyncInitPlr(int pnum); -void CheckStats(PlayerStruct &player); +void CheckStats(Player &player); void ModifyPlrStr(int p, int l); void ModifyPlrMag(int p, int l); void ModifyPlrDex(int p, int l); void ModifyPlrVit(int p, int l); -void SetPlayerHitPoints(PlayerStruct &player, int val); -void SetPlrStr(PlayerStruct &player, int v); -void SetPlrMag(PlayerStruct &player, int v); -void SetPlrDex(PlayerStruct &player, int v); -void SetPlrVit(PlayerStruct &player, int v); -void InitDungMsgs(PlayerStruct &player); +void SetPlayerHitPoints(Player &player, int val); +void SetPlrStr(Player &player, int v); +void SetPlrMag(Player &player, int v); +void SetPlrDex(Player &player, int v); +void SetPlrVit(Player &player, int v); +void InitDungMsgs(Player &player); void PlayDungMsgs(); /* data */ diff --git a/Source/spells.cpp b/Source/spells.cpp index 0642d5a42..9edb462dc 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -27,7 +27,7 @@ namespace { * @param player The player whose readied spell is to be checked. * @return 'true' when the readied spell is currently valid, and 'false' otherwise. */ -bool IsReadiedSpellValid(const PlayerStruct &player) +bool IsReadiedSpellValid(const Player &player) { switch (player._pRSplType) { case RSPLTYPE_SKILL: @@ -51,7 +51,7 @@ bool IsReadiedSpellValid(const PlayerStruct &player) * @note Will force a UI redraw in case the values actually change, so that the new spell reflects on the bottom panel. * @param player The player whose readied spell is to be cleared. */ -void ClearReadiedSpell(PlayerStruct &player) +void ClearReadiedSpell(Player &player) { if (player._pRSpell != SPL_INVALID) { player._pRSpell = SPL_INVALID; @@ -109,7 +109,7 @@ void PlacePlayer(int pnum) } // namespace -int GetManaAmount(PlayerStruct &player, spell_id sn) +int GetManaAmount(Player &player, spell_id sn) { int ma; // mana amount @@ -192,7 +192,7 @@ void UseMana(int id, spell_id sn) * @note Will force a UI redraw in case the values actually change, so that the new spell reflects on the bottom panel. * @param player The player whose readied spell is to be checked. */ -void EnsureValidReadiedSpell(PlayerStruct &player) +void EnsureValidReadiedSpell(Player &player) { if (!IsReadiedSpellValid(player)) { ClearReadiedSpell(player); diff --git a/Source/spells.h b/Source/spells.h index 43079ddbf..cc9b63f6e 100644 --- a/Source/spells.h +++ b/Source/spells.h @@ -16,10 +16,10 @@ enum class SpellCheckResult : uint8_t { Fail_Busy, }; -int GetManaAmount(PlayerStruct &player, spell_id sn); +int GetManaAmount(Player &player, spell_id sn); void UseMana(int id, spell_id sn); SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly); -void EnsureValidReadiedSpell(PlayerStruct &player); +void EnsureValidReadiedSpell(Player &player); void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl); void DoResurrect(int pnum, uint16_t rid); void DoHealOther(int pnum, uint16_t rid); diff --git a/Source/stores.cpp b/Source/stores.cpp index 5fc8e607e..75f37999d 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -2134,7 +2134,7 @@ void DrunkEnter() } } -int TakeGold(PlayerStruct &player, int cost, bool skipMaxPiles) +int TakeGold(Player &player, int cost, bool skipMaxPiles) { for (int i = 0; i < player._pNumInv; i++) { auto &item = player.InvList[i]; diff --git a/Source/towners.cpp b/Source/towners.cpp index 124d027ec..df3c07565 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -31,7 +31,7 @@ struct TownerInit { Point position; Direction dir; void (*init)(TownerStruct &towner, const TownerInit &initData); - void (*talk)(PlayerStruct &player, TownerStruct &towner); + void (*talk)(Player &player, TownerStruct &towner); }; void NewTownerAnim(TownerStruct &towner, byte *pAnim, uint8_t numFrames, int delay) @@ -290,7 +290,7 @@ void TownerTalk(_speech_id message) InitQTextMsg(message); } -void TalkToBarOwner(PlayerStruct &player, TownerStruct &barOwner) +void TalkToBarOwner(Player &player, TownerStruct &barOwner) { if (!player._pLvlVisited[0]) { InitQTextMsg(TEXT_INTRO); @@ -349,7 +349,7 @@ void TalkToBarOwner(PlayerStruct &player, TownerStruct &barOwner) StartStore(STORE_TAVERN); } -void TalkToDeadguy(PlayerStruct &player, TownerStruct & /*deadguy*/) +void TalkToDeadguy(Player &player, TownerStruct & /*deadguy*/) { auto &quest = Quests[Q_BUTCHER]; if (quest._qactive == QUEST_DONE) @@ -368,7 +368,7 @@ void TalkToDeadguy(PlayerStruct &player, TownerStruct & /*deadguy*/) NetSendCmdQuest(true, quest); } -void TalkToBlackSmith(PlayerStruct &player, TownerStruct &blackSmith) +void TalkToBlackSmith(Player &player, TownerStruct &blackSmith) { if (Quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) { if (player._pLvlVisited[4] && Quests[Q_ROCK]._qactive != QUEST_DONE) { @@ -415,7 +415,7 @@ void TalkToBlackSmith(PlayerStruct &player, TownerStruct &blackSmith) StartStore(STORE_SMITH); } -void TalkToWitch(PlayerStruct &player, TownerStruct & /*witch*/) +void TalkToWitch(Player &player, TownerStruct & /*witch*/) { if (Quests[Q_MUSHROOM]._qactive != QUEST_NOTAVAIL) { if (Quests[Q_MUSHROOM]._qactive == QUEST_INIT && player.TryRemoveInvItemById(IDI_FUNGALTM)) { @@ -461,7 +461,7 @@ void TalkToWitch(PlayerStruct &player, TownerStruct & /*witch*/) StartStore(STORE_WITCH); } -void TalkToBarmaid(PlayerStruct &player, TownerStruct & /*barmaid*/) +void TalkToBarmaid(Player &player, TownerStruct & /*barmaid*/) { if (!player._pLvlVisited[21] && player.HasItem(IDI_MAPOFDOOM)) { Quests[Q_GRAVE]._qactive = QUEST_ACTIVE; @@ -475,13 +475,13 @@ void TalkToBarmaid(PlayerStruct &player, TownerStruct & /*barmaid*/) StartStore(STORE_BARMAID); } -void TalkToDrunk(PlayerStruct & /*player*/, TownerStruct & /*drunk*/) +void TalkToDrunk(Player & /*player*/, TownerStruct & /*drunk*/) { TownerTalk(TEXT_FARNHAM1); StartStore(STORE_DRUNK); } -void TalkToHealer(PlayerStruct &player, TownerStruct &healer) +void TalkToHealer(Player &player, TownerStruct &healer) { if (Quests[Q_PWATER]._qactive != QUEST_NOTAVAIL) { if ((player._pLvlVisited[1] || player._pLvlVisited[5]) && Quests[Q_PWATER]._qactive == QUEST_INIT) { @@ -512,13 +512,13 @@ void TalkToHealer(PlayerStruct &player, TownerStruct &healer) StartStore(STORE_HEALER); } -void TalkToBoy(PlayerStruct & /*player*/, TownerStruct & /*boy*/) +void TalkToBoy(Player & /*player*/, TownerStruct & /*boy*/) { TownerTalk(TEXT_WIRT1); StartStore(STORE_BOY); } -void TalkToStoryteller(PlayerStruct &player, TownerStruct & /*storyteller*/) +void TalkToStoryteller(Player &player, TownerStruct & /*storyteller*/) { auto &betrayerQuest = Quests[Q_BETRAYER]; if (!gbIsMultiplayer) { @@ -553,7 +553,7 @@ void TalkToStoryteller(PlayerStruct &player, TownerStruct & /*storyteller*/) StartStore(STORE_STORY); } -void TalkToCow(PlayerStruct &player, TownerStruct &cow) +void TalkToCow(Player &player, TownerStruct &cow) { if (CowPlaying != SFX_NONE && effect_is_playing(CowPlaying)) return; @@ -583,7 +583,7 @@ void TalkToCow(PlayerStruct &player, TownerStruct &cow) PlaySfxLoc(CowPlaying, cow.position); } -void TalkToFarmer(PlayerStruct &player, TownerStruct &farmer) +void TalkToFarmer(Player &player, TownerStruct &farmer) { auto &quest = Quests[Q_FARMER]; switch (quest._qactive) { @@ -640,7 +640,7 @@ void TalkToFarmer(PlayerStruct &player, TownerStruct &farmer) } } -void TalkToCowFarmer(PlayerStruct &player, TownerStruct &cowFarmer) +void TalkToCowFarmer(Player &player, TownerStruct &cowFarmer) { if (player.TryRemoveInvItemById(IDI_GREYSUIT)) { InitQTextMsg(TEXT_JERSEY7); @@ -727,7 +727,7 @@ void TalkToCowFarmer(PlayerStruct &player, TownerStruct &cowFarmer) } } -void TalkToGirl(PlayerStruct &player, TownerStruct &girl) +void TalkToGirl(Player &player, TownerStruct &girl) { auto &quest = Quests[Q_GIRL]; @@ -879,7 +879,7 @@ void ProcessTowners() } } -void TalkToTowner(PlayerStruct &player, int t) +void TalkToTowner(Player &player, int t) { auto &towner = Towners[t]; diff --git a/Source/towners.h b/Source/towners.h index 013e51422..b490f534e 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -57,7 +57,7 @@ struct TownerStruct { /** Specifies the animation frame sequence. */ const uint8_t *animOrder; // unowned std::size_t animOrderSize; - void (*talk)(PlayerStruct &player, TownerStruct &towner); + void (*talk)(Player &player, TownerStruct &towner); _talker_id _ttype; }; @@ -66,7 +66,7 @@ extern TownerStruct Towners[NUM_TOWNERS]; void InitTowners(); void FreeTownerGFX(); void ProcessTowners(); -void TalkToTowner(PlayerStruct &player, int t); +void TalkToTowner(Player &player, int t); #ifdef _DEBUG bool DebugTalkToTowner(std::string targetName); diff --git a/Source/track.cpp b/Source/track.cpp index 8c259acfd..56f6dfee5 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -16,7 +16,7 @@ namespace devilution { namespace { -void RepeatWalk(PlayerStruct &player) +void RepeatWalk(Player &player) { if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1) return; diff --git a/test/player_test.cpp b/test/player_test.cpp index d85a87881..1e0876eb5 100644 --- a/test/player_test.cpp +++ b/test/player_test.cpp @@ -81,7 +81,7 @@ TEST(Player, PM_DoGotHit) } } -static void AssertPlayer(PlayerStruct &player) +static void AssertPlayer(Player &player) { ASSERT_EQ(Count8(player._pSplLvl, 64), 0); ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 1); diff --git a/test/writehero_test.cpp b/test/writehero_test.cpp index 203f57658..ee6112602 100644 --- a/test/writehero_test.cpp +++ b/test/writehero_test.cpp @@ -214,7 +214,7 @@ static void PackPlayerTest(PkPlayerStruct *pPack) pPack->_pNumInv = 2; } -static void AssertPlayer(PlayerStruct &player) +static void AssertPlayer(Player &player) { ASSERT_EQ(Count8(player._pSplLvl, 64), 23); ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 9);