Browse Source

♻️ Use explicit types and remove globals from save file logic

pull/1146/head
Anders Jenbo 5 years ago
parent
commit
1284333765
  1. 2
      Source/inv.cpp
  2. 2
      Source/items.h
  3. 7
      Source/lighting.h
  4. 2940
      Source/loadsave.cpp
  5. 2
      Source/loadsave.h
  6. 2
      Source/missiles.h
  7. 1
      Source/monster.cpp
  8. 2
      Source/mpqapi.cpp
  9. 4
      Source/pack.h
  10. 2
      Source/pfile.cpp
  11. 7
      Source/player.h
  12. 13
      structs.h

2
Source/inv.cpp

@ -1867,7 +1867,7 @@ void CleanupItems(int ii)
if (currlevel == 21 & item[ii]._ix == CornerStone.x && item[ii]._iy == CornerStone.y) {
CornerStone.item.IDidx = -1;
CornerStone.item._itype = ITYPE_MISC;
CornerStone.item._iSelFlag = FALSE;
CornerStone.item._iSelFlag = 0;
CornerStone.item._ix = 0;
CornerStone.item._iy = 0;
CornerStone.item._iAnimFlag = FALSE;

2
Source/items.h

@ -66,7 +66,7 @@ typedef struct ItemStruct {
Sint32 _iAnimWidth;
Sint32 _iAnimWidth2; // width 2?
bool _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02
Sint8 _iSelFlag;
Uint8 _iSelFlag;
bool _iPostDraw;
bool _iIdentified;
Sint8 _iMagical;

7
Source/lighting.h

@ -17,15 +17,14 @@ typedef struct LightListStruct {
int _ly;
int _lradius;
int _lid;
int _ldel;
int _lunflag;
int field_18;
bool _ldel;
bool _lunflag;
int _lunx;
int _luny;
int _lunr;
int _xoff;
int _yoff;
int _lflags;
bool _lflags;
} LightListStruct;
extern LightListStruct VisionList[MAXVISION];

2940
Source/loadsave.cpp

File diff suppressed because it is too large Load Diff

2
Source/loadsave.h

@ -17,7 +17,7 @@ extern int giNumberOfLevels;
int RemapItemIdxFromDiablo(int i);
int RemapItemIdxToDiablo(int i);
bool IsHeaderValid(int magicNumber);
bool IsHeaderValid(Uint32 magicNumber);
void LoadHotkeys();
void LoadGame(BOOL firstflag);
void SaveHotkeys();

2
Source/missiles.h

@ -70,7 +70,7 @@ typedef struct MissileStruct {
bool _miDrawFlag;
bool _miLightFlag;
bool _miPreFlag;
Sint32 _miUniqTrans;
Uint32 _miUniqTrans;
Sint32 _mirange; // Time to live for the missile in game ticks, oncs 0 the missile will be marked for deletion via _miDelFlag
Sint32 _misource;
Sint32 _micaster;

1
Source/monster.cpp

@ -495,7 +495,6 @@ void InitMonster(int i, int rd, int mtype, int x, int y)
monster[i]._mgoalvar1 = 0;
monster[i]._mgoalvar2 = 0;
monster[i]._mgoalvar3 = 0;
monster[i].field_18 = 0;
monster[i]._pathcount = 0;
monster[i]._mDelFlag = FALSE;
monster[i]._uniqtype = 0;

2
Source/mpqapi.cpp

@ -262,7 +262,7 @@ private:
_FILEHEADER fhdr;
memset(&fhdr, 0, sizeof(fhdr));
fhdr.signature = LOAD_LE32("MPQ\x1A");
fhdr.signature = SDL_SwapLE32(LOAD_LE32("MPQ\x1A"));
fhdr.headersize = SDL_SwapLE32(32);
fhdr.filesize = SDL_SwapLE32(static_cast<uint32_t>(size));
fhdr.version = SDL_SwapLE16(0);

4
Source/pack.h

@ -61,7 +61,7 @@ typedef struct PkPlayerStruct {
Sint8 pTownWarps;
Sint8 pDungMsgs;
Sint8 pLvlLoad;
Sint8 pBattleNet;
Uint8 pBattleNet;
Uint8 pManaShield;
Uint8 pDungMsgs2;
Sint8 bIsHellfire;
@ -71,7 +71,7 @@ typedef struct PkPlayerStruct {
Sint8 pSplLvl2[10]; // Hellfire spells
Sint16 wReserved8; // For future use
Uint32 pDiabloKillLevel;
Sint32 pDifficulty;
Uint32 pDifficulty;
Sint32 pDamAcFlags;
Sint32 dwReserved[5]; // For future use
} PkPlayerStruct;

2
Source/pfile.cpp

@ -299,7 +299,7 @@ BOOL pfile_archive_contains_game(HANDLE hsArchive, DWORD save_num)
if (gameData == NULL)
return FALSE;
int hdr = (gameData[0] << 24) | (gameData[1] << 16) | (gameData[2] << 8) | gameData[3];
Uint32 hdr = LOAD_LE32(gameData);
mem_free_dbg(gameData);
return IsHeaderValid(hdr);

7
Source/player.h

@ -33,7 +33,6 @@ typedef struct PlayerStruct {
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
int _pdir; // Direction faced by player (direction enum)
int _nextdir; // Unused
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)
unsigned char *_pAnimData;
int _pAnimDelay; // Tick length of each frame in the current animation
@ -171,14 +170,14 @@ typedef struct PlayerStruct {
unsigned char pTownWarps;
unsigned char pDungMsgs;
unsigned char pLvlLoad;
unsigned char pBattleNet;
bool pBattleNet;
BOOLEAN pManaShield;
unsigned char pDungMsgs2;
BOOLEAN pOriginalCathedral;
WORD wReflections;
DWORD pDiabloKillLevel;
int pDifficulty;
int pDamAcFlags;
Uint32 pDifficulty;
Uint32 pDamAcFlags;
unsigned char *_pNData;
unsigned char *_pWData;
unsigned char *_pAData;

13
structs.h

@ -107,7 +107,6 @@ typedef struct MonsterStruct { // note: missing field _mAFNum
int _mgoalvar1;
int _mgoalvar2;
int _mgoalvar3;
int field_18;
unsigned char _pathcount;
int _mx; // Tile X-position of monster
int _my; // Tile Y-position of monster
@ -123,13 +122,11 @@ typedef struct MonsterStruct { // note: missing field _mAFNum
int _menemy; // The current target of the mosnter. An index in to either the plr or monster array based on the _meflag value.
unsigned char _menemyx; // X-coordinate of enemy (usually correspond's to the enemy's futx value)
unsigned char _menemyy; // Y-coordinate of enemy (usually correspond's to the enemy's futy value)
short falign_52; // probably _mAFNum (unused)
unsigned char *_mAnimData;
int _mAnimDelay; // Tick length of each frame in the current animation
int _mAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay
int _mAnimLen; // Number of frames in current animation
int _mAnimFrame; // Current frame of animation.
BOOL _meflag;
BOOL _mDelFlag;
int _mVar1;
int _mVar2;
@ -143,15 +140,12 @@ typedef struct MonsterStruct { // note: missing field _mAFNum
int _mhitpoints;
unsigned char _mAi;
unsigned char _mint;
short falign_9A;
int _mFlags;
Uint32 _mFlags;
BYTE _msquelch;
int falign_A4;
int _lastx;
int _lasty;
int _mRndSeed;
int _mAISeed;
int falign_B8;
unsigned char _uniqtype;
unsigned char _uniqtrans;
char _udeadval;
@ -165,7 +159,6 @@ typedef struct MonsterStruct { // note: missing field _mAFNum
unsigned char mMinDamage2;
unsigned char mMaxDamage2;
unsigned char mArmorClass;
char falign_CB;
unsigned short mMagicRes;
int mtalkmsg;
unsigned char leader;
@ -222,8 +215,8 @@ typedef struct ObjectStruct {
int _otype;
int _ox;
int _oy;
int _oLight;
int _oAnimFlag;
bool _oLight;
Uint32 _oAnimFlag;
unsigned char *_oAnimData;
int _oAnimDelay; // Tick length of each frame in the current animation
int _oAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay

Loading…
Cancel
Save