Browse Source

Merge pull request #1312 from mewpull/cleanup4

Update player struct to use more booleans.
pull/197/head
Robin Eklind 7 years ago committed by GitHub
parent
commit
eaf8fbd0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      Source/diablo.cpp
  2. 2
      Source/gendung.cpp
  3. 24
      Source/items.cpp
  4. 6
      Source/loadsave.cpp
  5. 4
      Source/missiles.cpp
  6. 4
      Source/msg.cpp
  7. 4
      Source/multi.cpp
  8. 4
      Source/objects.cpp
  9. 12
      Source/player.cpp
  10. 6
      Source/portal.cpp
  11. 2
      Source/spells.cpp
  12. 1
      Source/trigs.cpp
  13. 12
      structs.h

5
Source/diablo.cpp

@ -376,7 +376,7 @@ void diablo_parse_flags(char *args)
*/ */
break; break;
case 'l': case 'l':
setlevel = 0; setlevel = FALSE;
leveldebug = 1; leveldebug = 1;
while (isspace(*args)) { while (isspace(*args)) {
args++; args++;
@ -440,7 +440,7 @@ void diablo_parse_flags(char *args)
break; break;
case 't': case 't':
leveldebug = 1; leveldebug = 1;
setlevel = 1; setlevel = TRUE;
while (isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
@ -1834,7 +1834,6 @@ void LoadGameLevel(BOOL firstflag, int lvldir)
PlaySFX(USFX_SKING1); PlaySFX(USFX_SKING1);
} }
// 525738: using guessed type int setseed; // 525738: using guessed type int setseed;
// 5CF31D: using guessed type char setlevel;
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
void game_loop(BOOL bStartup) void game_loop(BOOL bStartup)

2
Source/gendung.cpp

@ -950,6 +950,6 @@ void InitLevels()
if (!leveldebug) { if (!leveldebug) {
currlevel = 0; currlevel = 0;
leveltype = DTYPE_TOWN; leveltype = DTYPE_TOWN;
setlevel = 0; setlevel = FALSE;
} }
} }

24
Source/items.cpp

@ -510,12 +510,12 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
plr[p]._pILMaxDam = lmax; plr[p]._pILMaxDam = lmax;
if (iflgs & ISPL_INFRAVISION) { if (iflgs & ISPL_INFRAVISION) {
plr[p]._pInfraFlag = 1; plr[p]._pInfraFlag = TRUE;
} else { } else {
plr[p]._pInfraFlag = 0; plr[p]._pInfraFlag = FALSE;
} }
plr[p]._pBlockFlag = 0; plr[p]._pBlockFlag = FALSE;
plr[p]._pwtype = WT_MELEE; plr[p]._pwtype = WT_MELEE;
g = 0; g = 0;
@ -552,11 +552,11 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
} }
if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) {
plr[p]._pBlockFlag = 1; plr[p]._pBlockFlag = TRUE;
g++; g++;
} }
if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) {
plr[p]._pBlockFlag = 1; plr[p]._pBlockFlag = TRUE;
g++; g++;
} }
@ -2811,21 +2811,21 @@ void PrintItemPower(char plidx, ItemStruct *x)
strcpy(tempstr, "damages target's armor"); strcpy(tempstr, "damages target's armor");
break; break;
case IPL_FASTATTACK: case IPL_FASTATTACK:
if (x->_iFlags & 0x20000) if (x->_iFlags & ISPL_QUICKATTACK)
strcpy(tempstr, "quick attack"); strcpy(tempstr, "quick attack");
if (x->_iFlags & 0x40000) if (x->_iFlags & ISPL_FASTATTACK)
strcpy(tempstr, "fast attack"); strcpy(tempstr, "fast attack");
if (x->_iFlags & 0x80000) if (x->_iFlags & ISPL_FASTERATTACK)
strcpy(tempstr, "faster attack"); strcpy(tempstr, "faster attack");
if (x->_iFlags & 0x100000) if (x->_iFlags & ISPL_FASTESTATTACK)
strcpy(tempstr, "fastest attack"); strcpy(tempstr, "fastest attack");
break; break;
case IPL_FASTRECOVER: case IPL_FASTRECOVER:
if (x->_iFlags & 0x200000) if (x->_iFlags & ISPL_FASTRECOVER)
strcpy(tempstr, "fast hit recovery"); strcpy(tempstr, "fast hit recovery");
if (x->_iFlags & 0x400000) if (x->_iFlags & ISPL_FASTERRECOVER)
strcpy(tempstr, "faster hit recovery"); strcpy(tempstr, "faster hit recovery");
if (x->_iFlags & 0x800000) if (x->_iFlags & ISPL_FASTESTRECOVER)
strcpy(tempstr, "fastest hit recovery"); strcpy(tempstr, "fastest hit recovery");
break; break;
case IPL_FASTBLOCK: case IPL_FASTBLOCK:

