Browse Source

♻️Remove SDL types from player header

pull/1609/head
Anders Jenbo 5 years ago
parent
commit
a9874d65c1
  1. 6
      Source/monster.cpp
  2. 108
      Source/pack.h
  3. 6
      Source/player.cpp
  4. 276
      Source/player.h

6
Source/monster.cpp

@ -2673,11 +2673,7 @@ void PrepDoEnding()
deathflag = false; deathflag = false;
cineflag = true; cineflag = true;
uint32_t *killLevel = &plr[myplr].pDiabloKillLevel; plr[myplr].pDiabloKillLevel = std::max(plr[myplr].pDiabloKillLevel, static_cast<uint8_t>(sgGameInitInfo.nDifficulty + 1));
uint32_t newKillLevel = sgGameInitInfo.nDifficulty + 1;
if (*killLevel > newKillLevel)
newKillLevel = *killLevel;
plr[myplr].pDiabloKillLevel = newKillLevel;
for (auto &player : plr) { for (auto &player : plr) {
player._pmode = PM_QUIT; player._pmode = PM_QUIT;

108
Source/pack.h

@ -5,6 +5,8 @@
*/ */
#pragma once #pragma once
#include <stdint.h>
#include "player.h" #include "player.h"
#include "inv.h" #include "inv.h"
#include "items.h" #include "items.h"
@ -13,66 +15,66 @@ namespace devilution {
#pragma pack(push, 1) #pragma pack(push, 1)
struct PkItemStruct { struct PkItemStruct {
Uint32 iSeed; uint32_t iSeed;
Uint16 iCreateInfo; uint16_t iCreateInfo;
Uint16 idx; uint16_t idx;
Uint8 bId; uint8_t bId;
Uint8 bDur; uint8_t bDur;
Uint8 bMDur; uint8_t bMDur;
Uint8 bCh; uint8_t bCh;
Uint8 bMCh; uint8_t bMCh;
Uint16 wValue; uint16_t wValue;
Uint32 dwBuff; int32_t dwBuff;
}; };
struct PkPlayerStruct { struct PkPlayerStruct {
Uint32 dwLowDateTime; uint32_t dwLowDateTime;
Uint32 dwHighDateTime; uint32_t dwHighDateTime;
Sint8 destAction; int8_t destAction;
Sint8 destParam1; int8_t destParam1;
Sint8 destParam2; int8_t destParam2;
Uint8 plrlevel; uint8_t plrlevel;
Uint8 px; uint8_t px;
Uint8 py; uint8_t py;
Uint8 targx; uint8_t targx;
Uint8 targy; uint8_t targy;
char pName[PLR_NAME_LEN]; char pName[PLR_NAME_LEN];
Sint8 pClass; int8_t pClass;
Uint8 pBaseStr; uint8_t pBaseStr;
Uint8 pBaseMag; uint8_t pBaseMag;
Uint8 pBaseDex; uint8_t pBaseDex;
Uint8 pBaseVit; uint8_t pBaseVit;
Sint8 pLevel; int8_t pLevel;
Uint8 pStatPts; uint8_t pStatPts;
Sint32 pExperience; int32_t pExperience;
Sint32 pGold; int32_t pGold;
Sint32 pHPBase; int32_t pHPBase;
Sint32 pMaxHPBase; int32_t pMaxHPBase;
Sint32 pManaBase; int32_t pManaBase;
Sint32 pMaxManaBase; int32_t pMaxManaBase;
Sint8 pSplLvl[37]; // Should be MAX_SPELLS but set to 37 to make save games compatible int8_t pSplLvl[37]; // Should be MAX_SPELLS but set to 37 to make save games compatible
Uint64 pMemSpells; uint64_t pMemSpells;
PkItemStruct InvBody[NUM_INVLOC]; PkItemStruct InvBody[NUM_INVLOC];
PkItemStruct InvList[NUM_INV_GRID_ELEM]; PkItemStruct InvList[NUM_INV_GRID_ELEM];
Sint8 InvGrid[NUM_INV_GRID_ELEM]; int8_t InvGrid[NUM_INV_GRID_ELEM];
Uint8 _pNumInv; uint8_t _pNumInv;
PkItemStruct SpdList[MAXBELTITEMS]; PkItemStruct SpdList[MAXBELTITEMS];
Sint8 pTownWarps; int8_t pTownWarps;
Sint8 pDungMsgs; int8_t pDungMsgs;
Sint8 pLvlLoad; int8_t pLvlLoad;
Uint8 pBattleNet; uint8_t pBattleNet;
Uint8 pManaShield; uint8_t pManaShield;
Uint8 pDungMsgs2; uint8_t pDungMsgs2;
Sint8 bIsHellfire; int8_t bIsHellfire;
Sint8 bReserved; // For future use int8_t bReserved; // For future use
Uint16 wReflections; uint16_t wReflections;
Sint16 wReserved2; // For future use int16_t wReserved2; // For future use
Sint8 pSplLvl2[10]; // Hellfire spells int8_t pSplLvl2[10]; // Hellfire spells
Sint16 wReserved8; // For future use int16_t wReserved8; // For future use
Uint32 pDiabloKillLevel; uint32_t pDiabloKillLevel;
Uint32 pDifficulty; uint32_t pDifficulty;
Sint32 pDamAcFlags; int32_t pDamAcFlags;
Sint32 dwReserved[5]; // For future use int32_t dwReserved[5]; // For future use
}; };
#pragma pack(pop) #pragma pack(pop)

6
Source/player.cpp

@ -192,7 +192,7 @@ const char *const ClassPathTbl[] = {
"Warrior", "Warrior",
}; };
Sint32 PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const int PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const
{ {
switch (attribute) { switch (attribute) {
case CharacterAttribute::Dexterity: case CharacterAttribute::Dexterity:
@ -208,7 +208,7 @@ Sint32 PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const
} }
} }
Sint32 PlayerStruct::GetMaximumAttributeValue(CharacterAttribute attribute) const int PlayerStruct::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
@ -3698,7 +3698,7 @@ void ProcessPlayerAnimation(int pnum)
} }
} }
Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer) int GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer)
{ {
// Normal logic is used, // Normal logic is used,
// - if no frame-skipping is required and so we have exactly one Animationframe per GameTick (_pAnimUsedNumFrames = 0) // - if no frame-skipping is required and so we have exactly one Animationframe per GameTick (_pAnimUsedNumFrames = 0)

276
Source/player.h

@ -151,42 +151,42 @@ struct PlayerStruct {
int8_t walkpath[MAX_PATH_LENGTH]; int8_t walkpath[MAX_PATH_LENGTH];
bool plractive; bool plractive;
action_id destAction; action_id destAction;
Sint32 destParam1; int destParam1;
Sint32 destParam2; int destParam2;
direction destParam3; direction destParam3;
Sint32 destParam4; int destParam4;
Sint32 plrlevel; int plrlevel;
Sint32 _px; // Tile X-position of player int _px; // Tile X-position of player
Sint32 _py; // Tile Y-position of player int _py; // Tile Y-position of player
Sint32 _pfutx; // Future tile X-position of player. Set at start of walking animation int _pfutx; // Future tile X-position of player. Set at start of walking animation
Sint32 _pfuty; // Future tile Y-position of player. Set at start of walking animation int _pfuty; // Future tile Y-position of player. Set at start of walking animation
Sint32 _ptargx; // Target tile X-position for player movment. Set during pathfinding int _ptargx; // Target tile X-position for player movment. Set during pathfinding
Sint32 _ptargy; // Target tile Y-position for player movment. Set during pathfinding int _ptargy; // Target tile Y-position for player movment. Set during pathfinding
Sint32 _pownerx; // Tile X-position of player. Set via network on player input int _pownerx; // Tile X-position of player. Set via network on player input
Sint32 _pownery; // Tile X-position of player. Set via network on player input int _pownery; // Tile X-position of player. Set via network on player input
Sint32 _poldx; // Most recent X-position in dPlayer. int _poldx; // Most recent X-position in dPlayer.
Sint32 _poldy; // Most recent Y-position in dPlayer. int _poldy; // Most recent Y-position in dPlayer.
Sint32 _pxoff; // Player sprite's pixel X-offset from tile. int _pxoff; // Player sprite's pixel X-offset from tile.
Sint32 _pyoff; // Player sprite's pixel Y-offset from tile. int _pyoff; // Player sprite's pixel Y-offset from tile.
Sint32 _pxvel; // Pixel X-velocity while walking. Indirectly applied to _pxoff via _pvar6 int _pxvel; // Pixel X-velocity while walking. Indirectly applied to _pxoff via _pvar6
Sint32 _pyvel; // Pixel Y-velocity while walking. Indirectly applied to _pyoff via _pvar7 int _pyvel; // Pixel Y-velocity while walking. Indirectly applied to _pyoff via _pvar7
direction _pdir; // Direction faced by player (direction enum) direction _pdir; // Direction faced by player (direction enum)
Sint32 _pgfxnum; // Bitmask indicating what variant of the sprite the player is using. Lower byte define weapon (anim_weapon_id) and higher values define armour (starting with anim_armor_id) int _pgfxnum; // Bitmask indicating what variant of the sprite the player is using. Lower byte define weapon (anim_weapon_id) and higher values define armour (starting with anim_armor_id)
Uint8 *_pAnimData; uint8_t *_pAnimData;
Sint32 _pAnimDelay; // Tick length of each frame in the current animation int _pAnimDelay; // Tick length of each frame in the current animation
Sint32 _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay int _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay
Sint32 _pAnimLen; // Number of frames in current animation int _pAnimLen; // Number of frames in current animation
Sint32 _pAnimFrame; // Current frame of animation. int _pAnimFrame; // Current frame of animation.
Sint32 _pAnimWidth; int _pAnimWidth;
Sint32 _pAnimWidth2; int _pAnimWidth2;
Sint32 _pAnimNumSkippedFrames; // Number of Frames that will be skipped (for example with modifier "faster attack") int _pAnimNumSkippedFrames; // Number of Frames that will be skipped (for example with modifier "faster attack")
Sint32 _pAnimGameTicksSinceSequenceStarted; // Number of GameTicks after the current animation sequence started int _pAnimGameTicksSinceSequenceStarted; // Number of GameTicks after the current animation sequence started
Sint32 _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame int _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame
Sint32 _plid; int _plid;
Sint32 _pvid; int _pvid;
spell_id _pSpell; spell_id _pSpell;
spell_type _pSplType; spell_type _pSplType;
Sint8 _pSplFrom; // TODO Create enum int8_t _pSplFrom; // TODO Create enum
spell_id _pTSpell; spell_id _pTSpell;
spell_type _pTSplType; spell_type _pTSplType;
spell_id _pRSpell; spell_id _pRSpell;
@ -194,134 +194,134 @@ struct PlayerStruct {
spell_id _pSBkSpell; spell_id _pSBkSpell;
spell_type _pSBkSplType; spell_type _pSBkSplType;
int8_t _pSplLvl[64]; int8_t _pSplLvl[64];
Uint64 _pMemSpells; // Bitmask of learned spells uint64_t _pMemSpells; // Bitmask of learned spells
Uint64 _pAblSpells; // Bitmask of abilities uint64_t _pAblSpells; // Bitmask of abilities
Uint64 _pScrlSpells; // Bitmask of spells available via scrolls uint64_t _pScrlSpells; // Bitmask of spells available via scrolls
Uint8 _pSpellFlags; uint8_t _pSpellFlags;
spell_id _pSplHotKey[4]; spell_id _pSplHotKey[4];
spell_type _pSplTHotKey[4]; spell_type _pSplTHotKey[4];
player_weapon_type _pwtype; player_weapon_type _pwtype;
bool _pBlockFlag; bool _pBlockFlag;
bool _pInvincible; bool _pInvincible;
Sint8 _pLightRad; int8_t _pLightRad;
bool _pLvlChanging; // True when the player is transitioning between levels bool _pLvlChanging; // True when the player is transitioning between levels
char _pName[PLR_NAME_LEN]; char _pName[PLR_NAME_LEN];
HeroClass _pClass; HeroClass _pClass;
Sint32 _pStrength; int _pStrength;
Sint32 _pBaseStr; int _pBaseStr;
Sint32 _pMagic; int _pMagic;
Sint32 _pBaseMag; int _pBaseMag;
Sint32 _pDexterity; int _pDexterity;
Sint32 _pBaseDex; int _pBaseDex;
Sint32 _pVitality; int _pVitality;
Sint32 _pBaseVit; int _pBaseVit;
Sint32 _pStatPts; int _pStatPts;
Sint32 _pDamageMod; int _pDamageMod;
Sint32 _pBaseToBlk; int _pBaseToBlk;
Sint32 _pHPBase; int _pHPBase;
Sint32 _pMaxHPBase; int _pMaxHPBase;
Sint32 _pHitPoints; int _pHitPoints;
Sint32 _pMaxHP; int _pMaxHP;
Sint32 _pHPPer; int _pHPPer;
Sint32 _pManaBase; int _pManaBase;
Sint32 _pMaxManaBase; int _pMaxManaBase;
Sint32 _pMana; int _pMana;
Sint32 _pMaxMana; int _pMaxMana;
Sint32 _pManaPer; int _pManaPer;
Sint8 _pLevel; int8_t _pLevel;
Sint8 _pMaxLvl; int8_t _pMaxLvl;
Sint32 _pExperience; int _pExperience;
Sint32 _pMaxExp; int _pMaxExp;
Sint32 _pNextExper; int _pNextExper;
Sint8 _pArmorClass; int8_t _pArmorClass;
Sint8 _pMagResist; int8_t _pMagResist;
Sint8 _pFireResist; int8_t _pFireResist;
Sint8 _pLghtResist; int8_t _pLghtResist;
Sint32 _pGold; int _pGold;
bool _pInfraFlag; bool _pInfraFlag;
Sint32 _pVar1; // Used for referring to X-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks) int _pVar1; // Used for referring to X-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
Sint32 _pVar2; // Used for referring to Y-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks) int _pVar2; // Used for referring to Y-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
direction _pVar3; // Player's direction when ending movement. Also used for casting direction of SPL_FIREWALL. direction _pVar3; // Player's direction when ending movement. Also used for casting direction of SPL_FIREWALL.
Sint32 _pVar4; // Used for storing X-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it) int _pVar4; // Used for storing X-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
Sint32 _pVar5; // Used for storing Y-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it) int _pVar5; // Used for storing Y-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
Sint32 _pVar6; // Same as _pxoff but contains the value in a higher range int _pVar6; // Same as _pxoff but contains the value in a higher range
Sint32 _pVar7; // Same as _pyoff but contains the value in a higher range int _pVar7; // Same as _pyoff but contains the value in a higher range
Sint32 _pVar8; // Used for counting how close we are to reaching the next tile when walking (usually counts to 8, which is equal to the walk animation length). Also used for stalling the appearance of the options screen after dying in singleplayer int _pVar8; // Used for counting how close we are to reaching the next tile when walking (usually counts to 8, which is equal to the walk animation length). Also used for stalling the appearance of the options screen after dying in singleplayer
bool _pLvlVisited[NUMLEVELS]; bool _pLvlVisited[NUMLEVELS];
bool _pSLvlVisited[NUMLEVELS]; // only 10 used bool _pSLvlVisited[NUMLEVELS]; // only 10 used
/** Using player_graphic as bitflags */ /** Using player_graphic as bitflags */
Sint32 _pGFXLoad; int _pGFXLoad;
Uint8 *_pNAnim[8]; // Stand animations uint8_t *_pNAnim[8]; // Stand animations
Sint32 _pNFrames; int _pNFrames;
Sint32 _pNWidth; int _pNWidth;
Uint8 *_pWAnim[8]; // Walk animations uint8_t *_pWAnim[8]; // Walk animations
Sint32 _pWFrames; int _pWFrames;
Sint32 _pWWidth; int _pWWidth;
Uint8 *_pAAnim[8]; // Attack animations uint8_t *_pAAnim[8]; // Attack animations
Sint32 _pAFrames; int _pAFrames;
Sint32 _pAWidth; int _pAWidth;
Sint32 _pAFNum; int _pAFNum;
Uint8 *_pLAnim[8]; // Lightning spell cast animations uint8_t *_pLAnim[8]; // Lightning spell cast animations
Uint8 *_pFAnim[8]; // Fire spell cast animations uint8_t *_pFAnim[8]; // Fire spell cast animations
Uint8 *_pTAnim[8]; // Generic spell cast animations uint8_t *_pTAnim[8]; // Generic spell cast animations
Sint32 _pSFrames; int _pSFrames;
Sint32 _pSWidth; int _pSWidth;
Sint32 _pSFNum; int _pSFNum;
Uint8 *_pHAnim[8]; // Getting hit animations uint8_t *_pHAnim[8]; // Getting hit animations
Sint32 _pHFrames; int _pHFrames;
Sint32 _pHWidth; int _pHWidth;
Uint8 *_pDAnim[8]; // Death animations uint8_t *_pDAnim[8]; // Death animations
Sint32 _pDFrames; int _pDFrames;
Sint32 _pDWidth; int _pDWidth;
Uint8 *_pBAnim[8]; // Block animations uint8_t *_pBAnim[8]; // Block animations
Sint32 _pBFrames; int _pBFrames;
Sint32 _pBWidth; int _pBWidth;
ItemStruct InvBody[NUM_INVLOC]; ItemStruct InvBody[NUM_INVLOC];
ItemStruct InvList[NUM_INV_GRID_ELEM]; ItemStruct InvList[NUM_INV_GRID_ELEM];
Sint32 _pNumInv; int _pNumInv;
int8_t InvGrid[NUM_INV_GRID_ELEM]; int8_t InvGrid[NUM_INV_GRID_ELEM];
ItemStruct SpdList[MAXBELTITEMS]; ItemStruct SpdList[MAXBELTITEMS];
ItemStruct HoldItem; ItemStruct HoldItem;
Sint32 _pIMinDam; int _pIMinDam;
Sint32 _pIMaxDam; int _pIMaxDam;
Sint32 _pIAC; int _pIAC;
Sint32 _pIBonusDam; int _pIBonusDam;
Sint32 _pIBonusToHit; int _pIBonusToHit;
Sint32 _pIBonusAC; int _pIBonusAC;
Sint32 _pIBonusDamMod; int _pIBonusDamMod;
/** Bitmask of staff spell */ /** Bitmask of staff spell */
Uint64 _pISpells; uint64_t _pISpells;
/** Bitmask using item_special_effect */ /** Bitmask using item_special_effect */
Sint32 _pIFlags; int _pIFlags;
Sint32 _pIGetHit; int _pIGetHit;
Sint8 _pISplLvlAdd; int8_t _pISplLvlAdd;
Sint32 _pISplDur; int _pISplDur;
Sint32 _pIEnAc; int _pIEnAc;
Sint32 _pIFMinDam; int _pIFMinDam;
Sint32 _pIFMaxDam; int _pIFMaxDam;
Sint32 _pILMinDam; int _pILMinDam;
Sint32 _pILMaxDam; int _pILMaxDam;
item_misc_id _pOilType; item_misc_id _pOilType;
Uint8 pTownWarps; uint8_t pTownWarps;
Uint8 pDungMsgs; uint8_t pDungMsgs;
Uint8 pLvlLoad; uint8_t pLvlLoad;
bool pBattleNet; bool pBattleNet;
bool pManaShield; bool pManaShield;
Uint8 pDungMsgs2; uint8_t pDungMsgs2;
bool pOriginalCathedral; bool pOriginalCathedral;
Uint16 wReflections; uint16_t wReflections;
uint32_t pDiabloKillLevel; uint8_t pDiabloKillLevel;
_difficulty pDifficulty; _difficulty pDifficulty;
Uint32 pDamAcFlags; uint32_t pDamAcFlags;
Uint8 *_pNData; uint8_t *_pNData;
Uint8 *_pWData; uint8_t *_pWData;
Uint8 *_pAData; uint8_t *_pAData;
Uint8 *_pLData; uint8_t *_pLData;
Uint8 *_pFData; uint8_t *_pFData;
Uint8 *_pTData; uint8_t *_pTData;
Uint8 *_pHData; uint8_t *_pHData;
Uint8 *_pDData; uint8_t *_pDData;
Uint8 *_pBData; uint8_t *_pBData;
/** /**
* @brief Gets the most valuable item out of all the player's items that match the given predicate. * @brief Gets the most valuable item out of all the player's items that match the given predicate.
@ -358,14 +358,14 @@ struct PlayerStruct {
* @param attribute The attribute to retrieve the base value for * @param attribute The attribute to retrieve the base value for
* @return The base value for the requested attribute. * @return The base value for the requested attribute.
*/ */
Sint32 GetBaseAttributeValue(CharacterAttribute attribute) const; int GetBaseAttributeValue(CharacterAttribute attribute) const;
/** /**
* @brief Gets the maximum value of the player's specified attribute. * @brief Gets the maximum value of the player's specified attribute.
* @param attribute The attribute to retrieve the maximum value for * @param attribute The attribute to retrieve the maximum value for
* @return The maximum value for the requested attribute. * @return The maximum value for the requested attribute.
*/ */
Sint32 GetMaximumAttributeValue(CharacterAttribute attribute) const; int GetMaximumAttributeValue(CharacterAttribute attribute) const;
}; };
extern int myplr; extern int myplr;
@ -397,7 +397,7 @@ void ProcessPlayerAnimation(int pnum);
* @param pPlayer Player * @param pPlayer Player
* @return The Frame to use for rendering * @return The Frame to use for rendering
*/ */
Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer); int GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer);
void CreatePlayer(int pnum, HeroClass c); void CreatePlayer(int pnum, HeroClass c);
int CalcStatDiff(int pnum); int CalcStatDiff(int pnum);
#ifdef _DEBUG #ifdef _DEBUG

Loading…
Cancel
Save