Browse Source

🚚 Rename 'PlayerStruct' to 'Player'

pull/2753/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
bbf529c65a
  1. 6
      Source/control.cpp
  2. 2
      Source/control.h
  3. 42
      Source/inv.cpp
  4. 28
      Source/inv.h
  5. 16
      Source/inv_iterators.hpp
  6. 24
      Source/items.cpp
  7. 16
      Source/items.h
  8. 10
      Source/loadsave.cpp
  9. 6
      Source/loadsave.h
  10. 54
      Source/msg.cpp
  11. 6
      Source/pack.cpp
  12. 4
      Source/pack.h
  13. 4
      Source/pfile.cpp
  14. 2
      Source/pfile.h
  15. 94
      Source/player.cpp
  16. 52
      Source/player.h
  17. 8
      Source/spells.cpp
  18. 4
      Source/spells.h
  19. 2
      Source/stores.cpp
  20. 30
      Source/towners.cpp
  21. 4
      Source/towners.h
  22. 2
      Source/track.cpp
  23. 2
      test/player_test.cpp
  24. 2
      test/writehero_test.cpp

6
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); int pointsToReachCap = player.GetMaximumAttributeValue(attribute) - player.GetBaseAttributeValue(attribute);
@ -510,7 +510,7 @@ spell_type GetSBookTrans(spell_id ii, bool townok)
return st; return st;
} }
void ControlSetGoldCurs(PlayerStruct &player) void ControlSetGoldCurs(Player &player)
{ {
SetPlrHandGoldCurs(player.HoldItem); SetPlrHandGoldCurs(player.HoldItem);
NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM); 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; int gi = goldIndex - INVITEM_INV_FIRST;
player.InvList[gi]._ivalue -= dropGoldValue; player.InvList[gi]._ivalue -= dropGoldValue;

2
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 * 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(); void control_update_life_mana();

42
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 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 * @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; const int pitch = 10;
for (int y = 0; y < itemSize.height; y++) { 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 * @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. * 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)) if (!CanEquip(item) || (item._iLoc != ILOC_ONEHAND && item._iLoc != ILOC_TWOHAND))
return false; 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 * @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. * 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()) { if (!CanEquip(item) || player._pmode > PM_WALK3 || !player.InvBody[bodyLocation].isEmpty()) {
return false; 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) if (player.HoldItem._iMiscId != IMISC_BOOK)
return; return;
@ -913,7 +913,7 @@ void CheckBookLevel(PlayerStruct &player)
} }
} }
void CheckNaKrulNotes(PlayerStruct &player) void CheckNaKrulNotes(Player &player)
{ {
int idx = player.HoldItem.IDidx; int idx = player.HoldItem.IDidx;
_item_indexes notes[] = { IDI_NOTE1, IDI_NOTE2, IDI_NOTE3 }; _item_indexes notes[] = { IDI_NOTE1, IDI_NOTE2, IDI_NOTE3 };
@ -945,7 +945,7 @@ void CheckNaKrulNotes(PlayerStruct &player)
Items[itemNum] = tmp; Items[itemNum] = tmp;
} }
void CheckQuestItem(PlayerStruct &player) void CheckQuestItem(Player &player)
{ {
auto &myPlayer = Players[MyPlayerId]; 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) if (ActiveItemCount >= MAXITEMS)
return false; 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'. * @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. * @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)) { if (!CanBePlacedOnBelt(item)) {
return false; return false;
@ -1323,7 +1323,7 @@ bool AutoEquip(int playerId, const ItemStruct &item, bool persistItem)
* @param item The item to check. * @param item The item to check.
* @return 'True' if auto-equipping behavior is enabled for the player and item and 'False' otherwise. * @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()) { 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 // 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'. * @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. * @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); 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'. * @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. * @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; int yy = (slotIndex > 0) ? (10 * (slotIndex / 10)) : 0;
@ -1455,7 +1455,7 @@ bool AutoPlaceItemInInventorySlot(PlayerStruct &player, int slotIndex, const Ite
return true; return true;
} }
bool GoldAutoPlace(PlayerStruct &player) bool GoldAutoPlace(Player &player)
{ {
bool done = false; bool done = false;
@ -1493,7 +1493,7 @@ bool GoldAutoPlace(PlayerStruct &player)
return done; return done;
} }
bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex) bool GoldAutoPlaceInInventorySlot(Player &player, int slotIndex)
{ {
if (player.InvGrid[slotIndex] != 0) { if (player.InvGrid[slotIndex] != 0) {
return false; return false;
@ -1521,7 +1521,7 @@ bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex)
return true; 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]; auto &item = Items[MAXITEMS];
memset(&item, 0, sizeof(item)); 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); 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) { if (iv < NUM_INVLOC) {
player.InvBody[iv]._itype = ITYPE_NONE; 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; ItemStruct &item = player.HoldItem;
@ -1774,7 +1774,7 @@ bool TryInvPut()
return CanPut(myPlayer.position.tile); return CanPut(myPlayer.position.tile);
} }
int InvPutItem(PlayerStruct &player, Point position) int InvPutItem(Player &player, Point position)
{ {
if (!PutItem(player, position)) if (!PutItem(player, position))
return -1; return -1;
@ -1824,7 +1824,7 @@ int InvPutItem(PlayerStruct &player, Point position)
return ii; 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)) if (!PutItem(player, position))
return -1; return -1;
@ -1958,7 +1958,7 @@ int8_t CheckInvHLight()
return rv; return rv;
} }
void RemoveScroll(PlayerStruct &player) void RemoveScroll(Player &player)
{ {
for (int i = 0; i < player._pNumInv; i++) { for (int i = 0; i < player._pNumInv; i++) {
if (!player.InvList[i].isEmpty() if (!player.InvList[i].isEmpty()
@ -2008,7 +2008,7 @@ bool UseScroll()
return false; return false;
} }
void UseStaffCharge(PlayerStruct &player) void UseStaffCharge(Player &player)
{ {
auto &staff = player.InvBody[INVLOC_HAND_LEFT]; auto &staff = player.InvBody[INVLOC_HAND_LEFT];
@ -2142,7 +2142,7 @@ void DoTelekinesis()
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
} }
int CalculateGold(PlayerStruct &player) int CalculateGold(Player &player)
{ {
int gold = 0; int gold = 0;

28
Source/inv.h

@ -97,34 +97,34 @@ void InitInv();
void DrawInv(const Surface &out); void DrawInv(const Surface &out);
void DrawInvBelt(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 AutoEquip(int playerId, const ItemStruct &item, bool persistItem = true);
bool AutoPlaceItemInInventory(PlayerStruct &player, const ItemStruct &item, bool persistItem = false); bool AutoPlaceItemInInventory(Player &player, const ItemStruct &item, bool persistItem = false);
bool AutoPlaceItemInInventorySlot(PlayerStruct &player, int slotIndex, const ItemStruct &item, bool persistItem); bool AutoPlaceItemInInventorySlot(Player &player, int slotIndex, const ItemStruct &item, bool persistItem);
bool AutoPlaceItemInBelt(PlayerStruct &player, const ItemStruct &item, bool persistItem = false); bool AutoPlaceItemInBelt(Player &player, const ItemStruct &item, bool persistItem = false);
bool GoldAutoPlace(PlayerStruct &player); bool GoldAutoPlace(Player &player);
bool GoldAutoPlaceInInventorySlot(PlayerStruct &player, int slotIndex); bool GoldAutoPlaceInInventorySlot(Player &player, int slotIndex);
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);
void inv_update_rem_item(PlayerStruct &player, BYTE iv); void inv_update_rem_item(Player &player, BYTE iv);
void CheckInvItem(bool isShiftHeld = false); void CheckInvItem(bool isShiftHeld = false);
void CheckInvScrn(bool isShiftHeld); void CheckInvScrn(bool isShiftHeld);
void CheckItemStats(PlayerStruct &player); void CheckItemStats(Player &player);
void InvGetItem(int pnum, ItemStruct *item, int ii); void InvGetItem(int pnum, ItemStruct *item, int ii);
void AutoGetItem(int pnum, ItemStruct *item, int ii); void AutoGetItem(int pnum, ItemStruct *item, int ii);
int FindGetItem(int idx, uint16_t ci, int iseed); int FindGetItem(int idx, uint16_t ci, int iseed);
void SyncGetItem(Point position, int idx, uint16_t ci, int iseed); void SyncGetItem(Point position, int idx, uint16_t ci, int iseed);
bool CanPut(Point position); bool CanPut(Point position);
bool TryInvPut(); bool TryInvPut();
int InvPutItem(PlayerStruct &player, Point position); int InvPutItem(Player &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 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(); int8_t CheckInvHLight();
void RemoveScroll(PlayerStruct &player); void RemoveScroll(Player &player);
bool UseScroll(); bool UseScroll();
void UseStaffCharge(PlayerStruct &player); void UseStaffCharge(Player &player);
bool UseStaff(); bool UseStaff();
bool UseInvItem(int pnum, int cii); bool UseInvItem(int pnum, int cii);
void DoTelekinesis(); void DoTelekinesis();
int CalculateGold(PlayerStruct &player); int CalculateGold(Player &player);
bool DropItemBeforeTrig(); bool DropItemBeforeTrig();
/* data */ /* data */

16
Source/inv_iterators.hpp

@ -179,7 +179,7 @@ public:
*/ */
class EquippedPlayerItemsRange { class EquippedPlayerItemsRange {
public: public:
explicit EquippedPlayerItemsRange(PlayerStruct &player) explicit EquippedPlayerItemsRange(Player &player)
: player_(&player) : player_(&player)
{ {
} }
@ -200,7 +200,7 @@ private:
return sizeof(player_->InvBody) / sizeof(player_->InvBody[0]); return sizeof(player_->InvBody) / sizeof(player_->InvBody[0]);
} }
PlayerStruct *player_; Player *player_;
}; };
/** /**
@ -208,7 +208,7 @@ private:
*/ */
class InventoryPlayerItemsRange { class InventoryPlayerItemsRange {
public: public:
explicit InventoryPlayerItemsRange(PlayerStruct &player) explicit InventoryPlayerItemsRange(Player &player)
: player_(&player) : player_(&player)
{ {
} }
@ -229,7 +229,7 @@ private:
return static_cast<std::size_t>(player_->_pNumInv); return static_cast<std::size_t>(player_->_pNumInv);
} }
PlayerStruct *player_; Player *player_;
}; };
/** /**
@ -237,7 +237,7 @@ private:
*/ */
class BeltPlayerItemsRange { class BeltPlayerItemsRange {
public: public:
explicit BeltPlayerItemsRange(PlayerStruct &player) explicit BeltPlayerItemsRange(Player &player)
: player_(&player) : player_(&player)
{ {
} }
@ -258,7 +258,7 @@ private:
return sizeof(player_->SpdList) / sizeof(player_->SpdList[0]); return sizeof(player_->SpdList) / sizeof(player_->SpdList[0]);
} }
PlayerStruct *player_; Player *player_;
}; };
/** /**
@ -266,7 +266,7 @@ private:
*/ */
class PlayerItemsRange { class PlayerItemsRange {
public: public:
explicit PlayerItemsRange(PlayerStruct &player) explicit PlayerItemsRange(Player &player)
: player_(&player) : player_(&player)
{ {
} }
@ -291,7 +291,7 @@ public:
} }
private: private:
PlayerStruct *player_; Player *player_;
}; };
} // namespace devilution } // namespace devilution