6
Source/loadsave.cpp

@ -595,10 +595,10 @@ void SaveLevel()
pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen);
mem_free_dbg(SaveBuff); mem_free_dbg(SaveBuff);
if (setlevel == 0) if (!setlevel)
plr[myplr]._pLvlVisited[currlevel] = 1; plr[myplr]._pLvlVisited[currlevel] = TRUE;
else else
plr[myplr]._pSLvlVisited[setlvlnum] = 1; plr[myplr]._pSLvlVisited[setlvlnum] = TRUE;
} }
void LoadLevel() void LoadLevel()

4
Source/missiles.cpp

@ -1240,7 +1240,7 @@ void AddArrow(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i
} }
if (!mienemy) { if (!mienemy) {
av = 32; av = 32;
if (plr[id]._pIFlags & 4) { if (plr[id]._pIFlags & ISPL_RNDARROWVEL) {
av = random(64, 32) + 16; av = random(64, 32) + 16;
} }
if (plr[id]._pClass == PC_ROGUE) if (plr[id]._pClass == PC_ROGUE)
@ -1299,7 +1299,7 @@ void AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir, char mien
missile[mi]._miVar1 = 0; missile[mi]._miVar1 = 0;
missile[mi]._mirange = 2; missile[mi]._mirange = 2;
if (setlevel == 0 || setlvlnum != SL_VILEBETRAYER) { if (!setlevel || setlvlnum != SL_VILEBETRAYER) {
missile[mi]._mix = sx + r1; missile[mi]._mix = sx + r1;
missile[mi]._miy = sy + r2; missile[mi]._miy = sy + r2;
if (!mienemy) if (!mienemy)

4
Source/msg.cpp

@ -452,7 +452,7 @@ void DeltaSaveLevel()
if (i != myplr) if (i != myplr)
plr[i]._pGFXLoad = 0; plr[i]._pGFXLoad = 0;
} }
plr[myplr]._pLvlVisited[currlevel] = 1; plr[myplr]._pLvlVisited[currlevel] = TRUE;
delta_leave_sync(currlevel); delta_leave_sync(currlevel);
} }
} }
@ -2337,7 +2337,7 @@ DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum)
if (gbBufferMsgs == 1) if (gbBufferMsgs == 1)
msg_send_packet(pnum, p, sizeof(*p)); msg_send_packet(pnum, p, sizeof(*p));
else { else {
plr[pnum]._pLvlChanging = 0; plr[pnum]._pLvlChanging = FALSE;
if (plr[pnum]._pName[0] && !plr[pnum].plractive) { if (plr[pnum]._pName[0] && !plr[pnum].plractive) {
plr[pnum].plractive = TRUE; plr[pnum].plractive = TRUE;
gbActivePlayers++; gbActivePlayers++;

4
Source/multi.cpp

@ -772,7 +772,7 @@ void SetupLocalCoords()
if (!leveldebug || gbMaxPlayers > 1) { if (!leveldebug || gbMaxPlayers > 1) {
currlevel = 0; currlevel = 0;
leveltype = DTYPE_TOWN; leveltype = DTYPE_TOWN;
setlevel = 0; setlevel = FALSE;
} }
x = 75; x = 75;
y = 68; y = 68;
@ -791,7 +791,7 @@ void SetupLocalCoords()
plr[myplr]._ptargx = x; plr[myplr]._ptargx = x;
plr[myplr]._ptargy = y; plr[myplr]._ptargy = y;
plr[myplr].plrlevel = currlevel; plr[myplr].plrlevel = currlevel;
plr[myplr]._pLvlChanging = 1; plr[myplr]._pLvlChanging = TRUE;
plr[myplr].pLvlLoad = 0; plr[myplr].pLvlLoad = 0;
plr[myplr]._pmode = PM_NEWLVL; plr[myplr]._pmode = PM_NEWLVL;
plr[myplr].destAction = ACTION_NONE; plr[myplr].destAction = ACTION_NONE;

4
Source/objects.cpp

@ -2462,7 +2462,7 @@ void OperateBook(int pnum, int i)
} }
object[i]._oAnimFrame++; object[i]._oAnimFrame++;
object[i]._oSelFlag = 0; object[i]._oSelFlag = 0;
if (setlevel == 0) if (!setlevel)
return; return;
if (setlvlnum == SL_BONECHAMB) { if (setlvlnum == SL_BONECHAMB) {
@ -2485,7 +2485,7 @@ void OperateBook(int pnum, int i)
0, 0,
0); 0);
} }
if (setlevel != 0 && setlvlnum == SL_VILEBETRAYER) { if (setlevel && setlvlnum == SL_VILEBETRAYER) {
ObjChangeMapResync( ObjChangeMapResync(
object[i]._oVar1, object[i]._oVar1,
object[i]._oVar2, object[i]._oVar2,

12
Source/player.cpp

@ -590,7 +590,7 @@ void CreatePlayer(int pnum, char c)
plr[pnum]._pFireResist = 0; plr[pnum]._pFireResist = 0;
plr[pnum]._pLghtResist = 0; plr[pnum]._pLghtResist = 0;
plr[pnum]._pLightRad = 10; plr[pnum]._pLightRad = 10;
plr[pnum]._pInfraFlag = 0; plr[pnum]._pInfraFlag = FALSE;
if (c == PC_WARRIOR) { if (c == PC_WARRIOR) {
plr[pnum]._pAblSpells = (__int64)1 << (SPL_REPAIR - 1); plr[pnum]._pAblSpells = (__int64)1 << (SPL_REPAIR - 1);
@ -631,14 +631,14 @@ void CreatePlayer(int pnum, char c)
} }
for (i = 0; i < NUMLEVELS; i++) { for (i = 0; i < NUMLEVELS; i++) {
plr[pnum]._pLvlVisited[i] = 0; plr[pnum]._pLvlVisited[i] = FALSE;
} }
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
plr[pnum]._pSLvlVisited[i] = 0; plr[pnum]._pSLvlVisited[i] = FALSE;
} }
plr[pnum]._pLvlChanging = 0; plr[pnum]._pLvlChanging = FALSE;
plr[pnum].pTownWarps = 0; plr[pnum].pTownWarps = 0;
plr[pnum].pLvlLoad = 0; plr[pnum].pLvlLoad = 0;
plr[pnum].pBattleNet = 0; plr[pnum].pBattleNet = 0;
@ -1960,12 +1960,12 @@ void InitLevelChange(int pnum)
if (pnum == myplr) { if (pnum == myplr) {
dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1; dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1;
} else { } else {
plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = 1; plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = TRUE;
} }
ClrPlrPath(pnum); ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_NONE; plr[pnum].destAction = ACTION_NONE;
plr[pnum]._pLvlChanging = 1; plr[pnum]._pLvlChanging = TRUE;
if (pnum == myplr) { if (pnum == myplr) {
plr[pnum].pLvlLoad = 10; plr[pnum].pLvlLoad = 10;

6
Source/portal.cpp

@ -121,19 +121,19 @@ void SetCurrentPortal(int p)
void GetPortalLevel() void GetPortalLevel()
{ {
if (currlevel) { if (currlevel) {
setlevel = 0; setlevel = FALSE;
currlevel = 0; currlevel = 0;
plr[myplr].plrlevel = 0; plr[myplr].plrlevel = 0;
leveltype = DTYPE_TOWN; leveltype = DTYPE_TOWN;
} else { } else {
if (portal[portalindex].setlvl) { if (portal[portalindex].setlvl) {
setlevel = 1; setlevel = TRUE;
setlvlnum = portal[portalindex].level; setlvlnum = portal[portalindex].level;
currlevel = portal[portalindex].level; currlevel = portal[portalindex].level;
plr[myplr].plrlevel = setlvlnum; plr[myplr].plrlevel = setlvlnum;
leveltype = portal[portalindex].ltype; leveltype = portal[portalindex].ltype;
} else { } else {
setlevel = 0; setlevel = FALSE;
currlevel = portal[portalindex].level; currlevel = portal[portalindex].level;
plr[myplr].plrlevel = currlevel; plr[myplr].plrlevel = currlevel;
leveltype = portal[portalindex].ltype; leveltype = portal[portalindex].ltype;

2
Source/spells.cpp

@ -167,7 +167,7 @@ void DoResurrect(int pnum, int rid)
ClrPlrPath(rid); ClrPlrPath(rid);
plr[rid].destAction = ACTION_NONE; plr[rid].destAction = ACTION_NONE;
plr[rid]._pInvincible = 0; plr[rid]._pInvincible = FALSE;
PlacePlayer(rid); PlacePlayer(rid);
hp = 640; hp = 640;

1
Source/trigs.cpp

@ -695,7 +695,6 @@ void CheckTrigForce()
ClearPanel(); ClearPanel();
} }
} }
// 5CF31D: using guessed type char setlevel;
void CheckTriggers() void CheckTriggers()
{ {

12
structs.h

@ -224,10 +224,10 @@ typedef struct PlayerStruct {
int _pSplHotKey[4]; int _pSplHotKey[4];
char _pSplTHotKey[4]; char _pSplTHotKey[4];
int _pwtype; int _pwtype;
unsigned char _pBlockFlag; BOOLEAN _pBlockFlag;
unsigned char _pInvincible; BOOLEAN _pInvincible;
char _pLightRad; char _pLightRad;
unsigned char _pLvlChanging; BOOLEAN _pLvlChanging;
char _pName[PLR_NAME_LEN]; char _pName[PLR_NAME_LEN];
// plr_class enum value. // plr_class enum value.
// TODO: this could very well be `enum plr_class _pClass` // TODO: this could very well be `enum plr_class _pClass`
@ -267,7 +267,7 @@ typedef struct PlayerStruct {
char _pFireResist; char _pFireResist;
char _pLghtResist; char _pLghtResist;
int _pGold; int _pGold;
int _pInfraFlag; BOOL _pInfraFlag;
int _pVar1; int _pVar1;
int _pVar2; int _pVar2;
int _pVar3; int _pVar3;
@ -276,8 +276,8 @@ typedef struct PlayerStruct {
int _pVar6; int _pVar6;
int _pVar7; int _pVar7;
int _pVar8; int _pVar8;
unsigned char _pLvlVisited[NUMLEVELS]; BOOLEAN _pLvlVisited[NUMLEVELS];
unsigned char _pSLvlVisited[NUMLEVELS]; // only 10 used BOOLEAN _pSLvlVisited[NUMLEVELS]; // only 10 used
int _pGFXLoad; int _pGFXLoad;
unsigned char *_pNAnim[8]; unsigned char *_pNAnim[8];
int _pNFrames; int _pNFrames;

Loading…
Cancel
Save