From 105a583ce06fee9dde345108e20c8e6264148027 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Wed, 17 Jul 2019 20:41:41 +0200 Subject: [PATCH] Use TRUE and FALSE enums for setlevel. Also simplify if conditions to make use of boolean values. (If the cleanup4 PR ends up increasing inserts/deletions, then this commit is probably at fault.) --- Source/diablo.cpp | 5 ++--- Source/gendung.cpp | 2 +- Source/loadsave.cpp | 2 +- Source/missiles.cpp | 2 +- Source/multi.cpp | 2 +- Source/objects.cpp | 4 ++-- Source/portal.cpp | 6 +++--- Source/trigs.cpp | 1 - 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index c5a0e3304..146cec6f4 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -376,7 +376,7 @@ void diablo_parse_flags(char *args) */ break; case 'l': - setlevel = 0; + setlevel = FALSE; leveldebug = 1; while (isspace(*args)) { args++; @@ -440,7 +440,7 @@ void diablo_parse_flags(char *args) break; case 't': leveldebug = 1; - setlevel = 1; + setlevel = TRUE; while (isspace(*args)) { args++; } @@ -1834,7 +1834,6 @@ void LoadGameLevel(BOOL firstflag, int lvldir) PlaySFX(USFX_SKING1); } // 525738: using guessed type int setseed; -// 5CF31D: using guessed type char setlevel; // 679660: using guessed type char gbMaxPlayers; void game_loop(BOOL bStartup) diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 73b089d82..35f59a5a6 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -950,6 +950,6 @@ void InitLevels() if (!leveldebug) { currlevel = 0; leveltype = DTYPE_TOWN; - setlevel = 0; + setlevel = FALSE; } } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index ad1d7fb3e..a2b51b465 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -595,7 +595,7 @@ void SaveLevel() pfile_write_save_file(szName, SaveBuff, tbuff - SaveBuff, dwLen); mem_free_dbg(SaveBuff); - if (setlevel == 0) + if (!setlevel) plr[myplr]._pLvlVisited[currlevel] = TRUE; else plr[myplr]._pSLvlVisited[setlvlnum] = TRUE; diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 9b6c695cc..b9318d248 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -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]._mirange = 2; - if (setlevel == 0 || setlvlnum != SL_VILEBETRAYER) { + if (!setlevel || setlvlnum != SL_VILEBETRAYER) { missile[mi]._mix = sx + r1; missile[mi]._miy = sy + r2; if (!mienemy) diff --git a/Source/multi.cpp b/Source/multi.cpp index 466ccd57f..844e54f3a 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -772,7 +772,7 @@ void SetupLocalCoords() if (!leveldebug || gbMaxPlayers > 1) { currlevel = 0; leveltype = DTYPE_TOWN; - setlevel = 0; + setlevel = FALSE; } x = 75; y = 68; diff --git a/Source/objects.cpp b/Source/objects.cpp index c57efcba8..4f84bad9c 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2462,7 +2462,7 @@ void OperateBook(int pnum, int i) } object[i]._oAnimFrame++; object[i]._oSelFlag = 0; - if (setlevel == 0) + if (!setlevel) return; if (setlvlnum == SL_BONECHAMB) { @@ -2485,7 +2485,7 @@ void OperateBook(int pnum, int i) 0, 0); } - if (setlevel != 0 && setlvlnum == SL_VILEBETRAYER) { + if (setlevel && setlvlnum == SL_VILEBETRAYER) { ObjChangeMapResync( object[i]._oVar1, object[i]._oVar2, diff --git a/Source/portal.cpp b/Source/portal.cpp index dfffa8872..296fea10f 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -121,19 +121,19 @@ void SetCurrentPortal(int p) void GetPortalLevel() { if (currlevel) { - setlevel = 0; + setlevel = FALSE; currlevel = 0; plr[myplr].plrlevel = 0; leveltype = DTYPE_TOWN; } else { if (portal[portalindex].setlvl) { - setlevel = 1; + setlevel = TRUE; setlvlnum = portal[portalindex].level; currlevel = portal[portalindex].level; plr[myplr].plrlevel = setlvlnum; leveltype = portal[portalindex].ltype; } else { - setlevel = 0; + setlevel = FALSE; currlevel = portal[portalindex].level; plr[myplr].plrlevel = currlevel; leveltype = portal[portalindex].ltype; diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 6928d668d..fa2249976 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -695,7 +695,6 @@ void CheckTrigForce() ClearPanel(); } } -// 5CF31D: using guessed type char setlevel; void CheckTriggers() {