24
Source/items.cpp

@ -459,7 +459,7 @@ void SpawnNote()
SpawnQuestItem(id, position, 0, 1); SpawnQuestItem(id, position, 0, 1);
} }
void CalcSelfItems(PlayerStruct &player) void CalcSelfItems(Player &player)
{ {
int sa = 0; int sa = 0;
int ma = 0; int ma = 0;
@ -503,7 +503,7 @@ void CalcSelfItems(PlayerStruct &player)
} while (changeflag); } while (changeflag);
} }
bool ItemMinStats(const PlayerStruct &player, ItemStruct &x) bool ItemMinStats(const Player &player, ItemStruct &x)
{ {
if (player._pMagic < x._iMinMag) if (player._pMagic < x._iMinMag)
return false; return false;
@ -517,7 +517,7 @@ bool ItemMinStats(const PlayerStruct &player, ItemStruct &x)
return true; return true;
} }
void CalcPlrItemMin(PlayerStruct &player) void CalcPlrItemMin(Player &player)
{ {
for (int i = 0; i < player._pNumInv; i++) { for (int i = 0; i < player._pNumInv; i++) {
auto &item = player.InvList[i]; auto &item = player.InvList[i];
@ -561,7 +561,7 @@ bool StoreStatOk(ItemStruct &item)
return true; return true;
} }
void CalcPlrBookVals(PlayerStruct &player) void CalcPlrBookVals(Player &player)
{ {
if (currlevel == 0) { if (currlevel == 0) {
for (int i = 1; !witchitem[i].isEmpty(); i++) { 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); item._iCharges = std::min(item._iCharges, item._iMaxCharges);
} }
bool ApplyOilToItem(ItemStruct &item, PlayerStruct &player) bool ApplyOilToItem(ItemStruct &item, Player &player)
{ {
int r; int r;
@ -2625,7 +2625,7 @@ void InitItems()
initItemGetRecords(); initItemGetRecords();
} }
void CalcPlrItemVals(PlayerStruct &player, bool loadgfx) void CalcPlrItemVals(Player &player, bool loadgfx)
{ {
int mind = 0; // min damage int mind = 0; // min damage
int maxd = 0; // max damage int maxd = 0; // max damage
@ -2986,7 +2986,7 @@ void CalcPlrItemVals(PlayerStruct &player, bool loadgfx)
drawhpflag = true; drawhpflag = true;
} }
void CalcPlrInv(PlayerStruct &player, bool loadgfx) void CalcPlrInv(Player &player, bool loadgfx)
{ {
CalcPlrItemMin(player); CalcPlrItemMin(player);
CalcSelfItems(player); CalcSelfItems(player);
@ -3045,7 +3045,7 @@ void GetPlrHandSeed(ItemStruct *h)
h->_iSeed = AdvanceRndSeed(); h->_iSeed = AdvanceRndSeed();
} }
void SetGoldSeed(PlayerStruct &player, ItemStruct &gold) void SetGoldSeed(Player &player, ItemStruct &gold)
{ {
int s = 0; 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; ItemStruct *pi;
@ -3778,7 +3778,7 @@ void CheckIdentify(PlayerStruct &player, int cii)
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
} }
void DoRepair(PlayerStruct &player, int cii) void DoRepair(Player &player, int cii)
{ {
ItemStruct *pi; ItemStruct *pi;
@ -3797,7 +3797,7 @@ void DoRepair(PlayerStruct &player, int cii)
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
} }
void DoRecharge(PlayerStruct &player, int cii) void DoRecharge(Player &player, int cii)
{ {
ItemStruct *pi; ItemStruct *pi;
@ -3817,7 +3817,7 @@ void DoRecharge(PlayerStruct &player, int cii)
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
} }
void DoOil(PlayerStruct &player, int cii) void DoOil(Player &player, int cii)
{ {
ItemStruct *pi; ItemStruct *pi;
if (cii >= NUM_INVLOC) { if (cii >= NUM_INVLOC) {

16
Source/items.h

@ -396,7 +396,7 @@ struct CornerStoneStruct {
ItemStruct item; ItemStruct item;
}; };
struct PlayerStruct; struct Player;
extern ItemStruct Items[MAXITEMS + 1]; extern ItemStruct Items[MAXITEMS + 1];
extern int ActiveItems[MAXITEMS]; extern int ActiveItems[MAXITEMS];
@ -411,14 +411,14 @@ bool IsItemAvailable(int i);
bool IsUniqueAvailable(int i); bool IsUniqueAvailable(int i);
void InitItemGFX(); void InitItemGFX();
void InitItems(); void InitItems();
void CalcPlrItemVals(PlayerStruct &player, bool Loadgfx); void CalcPlrItemVals(Player &player, bool Loadgfx);
void CalcPlrInv(PlayerStruct &player, bool Loadgfx); void CalcPlrInv(Player &player, bool Loadgfx);
void SetPlrHandItem(ItemStruct &item, int itemData); void SetPlrHandItem(ItemStruct &item, int itemData);
void GetPlrHandSeed(ItemStruct *h); void GetPlrHandSeed(ItemStruct *h);
/** /**
* @brief Set a new unique seed value on the given item * @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); int GetGoldCursor(int value);
void SetPlrHandGoldCurs(ItemStruct &gold); void SetPlrHandGoldCurs(ItemStruct &gold);
void CreatePlrItems(int playerId); void CreatePlrItems(int playerId);
@ -448,10 +448,10 @@ void ProcessItems();
void FreeItemGFX(); void FreeItemGFX();
void GetItemFrm(ItemStruct &item); void GetItemFrm(ItemStruct &item);
void GetItemStr(ItemStruct &item); void GetItemStr(ItemStruct &item);
void CheckIdentify(PlayerStruct &player, int cii); void CheckIdentify(Player &player, int cii);
void DoRepair(PlayerStruct &player, int cii); void DoRepair(Player &player, int cii);
void DoRecharge(PlayerStruct &player, int cii); void DoRecharge(Player &player, int cii);
void DoOil(PlayerStruct &player, int cii); void DoOil(Player &player, int cii);
void PrintItemPower(char plidx, ItemStruct *x); void PrintItemPower(char plidx, ItemStruct *x);
void DrawUniqueInfo(const Surface &out); void DrawUniqueInfo(const Surface &out);
void PrintItemDetails(ItemStruct *x); void PrintItemDetails(ItemStruct *x);

10
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<PLR_MODE>(file->NextLE<int32_t>()); player._pmode = static_cast<PLR_MODE>(file->NextLE<int32_t>());
@ -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<int32_t>(player._pmode); file->WriteLE<int32_t>(player._pmode);
for (int8_t step : player.walkpath) for (int8_t step : player.walkpath)
@ -1619,7 +1619,7 @@ void SaveHotkeys()
file.WriteLE<uint8_t>(myPlayer._pRSplType); file.WriteLE<uint8_t>(myPlayer._pRSplType);
} }
void LoadHeroItems(PlayerStruct &player) void LoadHeroItems(Player &player)
{ {
LoadHelper file("heroitems"); LoadHelper file("heroitems");
if (!file.IsValid()) if (!file.IsValid())
@ -1634,7 +1634,7 @@ void LoadHeroItems(PlayerStruct &player)
gbIsHellfireSaveGame = gbIsHellfire; gbIsHellfireSaveGame = gbIsHellfire;
} }
void RemoveEmptyInventory(PlayerStruct &player) void RemoveEmptyInventory(Player &player)
{ {
for (int i = NUM_INV_GRID_ELEM; i > 0; i--) { for (int i = NUM_INV_GRID_ELEM; i > 0; i--) {
int8_t idx = player.InvGrid[i - 1]; int8_t idx = player.InvGrid[i - 1];
@ -1853,7 +1853,7 @@ void LoadGame(bool firstflag)
gbIsHellfireSaveGame = gbIsHellfire; gbIsHellfireSaveGame = gbIsHellfire;
} }
void SaveHeroItems(PlayerStruct &player) void SaveHeroItems(Player &player)
{ {
size_t itemCount = NUM_INVLOC + NUM_INV_GRID_ELEM + MAXBELTITEMS; size_t itemCount = NUM_INVLOC + NUM_INV_GRID_ELEM + MAXBELTITEMS;
SaveHelper file("heroitems", itemCount * (gbIsHellfire ? HellfireItemSaveSize : DiabloItemSaveSize) + sizeof(uint8_t)); SaveHelper file("heroitems", itemCount * (gbIsHellfire ? HellfireItemSaveSize : DiabloItemSaveSize) + sizeof(uint8_t));

6
Source/loadsave.h

@ -19,15 +19,15 @@ _item_indexes RemapItemIdxFromSpawn(_item_indexes i);
_item_indexes RemapItemIdxToSpawn(_item_indexes i); _item_indexes RemapItemIdxToSpawn(_item_indexes i);
bool IsHeaderValid(uint32_t magicNumber); bool IsHeaderValid(uint32_t magicNumber);
void LoadHotkeys(); void LoadHotkeys();
void LoadHeroItems(PlayerStruct &player); void LoadHeroItems(Player &player);
/** /**
* @brief Remove invalid inventory items from the inventory grid * @brief Remove invalid inventory items from the inventory grid
* @param pnum The id of the player * @param pnum The id of the player
*/ */
void RemoveEmptyInventory(PlayerStruct &player); void RemoveEmptyInventory(Player &player);
void LoadGame(bool firstflag); void LoadGame(bool firstflag);
void SaveHotkeys(); void SaveHotkeys();
void SaveHeroItems(PlayerStruct &player); void SaveHeroItems(Player &player);
void SaveGameData(); void SaveGameData();
void SaveGame(); void SaveGame();
void SaveLevel(); void SaveLevel();

54
Source/msg.cpp

@ -609,7 +609,7 @@ DWORD OnSyncData(TCmd *pCmd, int pnum)
return sync_update(pnum, (const byte *)pCmd); return sync_update(pnum, (const byte *)pCmd);
} }
DWORD OnWalk(TCmd *pCmd, PlayerStruct &player) DWORD OnWalk(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLoc *)pCmd; auto *p = (TCmdLoc *)pCmd;
@ -670,7 +670,7 @@ DWORD OnAddVitality(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnGotoGetItem(TCmd *pCmd, PlayerStruct &player) DWORD OnGotoGetItem(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam1 *)pCmd; auto *p = (TCmdLocParam1 *)pCmd;
@ -683,7 +683,7 @@ DWORD OnGotoGetItem(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnRequestGetItem(TCmd *pCmd, PlayerStruct &player) DWORD OnRequestGetItem(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdGItem *)pCmd; auto *p = (TCmdGItem *)pCmd;
@ -737,7 +737,7 @@ DWORD OnGetItem(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnGotoAutoGetItem(TCmd *pCmd, PlayerStruct &player) DWORD OnGotoAutoGetItem(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam1 *)pCmd; auto *p = (TCmdLocParam1 *)pCmd;
@ -750,7 +750,7 @@ DWORD OnGotoAutoGetItem(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnRequestAutoGetItem(TCmd *pCmd, PlayerStruct &player) DWORD OnRequestAutoGetItem(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdGItem *)pCmd; auto *p = (TCmdGItem *)pCmd;
@ -888,7 +888,7 @@ DWORD OnRespawnItem(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnAttackTile(TCmd *pCmd, PlayerStruct &player) DWORD OnAttackTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLoc *)pCmd; auto *p = (TCmdLoc *)pCmd;
@ -902,7 +902,7 @@ DWORD OnAttackTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnStandingAttackTile(TCmd *pCmd, PlayerStruct &player) DWORD OnStandingAttackTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLoc *)pCmd; auto *p = (TCmdLoc *)pCmd;
@ -916,7 +916,7 @@ DWORD OnStandingAttackTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnRangedAttackTile(TCmd *pCmd, PlayerStruct &player) DWORD OnRangedAttackTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLoc *)pCmd; auto *p = (TCmdLoc *)pCmd;
@ -930,7 +930,7 @@ DWORD OnRangedAttackTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnSpellWall(TCmd *pCmd, PlayerStruct &player) DWORD OnSpellWall(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam3 *)pCmd; auto *p = (TCmdLocParam3 *)pCmd;
@ -954,7 +954,7 @@ DWORD OnSpellWall(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnSpellTile(TCmd *pCmd, PlayerStruct &player) DWORD OnSpellTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam2 *)pCmd; auto *p = (TCmdLocParam2 *)pCmd;
@ -977,7 +977,7 @@ DWORD OnSpellTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnTargetSpellTile(TCmd *pCmd, PlayerStruct &player) DWORD OnTargetSpellTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam2 *)pCmd; auto *p = (TCmdLocParam2 *)pCmd;
@ -1000,7 +1000,7 @@ DWORD OnTargetSpellTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnOperateObjectTile(TCmd *pCmd, PlayerStruct &player) DWORD OnOperateObjectTile(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam1 *)pCmd; auto *p = (TCmdLocParam1 *)pCmd;
@ -1013,7 +1013,7 @@ DWORD OnOperateObjectTile(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnDisarm(TCmd *pCmd, PlayerStruct &player) DWORD OnDisarm(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam1 *)pCmd; auto *p = (TCmdLocParam1 *)pCmd;
@ -1026,7 +1026,7 @@ DWORD OnDisarm(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnOperateObjectTelekinesis(TCmd *pCmd, PlayerStruct &player) DWORD OnOperateObjectTelekinesis(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
@ -1038,7 +1038,7 @@ DWORD OnOperateObjectTelekinesis(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnAttackMonster(TCmd *pCmd, PlayerStruct &player) DWORD OnAttackMonster(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
@ -1053,7 +1053,7 @@ DWORD OnAttackMonster(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnAttackPlayer(TCmd *pCmd, PlayerStruct &player) DWORD OnAttackPlayer(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
@ -1066,7 +1066,7 @@ DWORD OnAttackPlayer(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnRangedAttackMonster(TCmd *pCmd, PlayerStruct &player) DWORD OnRangedAttackMonster(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
@ -1079,7 +1079,7 @@ DWORD OnRangedAttackMonster(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnRangedAttackPlayer(TCmd *pCmd, PlayerStruct &player) DWORD OnRangedAttackPlayer(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
@ -1092,7 +1092,7 @@ DWORD OnRangedAttackPlayer(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnSpellMonster(TCmd *pCmd, PlayerStruct &player) DWORD OnSpellMonster(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam3 *)pCmd; auto *p = (TCmdParam3 *)pCmd;
@ -1114,7 +1114,7 @@ DWORD OnSpellMonster(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnSpellPlayer(TCmd *pCmd, PlayerStruct &player) DWORD OnSpellPlayer(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam3 *)pCmd; auto *p = (TCmdParam3 *)pCmd;
@ -1136,7 +1136,7 @@ DWORD OnSpellPlayer(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnTargetSpellMonster(TCmd *pCmd, PlayerStruct &player) DWORD OnTargetSpellMonster(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam3 *)pCmd; auto *p = (TCmdParam3 *)pCmd;
@ -1158,7 +1158,7 @@ DWORD OnTargetSpellMonster(TCmd *pCmd, PlayerStruct &player)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnTargetSpellPlayer(TCmd *pCmd, PlayerStruct &player) DWORD OnTargetSpellPlayer(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam3 *)pCmd; auto *p = (TCmdParam3 *)pCmd;
@ -1216,7 +1216,7 @@ DWORD OnHealOther(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnTalkXY(TCmd *pCmd, PlayerStruct &player) DWORD OnTalkXY(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdLocParam1 *)pCmd; auto *p = (TCmdLocParam1 *)pCmd;
@ -1348,7 +1348,7 @@ DWORD OnPlayerDeath(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnPlayerDamage(TCmd *pCmd, PlayerStruct &player) DWORD OnPlayerDamage(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdDamage *)pCmd; auto *p = (TCmdDamage *)pCmd;
@ -1739,7 +1739,7 @@ DWORD OnNova(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
DWORD OnSetShield(TCmd *pCmd, PlayerStruct &player) DWORD OnSetShield(TCmd *pCmd, Player &player)
{ {
if (gbBufferMsgs != 1) if (gbBufferMsgs != 1)
player.pManaShield = true; player.pManaShield = true;
@ -1747,7 +1747,7 @@ DWORD OnSetShield(TCmd *pCmd, PlayerStruct &player)
return sizeof(*pCmd); return sizeof(*pCmd);
} }
DWORD OnRemoveShield(TCmd *pCmd, PlayerStruct &player) DWORD OnRemoveShield(TCmd *pCmd, Player &player)
{ {
if (gbBufferMsgs != 1) if (gbBufferMsgs != 1)
player.pManaShield = false; player.pManaShield = false;
@ -1755,7 +1755,7 @@ DWORD OnRemoveShield(TCmd *pCmd, PlayerStruct &player)
return sizeof(*pCmd); return sizeof(*pCmd);
} }
DWORD OnSetReflect(TCmd *pCmd, PlayerStruct &player) DWORD OnSetReflect(TCmd *pCmd, Player &player)
{ {
auto *p = (TCmdParam1 *)pCmd; auto *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1) if (gbBufferMsgs != 1)

6
Source/pack.cpp

@ -15,7 +15,7 @@ namespace devilution {
namespace { namespace {
void VerifyGoldSeeds(PlayerStruct &player) void VerifyGoldSeeds(Player &player)
{ {
for (int i = 0; i < player._pNumInv; i++) { for (int i = 0; i < player._pNumInv; i++) {
if (player.InvList[i].IDidx != IDI_GOLD) 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)); memset(pPack, 0, sizeof(*pPack));
pPack->destAction = player.destAction; pPack->destAction = player.destAction;
@ -197,7 +197,7 @@ void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire)
*id = item; *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.tile = { pPack->px, pPack->py };
player.position.future = { pPack->px, pPack->py }; player.position.future = { pPack->px, pPack->py };

4
Source/pack.h

@ -79,8 +79,8 @@ struct PkPlayerStruct {
}; };
#pragma pack(pop) #pragma pack(pop)
void PackPlayer(PkPlayerStruct *pPack, const PlayerStruct &player, bool manashield); void PackPlayer(PkPlayerStruct *pPack, const Player &player, bool manashield);
void UnPackPlayer(const PkPlayerStruct *pPack, PlayerStruct &player, bool netSync); void UnPackPlayer(const PkPlayerStruct *pPack, Player &player, bool netSync);
void PackItem(PkItemStruct *id, const ItemStruct *is); void PackItem(PkItemStruct *id, const ItemStruct *is);
void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire); void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire);

4
Source/pfile.cpp

@ -189,7 +189,7 @@ void CloseArchive(HANDLE *hsArchive)
*hsArchive = nullptr; *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); strncpy(heroinfo->name, player._pName, sizeof(heroinfo->name) - 1);
heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; heroinfo->name[sizeof(heroinfo->name) - 1] = '\0';
@ -375,7 +375,7 @@ bool pfile_delete_save(_uiheroinfo *heroInfo)
return true; 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; HANDLE archive;
PkPlayerStruct pkplr; PkPlayerStruct pkplr;

2
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(); uint32_t pfile_ui_get_first_unused_save_num();
bool pfile_ui_save_create(_uiheroinfo *heroinfo); bool pfile_ui_save_create(_uiheroinfo *heroinfo);
bool pfile_delete_save(_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(); bool LevelFileExists();
void GetTempLevelNames(char *szTemp); void GetTempLevelNames(char *szTemp);
void GetPermLevelNames(char *szPerm); void GetPermLevelNames(char *szPerm);

94
Source/player.cpp

@ -33,7 +33,7 @@
namespace devilution { namespace devilution {
int MyPlayerId; int MyPlayerId;
PlayerStruct Players[MAX_PLRS]; Player Players[MAX_PLRS];
bool MyPlayerIsDead; bool MyPlayerIsDead;
int deathdelay; int deathdelay;
@ -219,7 +219,7 @@ const char *const ClassPathTbl[] = {
"Warrior", "Warrior",
}; };
void PmChangeLightOff(PlayerStruct &player) void PmChangeLightOff(Player &player)
{ {
if (player._plid == NO_LIGHT) if (player._plid == NO_LIGHT)
return; return;
@ -304,7 +304,7 @@ constexpr std::array<const DirectionSettings, 8> WalkSettings { {
// clang-format on // 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.x = player.position.tile.x - ViewX;
ScrollInfo.tile.y = player.position.tile.y - ViewY; 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 position = player.position.tile;
Point futurePosition = position + dir; Point futurePosition = position + dir;
@ -368,7 +368,7 @@ void HandleWalkMode(int pnum, Displacement vel, Direction dir)
player._pdir = dir; player._pdir = dir;
} }
void StartWalkAnimation(PlayerStruct &player, Direction dir, bool pmWillBeCalled) void StartWalkAnimation(Player &player, Direction dir, bool pmWillBeCalled)
{ {
int skippedFrames = -2; int skippedFrames = -2;
if (currlevel == 0 && sgGameInitInfo.bRunInTown != 0) if (currlevel == 0 && sgGameInitInfo.bRunInTown != 0)
@ -405,7 +405,7 @@ void SetPlayerGPtrs(const char *path, std::unique_ptr<byte[]> &data, std::array<
} }
} }
void ClearStateVariables(PlayerStruct &player) void ClearStateVariables(Player &player)
{ {
player.position.temp = { 0, 0 }; player.position.temp = { 0, 0 };
player.tempDirection = DIR_S; player.tempDirection = DIR_S;
@ -584,7 +584,7 @@ void RespawnDeadItem(ItemStruct *itm, Point target)
itm->_itype = ITYPE_NONE; itm->_itype = ITYPE_NONE;
} }
void DeadItem(PlayerStruct &player, ItemStruct *itm, Displacement direction) void DeadItem(Player &player, ItemStruct *itm, Displacement direction)
{ {
if (itm->isEmpty()) if (itm->isEmpty())
return; return;
@ -768,7 +768,7 @@ bool DoWalk(int pnum, int variant)
return false; 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) { if (!player.InvBody[ii].isEmpty() && player.InvBody[ii]._iClass == ICLASS_WEAPON && (player.InvBody[ii]._iDamAcFlags & ISPLHF_DECAY) != 0) {
player.InvBody[ii]._iPLDam -= 5; player.InvBody[ii]._iPLDam -= 5;
@ -1538,7 +1538,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
int y = 0; int y = 0;
MonsterStruct *monster; MonsterStruct *monster;
PlayerStruct *target; Player *target;
ObjectStruct *object; ObjectStruct *object;
ItemStruct *item; ItemStruct *item;
@ -1944,7 +1944,7 @@ void ValidatePlayer()
myPlayer._pMemSpells &= msk; myPlayer._pMemSpells &= msk;
} }
void CheckCheatStats(PlayerStruct &player) void CheckCheatStats(Player &player)
{ {
if (player._pStrength > 750) { if (player._pStrength > 750) {
player._pStrength = 750; player._pStrength = 750;
@ -1973,7 +1973,7 @@ void CheckCheatStats(PlayerStruct &player)
} // namespace } // namespace
void PlayerStruct::CalcScrolls() void Player::CalcScrolls()
{ {
_pScrlSpells = 0; _pScrlSpells = 0;
for (int i = 0; i < _pNumInv; i++) { for (int i = 0; i < _pNumInv; i++) {
@ -1992,7 +1992,7 @@ void PlayerStruct::CalcScrolls()
EnsureValidReadiedSpell(*this); 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++) { for (int i = 0; i < _pNumInv; i++) {
if (InvList[i].IDidx == item) { if (InvList[i].IDidx == item) {
@ -2005,7 +2005,7 @@ bool PlayerStruct::HasItem(int item, int *idx) const
return false; return false;
} }
void PlayerStruct::RemoveInvItem(int iv, bool calcScrolls) void Player::RemoveInvItem(int iv, bool calcScrolls)
{ {
iv++; iv++;
@ -2037,7 +2037,7 @@ void PlayerStruct::RemoveInvItem(int iv, bool calcScrolls)
CalcScrolls(); CalcScrolls();
} }
bool PlayerStruct::TryRemoveInvItemById(int item) bool Player::TryRemoveInvItemById(int item)
{ {
int idx; int idx;
if (HasItem(item, &idx)) { if (HasItem(item, &idx)) {
@ -2047,7 +2047,7 @@ bool PlayerStruct::TryRemoveInvItemById(int item)
return false; return false;
} }
void PlayerStruct::RemoveSpdBarItem(int iv) void Player::RemoveSpdBarItem(int iv)
{ {
SpdList[iv]._itype = ITYPE_NONE; SpdList[iv]._itype = ITYPE_NONE;
@ -2055,7 +2055,7 @@ void PlayerStruct::RemoveSpdBarItem(int iv)
force_redraw = 255; force_redraw = 255;
} }
int PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const int Player::GetBaseAttributeValue(CharacterAttribute attribute) const
{ {
switch (attribute) { switch (attribute) {
case CharacterAttribute::Dexterity: 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<HeroClass>::value][enum_size<CharacterAttribute>::value] = { static const int MaxStats[enum_size<HeroClass>::value][enum_size<CharacterAttribute>::value] = {
// clang-format off // clang-format off
@ -2087,7 +2087,7 @@ int PlayerStruct::GetMaximumAttributeValue(CharacterAttribute attribute) const
return MaxStats[static_cast<std::size_t>(_pClass)][static_cast<std::size_t>(attribute)]; return MaxStats[static_cast<std::size_t>(_pClass)][static_cast<std::size_t>(attribute)];
} }
Point PlayerStruct::GetTargetPosition() const Point Player::GetTargetPosition() const
{ {
// clang-format off // clang-format off
constexpr int DirectionOffsetX[8] = { 0,-1, 1, 0,-1, 1, 1,-1 }; constexpr int DirectionOffsetX[8] = { 0,-1, 1, 0,-1, 1, 1,-1 };
@ -2105,14 +2105,14 @@ Point PlayerStruct::GetTargetPosition() const
return target; return target;
} }
void PlayerStruct::Say(HeroSpeech speechId) const void Player::Say(HeroSpeech speechId) const
{ {
_sfx_id soundEffect = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)]; _sfx_id soundEffect = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)];
PlaySfxLoc(soundEffect, position.tile); PlaySfxLoc(soundEffect, position.tile);
} }
void PlayerStruct::SaySpecific(HeroSpeech speechId) const void Player::SaySpecific(HeroSpeech speechId) const
{ {
_sfx_id soundEffect = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)]; _sfx_id soundEffect = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)];
@ -2122,31 +2122,31 @@ void PlayerStruct::SaySpecific(HeroSpeech speechId) const
PlaySfxLoc(soundEffect, position.tile, false); PlaySfxLoc(soundEffect, position.tile, false);
} }
void PlayerStruct::Say(HeroSpeech speechId, int delay) const void Player::Say(HeroSpeech speechId, int delay) const
{ {
sfxdelay = delay; sfxdelay = delay;
sfxdnum = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)]; sfxdnum = herosounds[static_cast<size_t>(_pClass)][static_cast<size_t>(speechId)];
} }
void PlayerStruct::Stop() void Player::Stop()
{ {
ClrPlrPath(*this); ClrPlrPath(*this);
destAction = ACTION_NONE; destAction = ACTION_NONE;
} }
bool PlayerStruct::IsWalking() const bool Player::IsWalking() const
{ {
return IsAnyOf(_pmode, PM_WALK, PM_WALK2, PM_WALK3); 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 // Create empty default initialized Player on heap to avoid excessive stack usage
auto emptyPlayer = std::make_unique<PlayerStruct>(); auto emptyPlayer = std::make_unique<Player>();
*this = std::move(*emptyPlayer); *this = std::move(*emptyPlayer);
} }
void LoadPlrGFX(PlayerStruct &player, player_graphic graphic) void LoadPlrGFX(Player &player, player_graphic graphic)
{ {
char prefix[16]; char prefix[16];
char pszName[256]; char pszName[256];
@ -2247,7 +2247,7 @@ void LoadPlrGFX(PlayerStruct &player, player_graphic graphic)
SetPlayerGPtrs(pszName, animationData.RawData, animationData.CelSpritesForDirections, animationWidth); SetPlayerGPtrs(pszName, animationData.RawData, animationData.CelSpritesForDirections, animationWidth);
} }
void InitPlayerGFX(PlayerStruct &player) void InitPlayerGFX(Player &player)
{ {
if (player._pHitPoints >> 6 == 0) { if (player._pHitPoints >> 6 == 0) {
player._pgfxnum = 0; player._pgfxnum = 0;
@ -2263,7 +2263,7 @@ void InitPlayerGFX(PlayerStruct &player)
} }
} }
void ResetPlayerGFX(PlayerStruct &player) void ResetPlayerGFX(Player &player)
{ {
player.AnimInfo.pCelSprite = nullptr; player.AnimInfo.pCelSprite = nullptr;
for (auto &animData : player.AnimationData) { 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<size_t>(graphic)].RawData == nullptr) if (player.AnimationData[static_cast<size_t>(graphic)].RawData == nullptr)
LoadPlrGFX(player, graphic); 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); player.AnimInfo.SetNewAnimation(pCelSprite, numberOfFrames, delayLen, flags, numSkippedFrames, distributeFramesBeforeFrame);
} }
void SetPlrAnims(PlayerStruct &player) void SetPlrAnims(Player &player)
{ {
HeroClass pc = player._pClass; HeroClass pc = player._pClass;
@ -2549,7 +2549,7 @@ void CreatePlayer(int playerId, HeroClass c)
SetRndSeed(0); SetRndSeed(0);
} }
int CalcStatDiff(PlayerStruct &player) int CalcStatDiff(Player &player)
{ {
int diff = 0; int diff = 0;
for (auto attribute : enum_values<CharacterAttribute>()) { for (auto attribute : enum_values<CharacterAttribute>()) {
@ -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]; 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; player.position.old = player.position.tile;
} }
@ -3090,7 +3090,7 @@ StartPlayerKill(int pnum, int earflag)
SetPlayerHitPoints(player, 0); SetPlayerHitPoints(player, 0);
} }
void StripTopGold(PlayerStruct &player) void StripTopGold(Player &player)
{ {
ItemStruct tmpItem = player.HoldItem; 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)); 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. * @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. * @param position Dungeon tile coordinates.
* @return False if something (other than the player themselves) is blocking the tile. * @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) if (position.x < 0 || position.x >= MAXDUNX || position.y < 0 || position.y >= MAXDUNY)
return false; return false;
@ -3424,7 +3424,7 @@ bool PosOkPlayer(const PlayerStruct &player, Point position)
return true; return true;
} }
void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace) void MakePlrPath(Player &player, Point targetPosition, bool endspace)
{ {
if (player.position.future == targetPosition) { if (player.position.future == targetPosition) {
return; return;
@ -3442,7 +3442,7 @@ void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace)
player.walkpath[path] = WALK_NONE; player.walkpath[path] = WALK_NONE;
} }
void CalcPlrStaff(PlayerStruct &player) void CalcPlrStaff(Player &player)
{ {
player._pISpells = 0; player._pISpells = 0;
if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty() if (!player.InvBody[INVLOC_HAND_LEFT].isEmpty()
@ -3654,7 +3654,7 @@ void SyncInitPlr(int pnum)
SyncInitPlrPos(pnum); SyncInitPlrPos(pnum);
} }
void CheckStats(PlayerStruct &player) void CheckStats(Player &player)
{ {
for (auto attribute : enum_values<CharacterAttribute>()) { for (auto attribute : enum_values<CharacterAttribute>()) {
int maxStatPoint = player.GetMaximumAttributeValue(attribute); 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._pHitPoints = val;
player._pHPBase = val + player._pMaxHPBase - player._pMaxHP; 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; player._pBaseStr = v;
CalcPlrInv(player, true); CalcPlrInv(player, true);
} }
void SetPlrMag(PlayerStruct &player, int v) void SetPlrMag(Player &player, int v)
{ {
player._pBaseMag = v; player._pBaseMag = v;
@ -3818,13 +3818,13 @@ void SetPlrMag(PlayerStruct &player, int v)
CalcPlrInv(player, true); CalcPlrInv(player, true);
} }
void SetPlrDex(PlayerStruct &player, int v) void SetPlrDex(Player &player, int v)
{ {
player._pBaseDex = v; player._pBaseDex = v;
CalcPlrInv(player, true); CalcPlrInv(player, true);
} }
void SetPlrVit(PlayerStruct &player, int v) void SetPlrVit(Player &player, int v)
{ {
player._pBaseVit = v; player._pBaseVit = v;
@ -3838,7 +3838,7 @@ void SetPlrVit(PlayerStruct &player, int v)
CalcPlrInv(player, true); CalcPlrInv(player, true);
} }
void InitDungMsgs(PlayerStruct &player) void InitDungMsgs(Player &player)
{ {
player.pDungMsgs = 0; player.pDungMsgs = 0;
player.pDungMsgs2 = 0; player.pDungMsgs2 = 0;

52
Source/player.h

@ -161,10 +161,10 @@ struct PlayerAnimationData {
std::unique_ptr<byte[]> RawData; std::unique_ptr<byte[]> RawData;
}; };
struct PlayerStruct { struct Player {
PlayerStruct() = default; Player() = default;
PlayerStruct(PlayerStruct &&) noexcept = default; Player(Player &&) noexcept = default;
PlayerStruct &operator=(PlayerStruct &&) noexcept = default; Player &operator=(Player &&) noexcept = default;
PLR_MODE _pmode; PLR_MODE _pmode;
int8_t walkpath[MAX_PATH_LENGTH]; int8_t walkpath[MAX_PATH_LENGTH];
@ -392,7 +392,7 @@ struct PlayerStruct {
bool IsWalking() const; bool IsWalking() const;
/** /**
* @brief Resets all Data of the current PlayerStruct * @brief Resets all Data of the current Player
*/ */
void Reset(); void Reset();
@ -569,13 +569,13 @@ struct PlayerStruct {
}; };
extern int MyPlayerId; extern int MyPlayerId;
extern PlayerStruct Players[MAX_PLRS]; extern Player Players[MAX_PLRS];
extern bool MyPlayerIsDead; extern bool MyPlayerIsDead;
extern int BlockBonuses[enum_size<HeroClass>::value]; extern int BlockBonuses[enum_size<HeroClass>::value];
void LoadPlrGFX(PlayerStruct &player, player_graphic graphic); void LoadPlrGFX(Player &player, player_graphic graphic);
void InitPlayerGFX(PlayerStruct &player); void InitPlayerGFX(Player &player);
void ResetPlayerGFX(PlayerStruct &player); void ResetPlayerGFX(Player &player);
/** /**
* @brief Sets the new Player Animation with all relevant information for rendering * @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 numSkippedFrames Number of Frames that will be skipped (for example with modifier "faster attack")
* @param distributeFramesBeforeFrame Distribute the numSkippedFrames only before this frame * @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 NewPlrAnim(Player &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 SetPlrAnims(Player &player);
void CreatePlayer(int playerId, HeroClass c); void CreatePlayer(int playerId, HeroClass c);
int CalcStatDiff(PlayerStruct &player); int CalcStatDiff(Player &player);
#ifdef _DEBUG #ifdef _DEBUG
void NextPlrLevel(int pnum); void NextPlrLevel(int pnum);
#endif #endif
void AddPlrExperience(int pnum, int lvl, int exp); void AddPlrExperience(int pnum, int lvl, int exp);
void AddPlrMonstExper(int lvl, int exp, char pmask); void AddPlrMonstExper(int lvl, int exp, char pmask);
void ApplyPlrDamage(int pnum, int dam, int minHP = 0, int frac = 0, int earflag = 0); 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 InitMultiView();
void PlrClrTrans(Point position); void PlrClrTrans(Point position);
void PlrDoTrans(Point position); void PlrDoTrans(Point position);
void SetPlayerOld(PlayerStruct &player); void SetPlayerOld(Player &player);
void FixPlayerLocation(int pnum, Direction bDir); void FixPlayerLocation(int pnum, Direction bDir);
void StartStand(int pnum, Direction dir); void StartStand(int pnum, Direction dir);
void StartPlrBlock(int pnum, Direction dir); void StartPlrBlock(int pnum, Direction dir);
@ -609,32 +609,32 @@ void FixPlrWalkTags(int pnum);
void RemovePlrFromMap(int pnum); void RemovePlrFromMap(int pnum);
void StartPlrHit(int pnum, int dam, bool forcehit); void StartPlrHit(int pnum, int dam, bool forcehit);
void StartPlayerKill(int pnum, int earflag); void StartPlayerKill(int pnum, int earflag);
void StripTopGold(PlayerStruct &player); void StripTopGold(Player &player);
void SyncPlrKill(int pnum, int earflag); void SyncPlrKill(int pnum, int earflag);
void RemovePlrMissiles(int pnum); void RemovePlrMissiles(int pnum);
void StartNewLvl(int pnum, interface_mode fom, int lvl); void StartNewLvl(int pnum, interface_mode fom, int lvl);
void RestartTownLvl(int pnum); void RestartTownLvl(int pnum);
void StartWarpLvl(int pnum, int pidx); void StartWarpLvl(int pnum, int pidx);
void ProcessPlayers(); void ProcessPlayers();
void ClrPlrPath(PlayerStruct &player); void ClrPlrPath(Player &player);
bool PosOkPlayer(const PlayerStruct &player, Point position); bool PosOkPlayer(const Player &player, Point position);
void MakePlrPath(PlayerStruct &player, Point targetPosition, bool endspace); void MakePlrPath(Player &player, Point targetPosition, bool endspace);
void CalcPlrStaff(PlayerStruct &player); void CalcPlrStaff(Player &player);
void CheckPlrSpell(); void CheckPlrSpell();
void SyncPlrAnim(int pnum); void SyncPlrAnim(int pnum);
void SyncInitPlrPos(int pnum); void SyncInitPlrPos(int pnum);
void SyncInitPlr(int pnum); void SyncInitPlr(int pnum);
void CheckStats(PlayerStruct &player); void CheckStats(Player &player);
void ModifyPlrStr(int p, int l); void ModifyPlrStr(int p, int l);
void ModifyPlrMag(int p, int l); void ModifyPlrMag(int p, int l);
void ModifyPlrDex(int p, int l); void ModifyPlrDex(int p, int l);
void ModifyPlrVit(int p, int l); void ModifyPlrVit(int p, int l);
void SetPlayerHitPoints(PlayerStruct &player, int val); void SetPlayerHitPoints(Player &player, int val);
void SetPlrStr(PlayerStruct &player, int v); void SetPlrStr(Player &player, int v);
void SetPlrMag(PlayerStruct &player, int v); void SetPlrMag(Player &player, int v);
void SetPlrDex(PlayerStruct &player, int v); void SetPlrDex(Player &player, int v);
void SetPlrVit(PlayerStruct &player, int v); void SetPlrVit(Player &player, int v);
void InitDungMsgs(PlayerStruct &player); void InitDungMsgs(Player &player);
void PlayDungMsgs(); void PlayDungMsgs();
/* data */ /* data */

8
Source/spells.cpp

@ -27,7 +27,7 @@ namespace {
* @param player The player whose readied spell is to be checked. * @param player The player whose readied spell is to be checked.
* @return 'true' when the readied spell is currently valid, and 'false' otherwise. * @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) { switch (player._pRSplType) {
case RSPLTYPE_SKILL: 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. * @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. * @param player The player whose readied spell is to be cleared.
*/ */
void ClearReadiedSpell(PlayerStruct &player) void ClearReadiedSpell(Player &player)
{ {
if (player._pRSpell != SPL_INVALID) { if (player._pRSpell != SPL_INVALID) {
player._pRSpell = SPL_INVALID; player._pRSpell = SPL_INVALID;
@ -109,7 +109,7 @@ void PlacePlayer(int pnum)
} // namespace } // namespace
int GetManaAmount(PlayerStruct &player, spell_id sn) int GetManaAmount(Player &player, spell_id sn)
{ {
int ma; // mana amount 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. * @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. * @param player The player whose readied spell is to be checked.
*/ */
void EnsureValidReadiedSpell(PlayerStruct &player) void EnsureValidReadiedSpell(Player &player)
{ {
if (!IsReadiedSpellValid(player)) { if (!IsReadiedSpellValid(player)) {
ClearReadiedSpell(player); ClearReadiedSpell(player);

4
Source/spells.h

@ -16,10 +16,10 @@ enum class SpellCheckResult : uint8_t {
Fail_Busy, Fail_Busy,
}; };
int GetManaAmount(PlayerStruct &player, spell_id sn); int GetManaAmount(Player &player, spell_id sn);
void UseMana(int id, spell_id sn); void UseMana(int id, spell_id sn);
SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly); 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 CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl);
void DoResurrect(int pnum, uint16_t rid); void DoResurrect(int pnum, uint16_t rid);
void DoHealOther(int pnum, uint16_t rid); void DoHealOther(int pnum, uint16_t rid);

2
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++) { for (int i = 0; i < player._pNumInv; i++) {
auto &item = player.InvList[i]; auto &item = player.InvList[i];

30
Source/towners.cpp

@ -31,7 +31,7 @@ struct TownerInit {
Point position; Point position;
Direction dir; Direction dir;
void (*init)(TownerStruct &towner, const TownerInit &initData); 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) void NewTownerAnim(TownerStruct &towner, byte *pAnim, uint8_t numFrames, int delay)
@ -290,7 +290,7 @@ void TownerTalk(_speech_id message)
InitQTextMsg(message); InitQTextMsg(message);
} }
void TalkToBarOwner(PlayerStruct &player, TownerStruct &barOwner) void TalkToBarOwner(Player &player, TownerStruct &barOwner)
{ {
if (!player._pLvlVisited[0]) { if (!player._pLvlVisited[0]) {
InitQTextMsg(TEXT_INTRO); InitQTextMsg(TEXT_INTRO);
@ -349,7 +349,7 @@ void TalkToBarOwner(PlayerStruct &player, TownerStruct &barOwner)
StartStore(STORE_TAVERN); StartStore(STORE_TAVERN);
} }
void TalkToDeadguy(PlayerStruct &player, TownerStruct & /*deadguy*/) void TalkToDeadguy(Player &player, TownerStruct & /*deadguy*/)
{ {
auto &quest = Quests[Q_BUTCHER]; auto &quest = Quests[Q_BUTCHER];
if (quest._qactive == QUEST_DONE) if (quest._qactive == QUEST_DONE)
@ -368,7 +368,7 @@ void TalkToDeadguy(PlayerStruct &player, TownerStruct & /*deadguy*/)
NetSendCmdQuest(true, quest); NetSendCmdQuest(true, quest);
} }
void TalkToBlackSmith(PlayerStruct &player, TownerStruct &blackSmith) void TalkToBlackSmith(Player &player, TownerStruct &blackSmith)
{ {
if (Quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) { if (Quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) {
if (player._pLvlVisited[4] && Quests[Q_ROCK]._qactive != QUEST_DONE) { if (player._pLvlVisited[4] && Quests[Q_ROCK]._qactive != QUEST_DONE) {
@ -415,7 +415,7 @@ void TalkToBlackSmith(PlayerStruct &player, TownerStruct &blackSmith)
StartStore(STORE_SMITH); 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_NOTAVAIL) {
if (Quests[Q_MUSHROOM]._qactive == QUEST_INIT && player.TryRemoveInvItemById(IDI_FUNGALTM)) { if (Quests[Q_MUSHROOM]._qactive == QUEST_INIT && player.TryRemoveInvItemById(IDI_FUNGALTM)) {
@ -461,7 +461,7 @@ void TalkToWitch(PlayerStruct &player, TownerStruct & /*witch*/)
StartStore(STORE_WITCH); StartStore(STORE_WITCH);
} }
void TalkToBarmaid(PlayerStruct &player, TownerStruct & /*barmaid*/) void TalkToBarmaid(Player &player, TownerStruct & /*barmaid*/)
{ {
if (!player._pLvlVisited[21] && player.HasItem(IDI_MAPOFDOOM)) { if (!player._pLvlVisited[21] && player.HasItem(IDI_MAPOFDOOM)) {
Quests[Q_GRAVE]._qactive = QUEST_ACTIVE; Quests[Q_GRAVE]._qactive = QUEST_ACTIVE;
@ -475,13 +475,13 @@ void TalkToBarmaid(PlayerStruct &player, TownerStruct & /*barmaid*/)
StartStore(STORE_BARMAID); StartStore(STORE_BARMAID);
} }
void TalkToDrunk(PlayerStruct & /*player*/, TownerStruct & /*drunk*/) void TalkToDrunk(Player & /*player*/, TownerStruct & /*drunk*/)
{ {
TownerTalk(TEXT_FARNHAM1); TownerTalk(TEXT_FARNHAM1);
StartStore(STORE_DRUNK); StartStore(STORE_DRUNK);
} }
void TalkToHealer(PlayerStruct &player, TownerStruct &healer) void TalkToHealer(Player &player, TownerStruct &healer)
{ {
if (Quests[Q_PWATER]._qactive != QUEST_NOTAVAIL) { if (Quests[Q_PWATER]._qactive != QUEST_NOTAVAIL) {
if ((player._pLvlVisited[1] || player._pLvlVisited[5]) && Quests[Q_PWATER]._qactive == QUEST_INIT) { 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); StartStore(STORE_HEALER);
} }
void TalkToBoy(PlayerStruct & /*player*/, TownerStruct & /*boy*/) void TalkToBoy(Player & /*player*/, TownerStruct & /*boy*/)
{ {
TownerTalk(TEXT_WIRT1); TownerTalk(TEXT_WIRT1);
StartStore(STORE_BOY); StartStore(STORE_BOY);
} }
void TalkToStoryteller(PlayerStruct &player, TownerStruct & /*storyteller*/) void TalkToStoryteller(Player &player, TownerStruct & /*storyteller*/)
{ {
auto &betrayerQuest = Quests[Q_BETRAYER]; auto &betrayerQuest = Quests[Q_BETRAYER];
if (!gbIsMultiplayer) { if (!gbIsMultiplayer) {
@ -553,7 +553,7 @@ void TalkToStoryteller(PlayerStruct &player, TownerStruct & /*storyteller*/)
StartStore(STORE_STORY); StartStore(STORE_STORY);
} }
void TalkToCow(PlayerStruct &player, TownerStruct &cow) void TalkToCow(Player &player, TownerStruct &cow)
{ {
if (CowPlaying != SFX_NONE && effect_is_playing(CowPlaying)) if (CowPlaying != SFX_NONE && effect_is_playing(CowPlaying))
return; return;
@ -583,7 +583,7 @@ void TalkToCow(PlayerStruct &player, TownerStruct &cow)
PlaySfxLoc(CowPlaying, cow.position); PlaySfxLoc(CowPlaying, cow.position);
} }
void TalkToFarmer(PlayerStruct &player, TownerStruct &farmer) void TalkToFarmer(Player &player, TownerStruct &farmer)
{ {
auto &quest = Quests[Q_FARMER]; auto &quest = Quests[Q_FARMER];
switch (quest._qactive) { 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)) { if (player.TryRemoveInvItemById(IDI_GREYSUIT)) {
InitQTextMsg(TEXT_JERSEY7); 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]; 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]; auto &towner = Towners[t];

4
Source/towners.h

@ -57,7 +57,7 @@ struct TownerStruct {
/** Specifies the animation frame sequence. */ /** Specifies the animation frame sequence. */
const uint8_t *animOrder; // unowned const uint8_t *animOrder; // unowned
std::size_t animOrderSize; std::size_t animOrderSize;
void (*talk)(PlayerStruct &player, TownerStruct &towner); void (*talk)(Player &player, TownerStruct &towner);
_talker_id _ttype; _talker_id _ttype;
}; };
@ -66,7 +66,7 @@ extern TownerStruct Towners[NUM_TOWNERS];
void InitTowners(); void InitTowners();
void FreeTownerGFX(); void FreeTownerGFX();
void ProcessTowners(); void ProcessTowners();
void TalkToTowner(PlayerStruct &player, int t); void TalkToTowner(Player &player, int t);
#ifdef _DEBUG #ifdef _DEBUG
bool DebugTalkToTowner(std::string targetName); bool DebugTalkToTowner(std::string targetName);

2
Source/track.cpp

@ -16,7 +16,7 @@ namespace devilution {
namespace { namespace {
void RepeatWalk(PlayerStruct &player) void RepeatWalk(Player &player)
{ {
if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1) if (cursmx < 0 || cursmx >= MAXDUNX - 1 || cursmy < 0 || cursmy >= MAXDUNY - 1)
return; return;

2
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._pSplLvl, 64), 0);
ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 1); ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 1);

2
test/writehero_test.cpp

@ -214,7 +214,7 @@ static void PackPlayerTest(PkPlayerStruct *pPack)
pPack->_pNumInv = 2; pPack->_pNumInv = 2;
} }
static void AssertPlayer(PlayerStruct &player) static void AssertPlayer(Player &player)
{ {
ASSERT_EQ(Count8(player._pSplLvl, 64), 23); ASSERT_EQ(Count8(player._pSplLvl, 64), 23);
ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 9); ASSERT_EQ(Count8(player.InvGrid, NUM_INV_GRID_ELEM), 9);

Loading…
Cancel
Save