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;
cineflag = true;
uint32_t *killLevel = &plr[myplr].pDiabloKillLevel;
uint32_t newKillLevel = sgGameInitInfo.nDifficulty + 1;
if (*killLevel > newKillLevel)
newKillLevel = *killLevel;
plr[myplr].pDiabloKillLevel = newKillLevel;
plr[myplr].pDiabloKillLevel = std::max(plr[myplr].pDiabloKillLevel, static_cast<uint8_t>(sgGameInitInfo.nDifficulty + 1));
for (auto &player : plr) {
player._pmode = PM_QUIT;

108
Source/pack.h

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

6
Source/player.cpp

@ -192,7 +192,7 @@ const char *const ClassPathTbl[] = {
"Warrior",
};
Sint32 PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const
int PlayerStruct::GetBaseAttributeValue(CharacterAttribute attribute) const
{
switch (attribute) {
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] = {
// 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,
// - 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];
bool plractive;
action_id destAction;
Sint32 destParam1;
Sint32 destParam2;
int destParam1;
int destParam2;
direction destParam3;
Sint32 destParam4;
Sint32 plrlevel;
Sint32 _px; // Tile X-position of player
Sint32 _py; // Tile Y-position of player
Sint32 _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
Sint32 _ptargx; // Target tile X-position for player movment. Set during pathfinding
Sint32 _ptargy; // Target tile Y-position for player movment. Set during pathfinding
Sint32 _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
Sint32 _poldx; // Most recent X-position in dPlayer.
Sint32 _poldy; // Most recent Y-position in dPlayer.
Sint32 _pxoff; // Player sprite's pixel X-offset from tile.
Sint32 _pyoff; // Player sprite's pixel Y-offset from tile.
Sint32 _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 destParam4;
int plrlevel;
int _px; // Tile X-position of player
int _py; // Tile Y-position of player
int _pfutx; // Future tile X-position of player. Set at start of walking animation
int _pfuty; // Future tile Y-position of player. Set at start of walking animation
int _ptargx; // Target tile X-position for player movment. Set during pathfinding
int _ptargy; // Target tile Y-position for player movment. Set during pathfinding
int _pownerx; // Tile X-position of player. Set via network on player input
int _pownery; // Tile X-position of player. Set via network on player input
int _poldx; // Most recent X-position in dPlayer.
int _poldy; // Most recent Y-position in dPlayer.
int _pxoff; // Player sprite's pixel X-offset from tile.
int _pyoff; // Player sprite's pixel Y-offset from tile.
int _pxvel; // Pixel X-velocity while walking. Indirectly applied to _pxoff via _pvar6
int _pyvel; // Pixel Y-velocity while walking. Indirectly applied to _pyoff via _pvar7
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)
Uint8 *_pAnimData;
Sint32 _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
Sint32 _pAnimLen; // Number of frames in current animation
Sint32 _pAnimFrame; // Current frame of animation.
Sint32 _pAnimWidth;
Sint32 _pAnimWidth2;
Sint32 _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
Sint32 _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame
Sint32 _plid;
Sint32 _pvid;
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_t *_pAnimData;
int _pAnimDelay; // Tick length of each frame in the current animation
int _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay
int _pAnimLen; // Number of frames in current animation
int _pAnimFrame; // Current frame of animation.
int _pAnimWidth;
int _pAnimWidth2;
int _pAnimNumSkippedFrames; // Number of Frames that will be skipped (for example with modifier "faster attack")
int _pAnimGameTicksSinceSequenceStarted; // Number of GameTicks after the current animation sequence started
int _pAnimStopDistributingAfterFrame; // Distribute the NumSkippedFrames only before this frame
int _plid;
int _pvid;
spell_id _pSpell;
spell_type _pSplType;
Sint8 _pSplFrom; // TODO Create enum
int8_t _pSplFrom; // TODO Create enum
spell_id _pTSpell;
spell_type _pTSplType;
spell_id _pRSpell;
@ -194,134 +194,134 @@ struct PlayerStruct {
spell_id _pSBkSpell;
spell_type _pSBkSplType;
int8_t _pSplLvl[64];
Uint64 _pMemSpells; // Bitmask of learned spells
Uint64 _pAblSpells; // Bitmask of abilities
Uint64 _pScrlSpells; // Bitmask of spells available via scrolls
Uint8 _pSpellFlags;
uint64_t _pMemSpells; // Bitmask of learned spells
uint64_t _pAblSpells; // Bitmask of abilities
uint64_t _pScrlSpells; // Bitmask of spells available via scrolls
uint8_t _pSpellFlags;
spell_id _pSplHotKey[4];
spell_type _pSplTHotKey[4];
player_weapon_type _pwtype;
bool _pBlockFlag;
bool _pInvincible;
Sint8 _pLightRad;
int8_t _pLightRad;
bool _pLvlChanging; // True when the player is transitioning between levels
char _pName[PLR_NAME_LEN];
HeroClass _pClass;
Sint32 _pStrength;
Sint32 _pBaseStr;
Sint32 _pMagic;
Sint32 _pBaseMag;
Sint32 _pDexterity;
Sint32 _pBaseDex;
Sint32 _pVitality;
Sint32 _pBaseVit;
Sint32 _pStatPts;
Sint32 _pDamageMod;
Sint32 _pBaseToBlk;
Sint32 _pHPBase;
Sint32 _pMaxHPBase;
Sint32 _pHitPoints;
Sint32 _pMaxHP;
Sint32 _pHPPer;
Sint32 _pManaBase;
Sint32 _pMaxManaBase;
Sint32 _pMana;
Sint32 _pMaxMana;
Sint32 _pManaPer;
Sint8 _pLevel;
Sint8 _pMaxLvl;
Sint32 _pExperience;
Sint32 _pMaxExp;
Sint32 _pNextExper;
Sint8 _pArmorClass;
Sint8 _pMagResist;
Sint8 _pFireResist;
Sint8 _pLghtResist;
Sint32 _pGold;
int _pStrength;
int _pBaseStr;
int _pMagic;
int _pBaseMag;
int _pDexterity;
int _pBaseDex;
int _pVitality;
int _pBaseVit;
int _pStatPts;
int _pDamageMod;
int _pBaseToBlk;
int _pHPBase;
int _pMaxHPBase;
int _pHitPoints;
int _pMaxHP;
int _pHPPer;
int _pManaBase;
int _pMaxManaBase;
int _pMana;
int _pMaxMana;
int _pManaPer;
int8_t _pLevel;
int8_t _pMaxLvl;
int _pExperience;
int _pMaxExp;
int _pNextExper;
int8_t _pArmorClass;
int8_t _pMagResist;
int8_t _pFireResist;
int8_t _pLghtResist;
int _pGold;
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)
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 _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 _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.
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)
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)
Sint32 _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
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 _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 _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 _pVar6; // Same as _pxoff but contains the value in a higher range
int _pVar7; // Same as _pyoff but contains the value in a higher range
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 _pSLvlVisited[NUMLEVELS]; // only 10 used
/** Using player_graphic as bitflags */
Sint32 _pGFXLoad;
Uint8 *_pNAnim[8]; // Stand animations
Sint32 _pNFrames;
Sint32 _pNWidth;
Uint8 *_pWAnim[8]; // Walk animations
Sint32 _pWFrames;
Sint32 _pWWidth;
Uint8 *_pAAnim[8]; // Attack animations
Sint32 _pAFrames;
Sint32 _pAWidth;
Sint32 _pAFNum;
Uint8 *_pLAnim[8]; // Lightning spell cast animations
Uint8 *_pFAnim[8]; // Fire spell cast animations
Uint8 *_pTAnim[8]; // Generic spell cast animations
Sint32 _pSFrames;
Sint32 _pSWidth;
Sint32 _pSFNum;
Uint8 *_pHAnim[8]; // Getting hit animations
Sint32 _pHFrames;
Sint32 _pHWidth;
Uint8 *_pDAnim[8]; // Death animations
Sint32 _pDFrames;
Sint32 _pDWidth;
Uint8 *_pBAnim[8]; // Block animations
Sint32 _pBFrames;
Sint32 _pBWidth;
int _pGFXLoad;
uint8_t *_pNAnim[8]; // Stand animations
int _pNFrames;
int _pNWidth;
uint8_t *_pWAnim[8]; // Walk animations
int _pWFrames;
int _pWWidth;
uint8_t *_pAAnim[8]; // Attack animations
int _pAFrames;
int _pAWidth;
int _pAFNum;
uint8_t *_pLAnim[8]; // Lightning spell cast animations
uint8_t *_pFAnim[8]; // Fire spell cast animations
uint8_t *_pTAnim[8]; // Generic spell cast animations
int _pSFrames;
int _pSWidth;
int _pSFNum;
uint8_t *_pHAnim[8]; // Getting hit animations
int _pHFrames;
int _pHWidth;
uint8_t *_pDAnim[8]; // Death animations
int _pDFrames;
int _pDWidth;
uint8_t *_pBAnim[8]; // Block animations
int _pBFrames;
int _pBWidth;
ItemStruct InvBody[NUM_INVLOC];
ItemStruct InvList[NUM_INV_GRID_ELEM];
Sint32 _pNumInv;
int _pNumInv;
int8_t InvGrid[NUM_INV_GRID_ELEM];
ItemStruct SpdList[MAXBELTITEMS];
ItemStruct HoldItem;
Sint32 _pIMinDam;
Sint32 _pIMaxDam;
Sint32 _pIAC;
Sint32 _pIBonusDam;
Sint32 _pIBonusToHit;
Sint32 _pIBonusAC;
Sint32 _pIBonusDamMod;
int _pIMinDam;
int _pIMaxDam;
int _pIAC;
int _pIBonusDam;
int _pIBonusToHit;
int _pIBonusAC;
int _pIBonusDamMod;
/** Bitmask of staff spell */
Uint64 _pISpells;
uint64_t _pISpells;
/** Bitmask using item_special_effect */
Sint32 _pIFlags;
Sint32 _pIGetHit;
Sint8 _pISplLvlAdd;
Sint32 _pISplDur;
Sint32 _pIEnAc;
Sint32 _pIFMinDam;
Sint32 _pIFMaxDam;
Sint32 _pILMinDam;
Sint32 _pILMaxDam;
int _pIFlags;
int _pIGetHit;
int8_t _pISplLvlAdd;
int _pISplDur;
int _pIEnAc;
int _pIFMinDam;
int _pIFMaxDam;
int _pILMinDam;
int _pILMaxDam;
item_misc_id _pOilType;
Uint8 pTownWarps;
Uint8 pDungMsgs;
Uint8 pLvlLoad;
uint8_t pTownWarps;
uint8_t pDungMsgs;
uint8_t pLvlLoad;
bool pBattleNet;
bool pManaShield;
Uint8 pDungMsgs2;
uint8_t pDungMsgs2;
bool pOriginalCathedral;
Uint16 wReflections;
uint32_t pDiabloKillLevel;
uint16_t wReflections;
uint8_t pDiabloKillLevel;
_difficulty pDifficulty;
Uint32 pDamAcFlags;
Uint8 *_pNData;
Uint8 *_pWData;
Uint8 *_pAData;
Uint8 *_pLData;
Uint8 *_pFData;
Uint8 *_pTData;
Uint8 *_pHData;
Uint8 *_pDData;
Uint8 *_pBData;
uint32_t pDamAcFlags;
uint8_t *_pNData;
uint8_t *_pWData;
uint8_t *_pAData;
uint8_t *_pLData;
uint8_t *_pFData;
uint8_t *_pTData;
uint8_t *_pHData;
uint8_t *_pDData;
uint8_t *_pBData;
/**
* @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
* @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.
* @param attribute The attribute to retrieve the maximum value for
* @return The maximum value for the requested attribute.
*/
Sint32 GetMaximumAttributeValue(CharacterAttribute attribute) const;
int GetMaximumAttributeValue(CharacterAttribute attribute) const;
};
extern int myplr;
@ -397,7 +397,7 @@ void ProcessPlayerAnimation(int pnum);
* @param pPlayer Player
* @return The Frame to use for rendering
*/
Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer);
int GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer);
void CreatePlayer(int pnum, HeroClass c);
int CalcStatDiff(int pnum);
#ifdef _DEBUG

Loading…
Cancel
Save