From a32ac83090b8212c8b2c3370c4a9d910ded54f1c Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 23 Apr 2021 02:06:36 +0200 Subject: [PATCH] :art: cleanup trivial trype comparisons --- Source/diablo.cpp | 4 +- Source/drlg_l2.cpp | 8 ++-- Source/drlg_l3.cpp | 8 ++-- Source/drlg_l4.cpp | 2 +- Source/dthread.cpp | 4 +- Source/effects.cpp | 32 +++++++-------- Source/gendung.cpp | 14 +++---- Source/gendung.h | 2 +- Source/gmenu.cpp | 32 +++++++-------- Source/init.cpp | 24 +++++------ Source/interfac.cpp | 2 +- Source/inv.cpp | 6 +-- Source/items.cpp | 60 ++++++++++++++-------------- Source/missiles.cpp | 54 ++++++++++++------------- Source/movie.cpp | 6 +-- Source/movie.h | 2 +- Source/mpqapi.cpp | 4 +- Source/msg.cpp | 4 +- Source/multi.cpp | 18 ++++----- Source/multi.h | 2 +- Source/objects.cpp | 26 ++++++------ Source/pack.cpp | 2 +- Source/path.cpp | 4 +- Source/pfile.cpp | 4 +- Source/player.cpp | 80 ++++++++++++++++++------------------- Source/quests.cpp | 4 +- Source/render.cpp | 8 ++-- Source/restrict.cpp | 2 +- Source/scrollrt.cpp | 40 +++++++++---------- Source/scrollrt.h | 4 +- Source/sha.cpp | 4 +- Source/sound.cpp | 8 ++-- Source/spells.cpp | 4 +- Source/storm/storm.cpp | 34 ++++++++-------- Source/storm/storm_net.cpp | 8 ++-- Source/storm/storm_svid.cpp | 16 ++++---- Source/themes.cpp | 4 +- Source/tmsg.cpp | 6 +-- Source/towners.cpp | 55 ++++++++++++------------- Source/track.cpp | 2 +- 40 files changed, 302 insertions(+), 301 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e202745e..8e482ded 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1089,7 +1089,7 @@ static void PressKey(int vkey) return; } if (PauseMode == 2) { - if ((vkey == DVL_VK_RETURN) && (GetAsyncKeyState(DVL_VK_MENU) & 0x8000)) + if (vkey == DVL_VK_RETURN && (GetAsyncKeyState(DVL_VK_MENU) & 0x8000) != 0) dx_reinit(); return; } @@ -2066,7 +2066,7 @@ static void game_logic() } #ifdef _DEBUG - if (debug_mode_key_inverted_v && GetAsyncKeyState(DVL_VK_SHIFT) & 0x8000) { + if (debug_mode_key_inverted_v && (GetAsyncKeyState(DVL_VK_SHIFT) & 0x8000) != 0) { ScrollView(); } #endif diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index cba11b7e..22322b28 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -3047,7 +3047,7 @@ void L2LockoutFix() } i++; } - if (!doorok && !(dflags[i - 1][j] & DLRG_PROTECTED)) { + if (!doorok && (dflags[i - 1][j] & DLRG_PROTECTED) == 0) { dungeon[i - 1][j] = 5; } } @@ -3055,7 +3055,7 @@ void L2LockoutFix() } for (j = 1; j < DMAXX - 1; j++) { /* check: might be flipped */ for (i = 1; i < DMAXY - 1; i++) { - if (dflags[j][i] & DLRG_PROTECTED) { + if ((dflags[j][i] & DLRG_PROTECTED) != 0) { continue; } if ((dungeon[j][i] == 1 || dungeon[j][i] == 4) && dungeon[j - 1][i] == 3 && dungeon[j + 1][i] == 3) { @@ -3072,7 +3072,7 @@ void L2LockoutFix() } i++; } - if (!doorok && !(dflags[j][i - 1] & DLRG_PROTECTED)) { + if (!doorok && (dflags[j][i - 1] & DLRG_PROTECTED) == 0) { dungeon[j][i - 1] = 4; } } @@ -3149,7 +3149,7 @@ static void DRLG_L2(lvl_entry entry) L2DoorFix(); L2DirtFix(); - DRLG_PlaceThemeRooms(6, 10, 3, 0, 0); + DRLG_PlaceThemeRooms(6, 10, 3, 0, false); DRLG_L2PlaceRndSet(CTRDOOR1, 100); DRLG_L2PlaceRndSet(CTRDOOR2, 100); DRLG_L2PlaceRndSet(CTRDOOR3, 100); diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 48e71b6f..a4aae95d 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1439,7 +1439,7 @@ static bool DRLG_L3SpawnEdge(int x, int y, int *totarea) if (x < 0 || y < 0 || x >= DMAXX || y >= DMAXY) { return true; } - if (dungeon[x][y] & 0x80) { + if ((dungeon[x][y] & 0x80) != 0) { return false; } if (dungeon[x][y] > 15) { @@ -1489,7 +1489,7 @@ static bool DRLG_L3Spawn(int x, int y, int *totarea) if (x < 0 || y < 0 || x >= DMAXX || y >= DMAXY) { return true; } - if (dungeon[x][y] & 0x80) { + if ((dungeon[x][y] & 0x80) != 0) { return false; } if (dungeon[x][y] > 15) { @@ -1575,7 +1575,7 @@ static void DRLG_L3Pool() for (i = std::max(dunx - totarea, 0); i < std::min(dunx + totarea, DMAXX); i++) { // BUGFIX: In the following swap the order to first do the // index checks and only then access dungeon[i][j] (fixed) - if (dungeon[i][j] & 0x80) { + if ((dungeon[i][j] & 0x80) != 0) { dungeon[i][j] &= ~0x80; if (totarea > 4 && poolchance < 25 && !found) { k = poolsub[dungeon[i][j]]; @@ -2482,7 +2482,7 @@ static void DRLG_L3(lvl_entry entry) } if (currlevel < 17) - DRLG_PlaceThemeRooms(5, 10, 7, 0, 0); + DRLG_PlaceThemeRooms(5, 10, 7, 0, false); if (currlevel < 17) { DRLG_L3Wood(); diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 3ba0a428..819f699d 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1707,7 +1707,7 @@ static void DRLG_L4(lvl_entry entry) DRLG_L4GeneralFix(); if (currlevel != 16) { - DRLG_PlaceThemeRooms(7, 10, 6, 8, 1); + DRLG_PlaceThemeRooms(7, 10, 6, 8, true); } DRLG_L4Shadows(); diff --git a/Source/dthread.cpp b/Source/dthread.cpp index a467718a..85f70921 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -26,7 +26,7 @@ static unsigned int dthread_handler(void *data) DWORD dwMilliseconds; while (dthread_running) { - if (!sgpInfoHead && WaitForEvent(sghWorkToDoEvent) == -1) { + if (sgpInfoHead == nullptr && WaitForEvent(sghWorkToDoEvent) == -1) { error_buf = SDL_GetError(); app_fatal("dthread4:\n%s", error_buf); } @@ -62,7 +62,7 @@ void dthread_remove_player(uint8_t pnum) TMegaPkt *pkt; sgMemCrit.Enter(); - for (pkt = sgpInfoHead; pkt; pkt = pkt->pNext) { + for (pkt = sgpInfoHead; pkt != nullptr; pkt = pkt->pNext) { if (pkt->dwSpaceLeft == pnum) pkt->dwSpaceLeft = MAX_PLRS; } diff --git a/Source/effects.cpp b/Source/effects.cpp index 3dc353b2..d61abfd0 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1071,10 +1071,10 @@ TSFX sgSFX[] = { bool effect_is_playing(int nSFX) { TSFX *sfx = &sgSFX[nSFX]; - if (sfx->pSnd) + if (sfx->pSnd != nullptr) return snd_playing(sfx->pSnd); - if (sfx->bFlags & sfx_STREAM) + if ((sfx->bFlags & sfx_STREAM) != 0) return sfx == sgpStreamSFX; return false; @@ -1133,7 +1133,7 @@ void InitMonsterSND(int monst) strcpy(path, name); pSnd = sound_file_load(path); Monsters[monst].Snds[i][j] = pSnd; - if (!pSnd) + if (pSnd == nullptr) mem_free_dbg(path); } } @@ -1150,7 +1150,7 @@ void FreeMonsterSnd() for (j = 0; j < 4; ++j) { for (k = 0; k < 2; ++k) { pSnd = Monsters[i].Snds[j][k]; - if (pSnd) { + if (pSnd != nullptr) { Monsters[i].Snds[j][k] = nullptr; file = pSnd->sound_path; pSnd->sound_path = nullptr; @@ -1200,7 +1200,7 @@ static void PlaySFX_priv(TSFX *pSFX, bool loc, int x, int y) return; } - if (!(pSFX->bFlags & (sfx_STREAM | sfx_MISC)) && pSFX->pSnd != nullptr && snd_playing(pSFX->pSnd)) { + if ((pSFX->bFlags & (sfx_STREAM | sfx_MISC)) == 0 && pSFX->pSnd != nullptr && snd_playing(pSFX->pSnd)) { return; } @@ -1210,15 +1210,15 @@ static void PlaySFX_priv(TSFX *pSFX, bool loc, int x, int y) return; } - if (pSFX->bFlags & sfx_STREAM) { + if ((pSFX->bFlags & sfx_STREAM) != 0) { stream_play(pSFX, lVolume, lPan); return; } - if (!pSFX->pSnd) + if (pSFX->pSnd == nullptr) pSFX->pSnd = sound_file_load(pSFX->pszName); - if (pSFX->pSnd) + if (pSFX->pSnd != nullptr) snd_play_snd(pSFX->pSnd, lVolume, lPan); } @@ -1238,7 +1238,7 @@ void PlayEffect(int i, int mode) mi = monster[i]._mMTidx; snd = Monsters[mi].Snds[mode][sndIdx]; - if (!snd || snd_playing(snd)) { + if (snd == nullptr || snd_playing(snd)) { return; } @@ -1297,7 +1297,7 @@ void PlaySfxLoc(_sfx_id psfx, int x, int y, bool randomizeByCategory) if (psfx >= 0 && psfx <= 3) { pSnd = sgSFX[psfx].pSnd; - if (pSnd) + if (pSnd != nullptr) pSnd->start_tc = 0; } @@ -1325,7 +1325,7 @@ void effects_cleanup_sfx() sound_stop(); for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) { - if (sgSFX[i].pSnd) { + if (sgSFX[i].pSnd != nullptr) { sound_file_cleanup(sgSFX[i].pSnd); sgSFX[i].pSnd = nullptr; } @@ -1341,19 +1341,19 @@ static void priv_sound_init(BYTE bLoadMask) } for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) { - if (sgSFX[i].pSnd) { + if (sgSFX[i].pSnd != nullptr) { continue; } - if (sgSFX[i].bFlags & sfx_STREAM) { + if ((sgSFX[i].bFlags & sfx_STREAM) != 0) { continue; } - if (!(sgSFX[i].bFlags & bLoadMask)) { + if ((sgSFX[i].bFlags & bLoadMask) == 0) { continue; } - if (!gbIsHellfire && sgSFX[i].bFlags & sfx_HELLFIRE) { + if (!gbIsHellfire && (sgSFX[i].bFlags & sfx_HELLFIRE) != 0) { continue; } @@ -1403,7 +1403,7 @@ void effects_play_sound(const char *snd_file) } for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) { - if (!strcasecmp(sgSFX[i].pszName, snd_file) && sgSFX[i].pSnd) { + if (strcasecmp(sgSFX[i].pszName, snd_file) == 0 && sgSFX[i].pSnd != nullptr) { if (!snd_playing(sgSFX[i].pSnd)) snd_play_snd(sgSFX[i].pSnd, 0, 0); diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 67ead49c..3a168233 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -170,15 +170,15 @@ void FillSolidBlockTbls() for (i = 1; i <= dwTiles; i++) { bv = *pTmp++; - if (bv & 1) + if ((bv & 0x01) != 0) nSolidTable[i] = true; - if (bv & 2) + if ((bv & 0x02) != 0) nBlockTable[i] = true; - if (bv & 4) + if ((bv & 0x04) != 0) nMissileTable[i] = true; - if (bv & 8) + if ((bv & 0x08) != 0) nTransTable[i] = true; - if (bv & 0x80) + if ((bv & 0x80) != 0) nTrapTable[i] = true; block_lvid[i] = (bv & 0x70) >> 4; /* beta: (bv >> 4) & 7 */ } @@ -520,7 +520,7 @@ void DRLG_CreateThemeRoom(int themeIndex) } } -void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rndSize) +void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, bool rndSize) { int i, j; int themeW, themeH; @@ -530,7 +530,7 @@ void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rnd memset(themeLoc, 0, sizeof(*themeLoc)); for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { - if (dungeon[i][j] == floor && !GenerateRnd(freq) && DRLG_WillThemeRoomFit(floor, i, j, minSize, maxSize, &themeW, &themeH)) { + if (dungeon[i][j] == floor && GenerateRnd(freq) == 0 && DRLG_WillThemeRoomFit(floor, i, j, minSize, maxSize, &themeW, &themeH)) { if (rndSize) { min = minSize - 2; max = maxSize - 2; diff --git a/Source/gendung.h b/Source/gendung.h index 739d8092..f8323f20 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -178,7 +178,7 @@ void DRLG_AreaTrans(int num, BYTE *List); void DRLG_InitSetPC(); void DRLG_SetPC(); void Make_SetPC(int x, int y, int w, int h); -void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rndSize); +void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, bool rndSize); void DRLG_HoldThemeRooms(); bool SkipThemeRoom(int x, int y); void InitLevels(); diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index f578c962..7173e64b 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -71,7 +71,7 @@ void gmenu_draw_pause(const CelOutputBuffer &out) { if (currlevel != 0) RedBack(out); - if (!sgpCurrentMenu) { + if (sgpCurrentMenu == nullptr) { light_table_index = 0; gmenu_print_text(out, 252 + PANEL_LEFT, 176, "Pause"); } @@ -113,7 +113,7 @@ static void gmenu_up_down(bool isDown) { int i; - if (!sgpCurrItem) { + if (sgpCurrItem == nullptr) { return; } mouseNavigation = false; @@ -143,7 +143,7 @@ static void gmenu_left_right(bool isRight) { int step, steps; - if (!(sgpCurrItem->dwFlags & GMENU_SLIDER)) + if ((sgpCurrItem->dwFlags & GMENU_SLIDER) == 0) return; step = sgpCurrItem->dwFlags & 0xFFF; @@ -170,13 +170,13 @@ void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)()) mouseNavigation = false; sgpCurrentMenu = pItem; gmenu_current_option = gmFunc; - if (gmFunc) { + if (gmFunc != nullptr) { gmenu_current_option(); pItem = sgpCurrentMenu; } sgCurrentMenuIdx = 0; - if (sgpCurrentMenu) { - for (i = 0; sgpCurrentMenu[i].fnMenu; i++) { + if (sgpCurrentMenu != nullptr) { + for (i = 0; sgpCurrentMenu[i].fnMenu != nullptr; i++) { sgCurrentMenuIdx++; } } @@ -200,7 +200,7 @@ static int gmenu_get_lfont(TMenuItem *pItem) int i; BYTE c; - if (pItem->dwFlags & GMENU_SLIDER) + if ((pItem->dwFlags & GMENU_SLIDER) != 0) return 490; text = pItem->pszStr; i = 0; @@ -215,7 +215,7 @@ static void gmenu_draw_menu_item(const CelOutputBuffer &out, TMenuItem *pItem, i { DWORD w, x, nSteps, step, pos; w = gmenu_get_lfont(pItem); - if (pItem->dwFlags & GMENU_SLIDER) { + if ((pItem->dwFlags & GMENU_SLIDER) != 0) { x = 16 + w / 2; CelDrawTo(out, x + PANEL_LEFT, y - 10, optbar_cel, 1, 287); step = pItem->dwFlags & 0xFFF; @@ -251,9 +251,9 @@ void gmenu_draw(const CelOutputBuffer &out) TMenuItem *i; DWORD ticks; - if (sgpCurrentMenu) { + if (sgpCurrentMenu != nullptr) { GameMenuMove(); - if (gmenu_current_option) + if (gmenu_current_option != nullptr) gmenu_current_option(); if (gbIsHellfire) { ticks = SDL_GetTicks(); @@ -269,8 +269,8 @@ void gmenu_draw(const CelOutputBuffer &out) } y = 160 + UI_OFFSET_Y; i = sgpCurrentMenu; - if (sgpCurrentMenu->fnMenu) { - while (i->fnMenu) { + if (sgpCurrentMenu->fnMenu != nullptr) { + while (i->fnMenu != nullptr) { gmenu_draw_menu_item(out, i, y); i++; y += 45; @@ -281,7 +281,7 @@ void gmenu_draw(const CelOutputBuffer &out) bool gmenu_presskeys(int vkey) { - if (!sgpCurrentMenu) + if (sgpCurrentMenu == nullptr) return false; switch (vkey) { case DVL_VK_RETURN: @@ -357,7 +357,7 @@ bool gmenu_left_mouse(bool isDown) return false; } - if (!sgpCurrentMenu) { + if (sgpCurrentMenu == nullptr) { return false; } if (MouseY >= PANEL_TOP) { @@ -371,7 +371,7 @@ bool gmenu_left_mouse(bool isDown) return true; } pItem = &sgpCurrentMenu[i]; - if (!(sgpCurrentMenu[i].dwFlags & GMENU_ENABLED)) { + if ((sgpCurrentMenu[i].dwFlags & GMENU_ENABLED) == 0) { return true; } w = gmenu_get_lfont(pItem); @@ -383,7 +383,7 @@ bool gmenu_left_mouse(bool isDown) } sgpCurrItem = pItem; PlaySFX(IS_TITLEMOV); - if (pItem->dwFlags & GMENU_SLIDER) { + if ((pItem->dwFlags & GMENU_SLIDER) != 0) { mouseNavigation = gmenu_get_mouse_slider(&dummy); gmenu_on_mouse_move(); } else { diff --git a/Source/init.cpp b/Source/init.cpp index ab6c5b18..40869c1f 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -86,51 +86,51 @@ void init_cleanup() pfile_write_hero(/*write_game_data=*/false, /*clear_tables=*/true); } - if (spawn_mpq) { + if (spawn_mpq != nullptr) { SFileCloseArchive(spawn_mpq); spawn_mpq = nullptr; } - if (diabdat_mpq) { + if (diabdat_mpq != nullptr) { SFileCloseArchive(diabdat_mpq); diabdat_mpq = nullptr; } - if (patch_rt_mpq) { + if (patch_rt_mpq != nullptr) { SFileCloseArchive(patch_rt_mpq); patch_rt_mpq = nullptr; } - if (hellfire_mpq) { + if (hellfire_mpq != nullptr) { SFileCloseArchive(hellfire_mpq); hellfire_mpq = nullptr; } - if (hfmonk_mpq) { + if (hfmonk_mpq != nullptr) { SFileCloseArchive(hfmonk_mpq); hfmonk_mpq = nullptr; } - if (hfbard_mpq) { + if (hfbard_mpq != nullptr) { SFileCloseArchive(hfbard_mpq); hfbard_mpq = nullptr; } - if (hfbarb_mpq) { + if (hfbarb_mpq != nullptr) { SFileCloseArchive(hfbarb_mpq); hfbarb_mpq = nullptr; } - if (hfmusic_mpq) { + if (hfmusic_mpq != nullptr) { SFileCloseArchive(hfmusic_mpq); hfmusic_mpq = nullptr; } - if (hfvoice_mpq) { + if (hfvoice_mpq != nullptr) { SFileCloseArchive(hfvoice_mpq); hfvoice_mpq = nullptr; } - if (hfopt1_mpq) { + if (hfopt1_mpq != nullptr) { SFileCloseArchive(hfopt1_mpq); hfopt1_mpq = nullptr; } - if (hfopt2_mpq) { + if (hfopt2_mpq != nullptr) { SFileCloseArchive(hfopt2_mpq); hfopt2_mpq = nullptr; } - if (devilutionx_mpq) { + if (devilutionx_mpq != nullptr) { SFileCloseArchive(patch_rt_mpq); patch_rt_mpq = nullptr; } diff --git a/Source/interfac.cpp b/Source/interfac.cpp index d3e6dc6b..0de00e7c 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -204,7 +204,7 @@ bool IncProgress() sgdwProgress += 23; if (sgdwProgress > 534) sgdwProgress = 534; - if (sgpBackCel) + if (sgpBackCel != nullptr) DrawCutscene(); return sgdwProgress >= 534; } diff --git a/Source/inv.cpp b/Source/inv.cpp index e750c75b..bf6acee2 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1640,11 +1640,11 @@ void CheckQuestItem(int pnum) ItemStruct tmp; mask = 0; idx = plr[pnum].HoldItem.IDidx; - if (PlrHasItem(pnum, IDI_NOTE1, &n1) || idx == IDI_NOTE1) + if (PlrHasItem(pnum, IDI_NOTE1, &n1) != nullptr || idx == IDI_NOTE1) mask = 1; - if (PlrHasItem(pnum, IDI_NOTE2, &n2) || idx == IDI_NOTE2) + if (PlrHasItem(pnum, IDI_NOTE2, &n2) != nullptr || idx == IDI_NOTE2) mask |= 2; - if (PlrHasItem(pnum, IDI_NOTE3, &n3) || idx == IDI_NOTE3) + if (PlrHasItem(pnum, IDI_NOTE3, &n3) != nullptr || idx == IDI_NOTE3) mask |= 4; if (mask == 7) { plr[myplr].PlaySpeach(46, 10); diff --git a/Source/items.cpp b/Source/items.cpp index cc9f9544..ac61f58c 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -422,7 +422,7 @@ bool ItemPlace(int xp, int yp) return false; if (dObject[xp][yp] != 0) return false; - if (dFlags[xp][yp] & BFLAG_POPULATED) + if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) return false; if (nSolidTable[dPiece[xp][yp]]) return false; @@ -765,7 +765,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) lr -= plr[p]._pLevel; } - if (iflgs & ISPL_ALLRESZERO) { + if ((iflgs & ISPL_ALLRESZERO) != 0) { // reset resistances to zero if the respective special effect is active mr = 0; fr = 0; @@ -829,7 +829,7 @@ void CalcPlrItemVals(int p, bool Loadgfx) plr[p]._pILMinDam = lmin; plr[p]._pILMaxDam = lmax; - if (iflgs & ISPL_INFRAVISION) { + if ((iflgs & ISPL_INFRAVISION) != 0) { plr[p]._pInfraFlag = true; } else { plr[p]._pInfraFlag = false; @@ -2245,7 +2245,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, affix_item_type flgs, bool only } if (!control_WriteStringToBuffer((BYTE *)items[i]._iIName)) { int aii = items[i].IDidx; - if (AllItemsList[aii].iSName) + if (AllItemsList[aii].iSName != nullptr) strcpy(items[i]._iIName, AllItemsList[aii].iSName); else items[i]._iName[0] = 0; @@ -2334,7 +2334,7 @@ int RndItem(int m) if ((monster[m].MData->mTreasure & 0x8000) != 0) return -((monster[m].MData->mTreasure & 0xFFF) + 1); - if (monster[m].MData->mTreasure & 0x4000) + if ((monster[m].MData->mTreasure & 0x4000) != 0) return 0; if (GenerateRnd(100) > 40) @@ -2781,7 +2781,7 @@ void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue, bool } if ((icreateinfo & CF_UNIQUE) == 0) { - if (icreateinfo & CF_TOWN) { + if ((icreateinfo & CF_TOWN) != 0) { RecreateTownItem(ii, idx, icreateinfo, iseed); gbIsHellfire = _gbIsHellfire; return; @@ -2797,9 +2797,9 @@ void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue, bool int level = icreateinfo & CF_LEVEL; int uper = 0; - if (icreateinfo & CF_UPER1) + if ((icreateinfo & CF_UPER1) != 0) uper = 1; - if (icreateinfo & CF_UPER15) + if ((icreateinfo & CF_UPER15) != 0) uper = 15; bool onlygood = (icreateinfo & CF_ONLYGOOD) != 0; @@ -3704,36 +3704,36 @@ void PrintItemPower(char plidx, ItemStruct *x) strcpy(tempstr, "hit monster doesn't heal"); break; case IPL_STEALMANA: - if (x->_iFlags & ISPL_STEALMANA_3) + if ((x->_iFlags & ISPL_STEALMANA_3) != 0) strcpy(tempstr, "hit steals 3% mana"); - if (x->_iFlags & ISPL_STEALMANA_5) + if ((x->_iFlags & ISPL_STEALMANA_5) != 0) strcpy(tempstr, "hit steals 5% mana"); break; case IPL_STEALLIFE: - if (x->_iFlags & ISPL_STEALLIFE_3) + if ((x->_iFlags & ISPL_STEALLIFE_3) != 0) strcpy(tempstr, "hit steals 3% life"); - if (x->_iFlags & ISPL_STEALLIFE_5) + if ((x->_iFlags & ISPL_STEALLIFE_5) != 0) strcpy(tempstr, "hit steals 5% life"); break; case IPL_TARGAC: strcpy(tempstr, "penetrates target's armor"); break; case IPL_FASTATTACK: - if (x->_iFlags & ISPL_QUICKATTACK) + if ((x->_iFlags & ISPL_QUICKATTACK) != 0) strcpy(tempstr, "quick attack"); - if (x->_iFlags & ISPL_FASTATTACK) + if ((x->_iFlags & ISPL_FASTATTACK) != 0) strcpy(tempstr, "fast attack"); - if (x->_iFlags & ISPL_FASTERATTACK) + if ((x->_iFlags & ISPL_FASTERATTACK) != 0) strcpy(tempstr, "faster attack"); - if (x->_iFlags & ISPL_FASTESTATTACK) + if ((x->_iFlags & ISPL_FASTESTATTACK) != 0) strcpy(tempstr, "fastest attack"); break; case IPL_FASTRECOVER: - if (x->_iFlags & ISPL_FASTRECOVER) + if ((x->_iFlags & ISPL_FASTRECOVER) != 0) strcpy(tempstr, "fast hit recovery"); - if (x->_iFlags & ISPL_FASTERRECOVER) + if ((x->_iFlags & ISPL_FASTERRECOVER) != 0) strcpy(tempstr, "faster hit recovery"); - if (x->_iFlags & ISPL_FASTESTRECOVER) + if ((x->_iFlags & ISPL_FASTESTRECOVER) != 0) strcpy(tempstr, "fastest hit recovery"); break; case IPL_FASTBLOCK: @@ -3992,7 +3992,7 @@ void PrintItemDetails(ItemStruct *x) sprintf(tempstr, "armor: %i Dur: %i/%i", x->_iAC, x->_iDurability, x->_iMaxDur); AddPanelString(tempstr, true); } - if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { + if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges != 0) { if (x->_iMinDam == x->_iMaxDam) sprintf(tempstr, "dam: %i Dur: %i/%i", x->_iMinDam, x->_iDurability, x->_iMaxDur); else @@ -4089,7 +4089,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) l *= 2; if (plr[p]._pClass == HeroClass::Rogue || plr[p]._pClass == HeroClass::Monk || plr[p]._pClass == HeroClass::Bard) l += l / 2; - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pMana += l; if (plr[p]._pMana > plr[p]._pMaxMana) plr[p]._pMana = plr[p]._pMaxMana; @@ -4100,7 +4100,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) } break; case IMISC_FULLMANA: - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pMana = plr[p]._pMaxMana; plr[p]._pManaBase = plr[p]._pMaxManaBase; drawmanaflag = true; @@ -4148,7 +4148,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) l *= 2; if (plr[p]._pClass == HeroClass::Rogue) l += l / 2; - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pMana += l; if (plr[p]._pMana > plr[p]._pMaxMana) plr[p]._pMana = plr[p]._pMaxMana; @@ -4162,7 +4162,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) plr[p]._pHitPoints = plr[p]._pMaxHP; plr[p]._pHPBase = plr[p]._pMaxHPBase; drawhpflag = true; - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pMana = plr[p]._pMaxMana; plr[p]._pManaBase = plr[p]._pMaxManaBase; drawmanaflag = true; @@ -4206,7 +4206,7 @@ void UseItem(int p, item_misc_id Mid, spell_id spl) plr[p]._pMemSpells |= GetSpellBitmask(spl); if (plr[p]._pSplLvl[spl] < MAX_SPELL_LEVEL) plr[p]._pSplLvl[spl]++; - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pMana += spelldata[spl].sManaCost << 6; if (plr[p]._pMana > plr[p]._pMaxMana) plr[p]._pMana = plr[p]._pMaxMana; @@ -5103,15 +5103,15 @@ void RecreateHealerItem(int ii, int idx, int lvl, int iseed) void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed) { - if (icreateinfo & CF_SMITH) + if ((icreateinfo & CF_SMITH) != 0) RecreateSmithItem(ii, icreateinfo & CF_LEVEL, iseed); - else if (icreateinfo & CF_SMITHPREMIUM) + else if ((icreateinfo & CF_SMITHPREMIUM) != 0) RecreatePremiumItem(ii, icreateinfo & CF_LEVEL, iseed); - else if (icreateinfo & CF_BOY) + else if ((icreateinfo & CF_BOY) != 0) RecreateBoyItem(ii, icreateinfo & CF_LEVEL, iseed); - else if (icreateinfo & CF_WITCH) + else if ((icreateinfo & CF_WITCH) != 0) RecreateWitchItem(ii, idx, icreateinfo & CF_LEVEL, iseed); - else if (icreateinfo & CF_HEALER) + else if ((icreateinfo & CF_HEALER) != 0) RecreateHealerItem(ii, idx, icreateinfo & CF_LEVEL, iseed); } diff --git a/Source/missiles.cpp b/Source/missiles.cpp index e0b7bb00..1d5a9506 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -786,13 +786,13 @@ bool PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, bool s dam = (mind << 6) + GenerateRnd((maxd - mind + 1) << 6); if (m == -1) - if (plr[pnum]._pIFlags & ISPL_ABSHALFTRAP) + if ((plr[pnum]._pIFlags & ISPL_ABSHALFTRAP) != 0) dam /= 2; dam += (plr[pnum]._pIGetHit << 6); } else { dam = mind + GenerateRnd(maxd - mind + 1); if (m == -1) - if (plr[pnum]._pIFlags & ISPL_ABSHALFTRAP) + if ((plr[pnum]._pIFlags & ISPL_ABSHALFTRAP) != 0) dam /= 2; dam += plr[pnum]._pIGetHit; } @@ -998,7 +998,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, bool shift, int mx, int my, shift, &blocked)) { if (gbIsHellfire && blocked) { - dir = missile[i]._mimfnum + (GenerateRnd(2) ? 1 : -1); + dir = missile[i]._mimfnum + (GenerateRnd(2) != 0 ? 1 : -1); mAnimFAmt = misfiledata[missile[i]._miAnimType].mAnimFAmt; if (dir < 0) dir = mAnimFAmt - 1; @@ -1032,7 +1032,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, bool shift, int mx, int my, 0, &blocked)) { if (gbIsHellfire && blocked) { - dir = missile[i]._mimfnum + (GenerateRnd(2) ? 1 : -1); + dir = missile[i]._mimfnum + (GenerateRnd(2) != 0 ? 1 : -1); mAnimFAmt = misfiledata[missile[i]._miAnimType].mAnimFAmt; if (dir < 0) dir = mAnimFAmt - 1; @@ -1079,7 +1079,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, bool shift, int mx, int my, missile[i]._miAnimType == MFILE_FIREWAL || missile[i]._miAnimType == MFILE_LGHNING, &blocked)) { if (gbIsHellfire && blocked) { - dir = missile[i]._mimfnum + (GenerateRnd(2) ? 1 : -1); + dir = missile[i]._mimfnum + (GenerateRnd(2) != 0 ? 1 : -1); mAnimFAmt = misfiledata[missile[i]._miAnimType].mAnimFAmt; if (dir < 0) dir = mAnimFAmt - 1; @@ -1145,7 +1145,7 @@ void LoadMissileGFX(BYTE mi) return; char pszName[256]; - if (mfd->mFlags & MFLAG_ALLOW_SPECIAL) { + if ((mfd->mFlags & MFLAG_ALLOW_SPECIAL) != 0) { sprintf(pszName, "Missiles\\%s.CL2", mfd->mName); BYTE *file = LoadFileInMem(pszName, nullptr); for (unsigned i = 0; i < mfd->mAnimFAmt; i++) @@ -1168,7 +1168,7 @@ void InitMissileGFX() for (mi = 0; misfiledata[mi].mAnimFAmt; mi++) { if (!gbIsHellfire && mi > MFILE_SCBSEXPD) break; - if (!(misfiledata[mi].mFlags & MFLAG_HIDDEN)) + if ((misfiledata[mi].mFlags & MFLAG_HIDDEN) == 0) LoadMissileGFX(mi); } } @@ -1189,7 +1189,7 @@ void FreeMissileGFX(int mi) } for (i = 0; i < misfiledata[mi].mAnimFAmt; i++) { - if (misfiledata[mi].mAnimData[i]) { + if (misfiledata[mi].mAnimData[i] != nullptr) { MemFreeDbg(misfiledata[mi].mAnimData[i]); } } @@ -1518,7 +1518,7 @@ void AddStealPotions(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint ty = sy + CrawlTable[l]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) { pnum = dPlayer[tx][ty]; - if (pnum) { + if (pnum != 0) { pnum = pnum > 0 ? pnum - 1 : -(pnum + 1); hasPlayedSFX = false; @@ -1626,13 +1626,13 @@ void AddSpecArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 else if (plr[id]._pClass == HeroClass::Warrior || plr[id]._pClass == HeroClass::Bard) av += (plr[id]._pLevel - 1) / 8; - if (plr[id]._pIFlags & ISPL_QUICKATTACK) + if ((plr[id]._pIFlags & ISPL_QUICKATTACK) != 0) av++; - if (plr[id]._pIFlags & ISPL_FASTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTATTACK) != 0) av += 2; - if (plr[id]._pIFlags & ISPL_FASTERATTACK) + if ((plr[id]._pIFlags & ISPL_FASTERATTACK) != 0) av += 4; - if (plr[id]._pIFlags & ISPL_FASTESTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTESTATTACK) != 0) av += 8; } missile[mi]._mirange = 1; @@ -1933,13 +1933,13 @@ void AddLArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 mid av += (plr[id]._pLevel) / 8; if (gbIsHellfire) { - if (plr[id]._pIFlags & ISPL_QUICKATTACK) + if ((plr[id]._pIFlags & ISPL_QUICKATTACK) != 0) av++; - if (plr[id]._pIFlags & ISPL_FASTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTATTACK) != 0) av += 2; - if (plr[id]._pIFlags & ISPL_FASTERATTACK) + if ((plr[id]._pIFlags & ISPL_FASTERATTACK) != 0) av += 4; - if (plr[id]._pIFlags & ISPL_FASTESTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTESTATTACK) != 0) av += 8; } else { if (plr[id]._pClass == HeroClass::Rogue || plr[id]._pClass == HeroClass::Warrior || plr[id]._pClass == HeroClass::Bard) @@ -1967,7 +1967,7 @@ void AddArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 midi } if (mienemy == TARGET_MONSTERS) { av = 32; - if (plr[id]._pIFlags & ISPL_RNDARROWVEL) { + if ((plr[id]._pIFlags & ISPL_RNDARROWVEL) != 0) { av = GenerateRnd(32) + 16; } if (plr[id]._pClass == HeroClass::Rogue) @@ -1975,13 +1975,13 @@ void AddArrow(Sint32 mi, Sint32 sx, Sint32 sy, Sint32 dx, Sint32 dy, Sint32 midi else if (plr[id]._pClass == HeroClass::Warrior || plr[id]._pClass == HeroClass::Bard) av += (plr[id]._pLevel - 1) / 8; if (gbIsHellfire) { - if (plr[id]._pIFlags & ISPL_QUICKATTACK) + if ((plr[id]._pIFlags & ISPL_QUICKATTACK) != 0) av++; - if (plr[id]._pIFlags & ISPL_FASTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTATTACK) != 0) av += 2; - if (plr[id]._pIFlags & ISPL_FASTERATTACK) + if ((plr[id]._pIFlags & ISPL_FASTERATTACK) != 0) av += 4; - if (plr[id]._pIFlags & ISPL_FASTESTATTACK) + if ((plr[id]._pIFlags & ISPL_FASTESTATTACK) != 0) av += 8; } GetMissileVel(mi, sx, sy, dx, dy, av); @@ -3311,7 +3311,7 @@ void MI_Golem(Sint32 i) const char *ct; src = missile[i]._misource; - if (monster[src]._mx == 1 && !monster[src]._my) { + if (monster[src]._mx == 1 && monster[src]._my == 0) { for (l = 0; l < 6; l++) { k = CrawlNum[l]; tid = k + 2; @@ -4552,7 +4552,7 @@ void MI_Guardian(Sint32 i) SetMissDir(i, 1); } - if (!(missile[i]._mirange % 16)) { + if ((missile[i]._mirange % 16) == 0) { ex = 0; for (j = 0; j < 23 && ex != -1; j++) { for (k = 10; k >= 0 && ex != -1 && (vCrawlTable[j][k] != 0 || vCrawlTable[j][k + 1] != 0); k -= 2) { @@ -4852,7 +4852,7 @@ void MI_Fireman(Sint32 i) bx = missile[i]._mix; by = missile[i]._miy; enemy = monster[src]._menemy; - if (!(monster[src]._mFlags & MFLAG_TARGETS_MONSTER)) { + if ((monster[src]._mFlags & MFLAG_TARGETS_MONSTER) == 0) { cx = plr[enemy]._px; cy = plr[enemy]._py; } else { @@ -4862,7 +4862,7 @@ void MI_Fireman(Sint32 i) if ((bx != ax || by != ay) && ((missile[i]._miVar1 & 1 && (abs(ax - cx) >= 4 || abs(ay - cy) >= 4)) || missile[i]._miVar2 > 1) && PosOkMonst(missile[i]._misource, ax, ay)) { MissToMonst(i, ax, ay); missile[i]._miDelFlag = true; - } else if (!(monster[src]._mFlags & MFLAG_TARGETS_MONSTER)) { + } else if ((monster[src]._mFlags & MFLAG_TARGETS_MONSTER) == 0) { j = dPlayer[bx][by]; } else { j = dMonster[bx][by]; @@ -5378,7 +5378,7 @@ void ProcessMissiles() for (i = 0; i < nummissiles; i++) { mi = missileactive[i]; missiledata[missile[mi]._mitype].mProc(missileactive[i]); - if (!(missile[mi]._miAnimFlags & MFLAG_LOCK_ANIMATION)) { + if ((missile[mi]._miAnimFlags & MFLAG_LOCK_ANIMATION) == 0) { missile[mi]._miAnimCnt++; if (missile[mi]._miAnimCnt >= missile[mi]._miAnimDelay) { missile[mi]._miAnimCnt = 0; diff --git a/Source/movie.cpp b/Source/movie.cpp index 7a7dc07e..58ee05f1 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -13,7 +13,7 @@ namespace devilution { /** Should the movie continue playing. */ -BYTE movie_playing; +bool movie_playing; /** Should the movie play in a loop. */ bool loop_movie; @@ -33,7 +33,7 @@ void play_movie(const char *pszMovie, bool user_can_close) SVidPlayBegin(pszMovie, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); MSG Msg; - while (video_stream && movie_playing) { + while (video_stream != nullptr && movie_playing) { while (movie_playing && FetchMessage(&Msg)) { switch (Msg.message) { case DVL_WM_KEYDOWN: @@ -51,7 +51,7 @@ void play_movie(const char *pszMovie, bool user_can_close) if (!SVidPlayContinue()) break; } - if (video_stream) + if (video_stream != nullptr) SVidPlayEnd(video_stream); sound_disable_music(false); movie_playing = false; diff --git a/Source/movie.h b/Source/movie.h index af1bce6b..b3f60581 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -9,7 +9,7 @@ namespace devilution { -extern BYTE movie_playing; +extern bool movie_playing; extern bool loop_movie; void play_movie(const char *pszMovie, bool user_can_close); diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 3a158dda..d1cc1b41 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -365,7 +365,7 @@ static _BLOCKENTRY *mpqapi_new_block(int *block_index) if (blockEntry->sizefile != 0) continue; - if (block_index) + if (block_index != nullptr) *block_index = i; return blockEntry; @@ -520,7 +520,7 @@ static _BLOCKENTRY *mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int } if (i < 0) app_fatal("Out of hash space"); - if (!pBlk) + if (pBlk == nullptr) pBlk = mpqapi_new_block(&block_index); cur_archive.sgpHashTbl[hIdx].hashcheck[0] = h2; diff --git a/Source/msg.cpp b/Source/msg.cpp index 7c0a767e..31530489 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -56,7 +56,7 @@ static void msg_get_next_packet() sgpCurrPkt->dwSpaceLeft = sizeof(result->data); result = (TMegaPkt *)&sgpMegaPkt; - while (result->pNext) + while (result->pNext != nullptr) result = result->pNext; result->pNext = sgpCurrPkt; @@ -64,7 +64,7 @@ static void msg_get_next_packet() static void msg_free_packets() { - while (sgpMegaPkt) { + while (sgpMegaPkt != nullptr) { sgpCurrPkt = sgpMegaPkt->pNext; MemFreeDbg(sgpMegaPkt); sgpMegaPkt = sgpCurrPkt; diff --git a/Source/multi.cpp b/Source/multi.cpp index ac531c48..290f8e3b 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -190,7 +190,7 @@ void multi_send_msg_packet(uint32_t pmask, BYTE *src, BYTE len) pkt.hdr.wLen = t; memcpy(pkt.body, src, len); for (v = 1, p = 0; p < MAX_PLRS; p++, v <<= 1) { - if (v & pmask) { + if ((v & pmask) != 0) { if (!SNetSendMessage(p, &pkt.hdr, t) && SErrGetLastError() != STORM_ERROR_INVALID_PLAYER) { nthread_terminate_game("SNetSendMessage"); return; @@ -215,7 +215,7 @@ static void multi_handle_turn_upper_bit(int pnum) int i; for (i = 0; i < MAX_PLRS; i++) { - if (player_state[i] & PS_CONNECTED && i != pnum) + if ((player_state[i] & PS_CONNECTED) != 0 && i != pnum) break; } @@ -246,14 +246,14 @@ void multi_msg_countdown() int i; for (i = 0; i < MAX_PLRS; i++) { - if (player_state[i] & PS_TURN_ARRIVED) { + if ((player_state[i] & PS_TURN_ARRIVED) != 0) { if (gdwMsgLenTbl[i] == 4) multi_parse_turn(i, *(DWORD *)glpMsgTbl[i]); } } } -static void multi_player_left_msg(int pnum, int left) +static void multi_player_left_msg(int pnum, bool left) { const char *pszFmt; @@ -292,7 +292,7 @@ static void multi_clear_left_tbl() if (gbBufferMsgs == 1) msg_send_drop_pkt(i, sgdwPlayerLeftReasonTbl[i]); else - multi_player_left_msg(i, 1); + multi_player_left_msg(i, true); sgbPlayerLeftGameTbl[i] = false; sgdwPlayerLeftReasonTbl[i] = 0; @@ -353,11 +353,11 @@ static void multi_begin_timeout() bGroupCount = 0; for (i = 0; i < MAX_PLRS; i++) { nState = player_state[i]; - if (nState & PS_CONNECTED) { + if ((nState & PS_CONNECTED) != 0) { if (nLowestPlayer == -1) { nLowestPlayer = i; } - if (nState & PS_ACTIVE) { + if ((nState & PS_ACTIVE) != 0) { bGroupPlayers++; if (nLowestActive == -1) { nLowestActive = i; @@ -388,7 +388,7 @@ static void multi_begin_timeout() /** * @return Always true for singleplayer */ -int multi_handle_delta() +bool multi_handle_delta() { int i; bool received; @@ -858,7 +858,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv) } sgwPackPlrOffsetTbl[pnum] = 0; - multi_player_left_msg(pnum, 0); + multi_player_left_msg(pnum, false); UnPackPlayer(&netplr[pnum], pnum, true); if (!recv) { diff --git a/Source/multi.h b/Source/multi.h index b9dfe986..5b9a6571 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -54,7 +54,7 @@ void multi_send_msg_packet(uint32_t pmask, BYTE *src, BYTE len); void multi_msg_countdown(); void multi_player_left(int pnum, int reason); void multi_net_ping(); -int multi_handle_delta(); +bool multi_handle_delta(); void multi_process_network_packets(); void multi_send_zero_packet(int pnum, _cmd_id bCmd, BYTE *pbSrc, DWORD dwLen); void NetClose(); diff --git a/Source/objects.cpp b/Source/objects.cpp index f5538af3..6b56ce39 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -336,7 +336,7 @@ bool RndLocOk(int xp, int yp) return false; if (dObject[xp][yp] != 0) return false; - if (dFlags[xp][yp] & BFLAG_POPULATED) + if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) return false; if (nSolidTable[dPiece[xp][yp]]) return false; @@ -347,7 +347,7 @@ bool RndLocOk(int xp, int yp) static bool WallTrapLocOkK(int xp, int yp) { - if (dFlags[xp][yp] & BFLAG_POPULATED) + if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) return false; if (nTrapTable[dPiece[xp][yp]]) @@ -640,7 +640,7 @@ void AddL3Objs(int x1, int y1, int x2, int y2) bool TorchLocOK(int xp, int yp) { - if (dFlags[xp][yp] & BFLAG_POPULATED) + if ((dFlags[xp][yp] & BFLAG_POPULATED) != 0) return false; return true; } @@ -1282,7 +1282,7 @@ void SetupObject(int i, int x, int y, _object_id ot) } object[i]._oAnimData = pObjCels[j]; object[i]._oAnimFlag = AllObjects[ot].oAnimFlag; - if (AllObjects[ot].oAnimFlag) { + if (AllObjects[ot].oAnimFlag != 0) { object[i]._oAnimDelay = AllObjects[ot].oAnimDelay; object[i]._oAnimCnt = GenerateRnd(AllObjects[ot].oAnimDelay); object[i]._oAnimLen = AllObjects[ot].oAnimLen; @@ -3040,7 +3040,7 @@ void OperateBookLever(int pnum, int i) quests[Q_BLOOD]._qactive = QUEST_ACTIVE; quests[Q_BLOOD]._qlog = true; quests[Q_BLOOD]._qvar1 = 1; - SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, true); } object[i]._otype = object[i]._otype; if (object[i]._otype == OBJ_STEELTOME && quests[Q_WARLORD]._qvar1 == 0) { @@ -3185,7 +3185,7 @@ void OperateMushPatch(int pnum, int i) object[i]._oAnimFrame++; if (!deltaload) { GetSuperItemLoc(object[i]._ox, object[i]._oy, &x, &y); - SpawnQuestItem(IDI_MUSHROOM, x, y, 0, 0); + SpawnQuestItem(IDI_MUSHROOM, x, y, 0, false); quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; } } @@ -3212,7 +3212,7 @@ void OperateInnSignChest(int pnum, int i) object[i]._oAnimFrame += 2; if (!deltaload) { GetSuperItemLoc(object[i]._ox, object[i]._oy, &x, &y); - SpawnQuestItem(IDI_BANNER, x, y, 0, 0); + SpawnQuestItem(IDI_BANNER, x, y, 0, false); } } } @@ -3339,13 +3339,13 @@ void OperatePedistal(int pnum, int i) if (!deltaload) PlaySfxLoc(LS_PUDDLE, object[i]._ox, object[i]._oy); ObjChangeMap(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, true); } if (object[i]._oVar6 == 2) { if (!deltaload) PlaySfxLoc(LS_PUDDLE, object[i]._ox, object[i]._oy); ObjChangeMap(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); - SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, true); } if (object[i]._oVar6 == 3) { if (!deltaload) @@ -3657,14 +3657,14 @@ bool OperateShrineEnchanted(int pnum) int maxSpells = gbIsHellfire ? MAX_SPELLS : 37; Uint64 spells = plr[pnum]._pMemSpells; for (int j = 0; j < maxSpells; j++) { - if (spell & spells) + if ((spell & spells) != 0) cnt++; spell *= 2; } if (cnt > 1) { spell = 1; for (int j = SPL_FIREBOLT; j < maxSpells; j++) { // BUGFIX: < MAX_SPELLS, there is no spell with MAX_SPELLS index (fixed) - if (plr[pnum]._pMemSpells & spell) { + if ((plr[pnum]._pMemSpells & spell) != 0) { if (plr[pnum]._pSplLvl[j] < MAX_SPELL_LEVEL) plr[pnum]._pSplLvl[j]++; } @@ -4578,7 +4578,7 @@ void OperateArmorStand(int pnum, int i, bool sendmsg) object[i]._oAnimFrame++; if (!deltaload) { SetRndSeed(object[i]._oRndSeed); - uniqueRnd = GenerateRnd(2); + uniqueRnd = (GenerateRnd(2) != 0); if (currlevel <= 5) { CreateTypeItem(object[i]._ox, object[i]._oy, true, ITYPE_LARMOR, IMISC_NONE, sendmsg, false); } else if (currlevel >= 6 && currlevel <= 9) { @@ -4834,7 +4834,7 @@ void OperateLazStand(int pnum, int i) object[i]._oAnimFrame++; object[i]._oSelFlag = 0; GetSuperItemLoc(object[i]._ox, object[i]._oy, &xx, &yy); - SpawnQuestItem(IDI_LAZSTAFF, xx, yy, 0, 0); + SpawnQuestItem(IDI_LAZSTAFF, xx, yy, 0, false); } } diff --git a/Source/pack.cpp b/Source/pack.cpp index 33c3ca6e..5c345f5a 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -171,7 +171,7 @@ void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire) memset(&items[MAXITEMS], 0, sizeof(*items)); RecreateItem(MAXITEMS, idx, SDL_SwapLE16(is->iCreateInfo), SDL_SwapLE32(is->iSeed), SDL_SwapLE16(is->wValue), isHellfire); items[MAXITEMS]._iMagical = is->bId >> 1; - items[MAXITEMS]._iIdentified = is->bId & 1; + items[MAXITEMS]._iIdentified = (is->bId & 1) != 0; items[MAXITEMS]._iDurability = is->bDur; items[MAXITEMS]._iMaxDur = is->bMDur; items[MAXITEMS]._iCharges = is->bCh; diff --git a/Source/path.cpp b/Source/path.cpp index 671f4936..2a45dafa 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -74,7 +74,7 @@ int FindPath(bool (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, if (next_node->x == dx && next_node->y == dy) { current = next_node; path_length = 0; - while (current->Parent) { + while (current->Parent != nullptr) { if (path_length >= MAX_PATH_LENGTH) break; pnode_vals[path_length++] = path_directions[3 * (current->y - current->Parent->y) - current->Parent->x + 4 + current->x]; @@ -305,7 +305,7 @@ void path_next_node(PATHNODE *pPath) int f; next = path_2_nodes; - if (!path_2_nodes->NextNode) { + if (path_2_nodes->NextNode == nullptr) { path_2_nodes->NextNode = pPath; } else { current = path_2_nodes; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 305dcb40..ddb39cd8 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -124,7 +124,7 @@ static DWORD pfile_get_save_num_from_name(const char *name) DWORD i; for (i = 0; i < MAX_CHARACTERS; i++) { - if (!strcasecmp(hero_names[i], name)) + if (strcasecmp(hero_names[i], name) == 0) break; } @@ -265,7 +265,7 @@ bool pfile_ui_set_hero_infos(bool (*ui_add_hero_info)(_uiheroinfo *)) for (DWORD i = 0; i < MAX_CHARACTERS; i++) { HANDLE archive = pfile_open_save_archive(i); - if (archive) { + if (archive != nullptr) { PkPlayerStruct pkplr; if (pfile_read_hero(archive, &pkplr)) { _uiheroinfo uihero; diff --git a/Source/player.cpp b/Source/player.cpp index 7d742e09..c2410c15 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -312,7 +312,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) const char *cs = ClassPathTbl[static_cast(c)]; for (i = 1; i <= PFILE_NONDEATH; i <<= 1) { - if (!(i & gfxflag)) { + if ((i & gfxflag) == 0) { continue; } @@ -374,7 +374,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) pAnim = (BYTE *)p->_pTAnim; break; case PFILE_DEATH: - if (p->_pgfxnum & 0xF) { + if ((p->_pgfxnum & 0xF) != 0) { continue; } szCel = "DT"; @@ -923,7 +923,7 @@ void NextPlrLevel(int pnum) plr[pnum]._pMaxMana += mana; plr[pnum]._pMaxManaBase += mana; - if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { + if ((plr[pnum]._pIFlags & ISPL_NOMANA) == 0) { plr[pnum]._pMana = plr[pnum]._pMaxMana; plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; } @@ -1013,14 +1013,14 @@ void AddPlrMonstExper(int lvl, int exp, char pmask) totplrs = 0; for (i = 0; i < MAX_PLRS; i++) { - if ((1 << i) & pmask) { + if (((1 << i) & pmask) != 0) { totplrs++; } } if (totplrs) { e = exp / totplrs; - if (pmask & (1 << myplr)) + if ((pmask & (1 << myplr)) != 0) AddPlrExperience(myplr, lvl, e); } } @@ -1252,7 +1252,7 @@ void StartStand(int pnum, direction dir) } if (!plr[pnum]._pInvincible || plr[pnum]._pHitPoints != 0 || pnum != myplr) { - if (!(plr[pnum]._pGFXLoad & PFILE_STAND)) { + if ((plr[pnum]._pGFXLoad & PFILE_STAND) == 0) { LoadPlrGFX(pnum, PFILE_STAND); } @@ -1462,7 +1462,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y } //Load walk animation in case it's not loaded yet - if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + if ((plr[pnum]._pGFXLoad & PFILE_WALK) == 0) { LoadPlrGFX(pnum, PFILE_WALK); } @@ -1501,18 +1501,18 @@ void StartAttack(int pnum, direction d) return; } - if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + if ((plr[pnum]._pGFXLoad & PFILE_ATTACK) == 0) { LoadPlrGFX(pnum, PFILE_ATTACK); } int skippedAnimationFrames = 1; // Every Attack start with Frame 2. Because ProcessPlayerAnimation is called after StartAttack and its increases the AnimationFrame. - if (plr[pnum]._pIFlags & ISPL_FASTATTACK) { + if ((plr[pnum]._pIFlags & ISPL_FASTATTACK) != 0) { skippedAnimationFrames += 1; } - if (plr[pnum]._pIFlags & ISPL_FASTERATTACK) { + if ((plr[pnum]._pIFlags & ISPL_FASTERATTACK) != 0) { skippedAnimationFrames += 2; } - if (plr[pnum]._pIFlags & ISPL_FASTESTATTACK) { + if ((plr[pnum]._pIFlags & ISPL_FASTESTATTACK) != 0) { skippedAnimationFrames += 2; } @@ -1533,13 +1533,13 @@ void StartRangeAttack(int pnum, direction d, int cx, int cy) return; } - if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + if ((plr[pnum]._pGFXLoad & PFILE_ATTACK) == 0) { LoadPlrGFX(pnum, PFILE_ATTACK); } int skippedAnimationFrames = 1; // Every Attack start with Frame 2. Because ProcessPlayerAnimation is called after StartRangeAttack and its increases the AnimationFrame. if (!gbIsHellfire) { - if (plr[pnum]._pIFlags & ISPL_FASTATTACK) { + if ((plr[pnum]._pIFlags & ISPL_FASTATTACK) != 0) { skippedAnimationFrames += 1; } } @@ -1566,12 +1566,12 @@ void StartPlrBlock(int pnum, direction dir) PlaySfxLoc(IS_ISWORD, plr[pnum]._px, plr[pnum]._py); - if (!(plr[pnum]._pGFXLoad & PFILE_BLOCK)) { + if ((plr[pnum]._pGFXLoad & PFILE_BLOCK) == 0) { LoadPlrGFX(pnum, PFILE_BLOCK); } int skippedAnimationFrames = 0; // Block can start with Frame 1 if Player 2 hits Player 1. In this case Player 1 will not call again ProcessPlayerAnimation. - if (plr[pnum]._pIFlags & ISPL_FASTBLOCK) { + if ((plr[pnum]._pIFlags & ISPL_FASTBLOCK) != 0) { skippedAnimationFrames = (plr[pnum]._pBFrames - 1); // ISPL_FASTBLOCK means there is only one AnimationFrame. } @@ -1595,19 +1595,19 @@ void StartSpell(int pnum, direction d, int cx, int cy) if (leveltype != DTYPE_TOWN) { switch (spelldata[plr[pnum]._pSpell].sType) { case STYPE_FIRE: - if (!(plr[pnum]._pGFXLoad & PFILE_FIRE)) { + if ((plr[pnum]._pGFXLoad & PFILE_FIRE) == 0) { LoadPlrGFX(pnum, PFILE_FIRE); } NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, 1, true); break; case STYPE_LIGHTNING: - if (!(plr[pnum]._pGFXLoad & PFILE_LIGHTNING)) { + if ((plr[pnum]._pGFXLoad & PFILE_LIGHTNING) == 0) { LoadPlrGFX(pnum, PFILE_LIGHTNING); } NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, 1, true); break; case STYPE_MAGIC: - if (!(plr[pnum]._pGFXLoad & PFILE_MAGIC)) { + if ((plr[pnum]._pGFXLoad & PFILE_MAGIC) == 0) { LoadPlrGFX(pnum, PFILE_MAGIC); } NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, 1, true); @@ -1666,7 +1666,7 @@ void RemovePlrFromMap(int pnum) for (y = 1; y < MAXDUNY; y++) { for (x = 1; x < MAXDUNX; x++) { if (dPlayer[x][y - 1] == pn || dPlayer[x - 1][y] == pn) { - if (dFlags[x][y] & BFLAG_PLAYERLR) { + if ((dFlags[x][y] & BFLAG_PLAYERLR) != 0) { dFlags[x][y] &= ~BFLAG_PLAYERLR; } } @@ -1704,7 +1704,7 @@ void StartPlrHit(int pnum, int dam, bool forcehit) direction pd = plr[pnum]._pdir; - if (!(plr[pnum]._pGFXLoad & PFILE_HIT)) { + if ((plr[pnum]._pGFXLoad & PFILE_HIT) == 0) { LoadPlrGFX(pnum, PFILE_HIT); } @@ -1712,11 +1712,11 @@ void StartPlrHit(int pnum, int dam, bool forcehit) const int ZenFlags = ISPL_FASTRECOVER | ISPL_FASTERRECOVER | ISPL_FASTESTRECOVER; if ((plr[pnum]._pIFlags & ZenFlags) == ZenFlags) { // if multiple hitrecovery modes are present the skipping of frames can go so far, that they skip frames that would skip. so the additional skipping thats skipped. that means we can't add the different modes together. skippedAnimationFrames = 4; - } else if (plr[pnum]._pIFlags & ISPL_FASTESTRECOVER) { + } else if ((plr[pnum]._pIFlags & ISPL_FASTESTRECOVER) != 0) { skippedAnimationFrames = 3; - } else if (plr[pnum]._pIFlags & ISPL_FASTERRECOVER) { + } else if ((plr[pnum]._pIFlags & ISPL_FASTERRECOVER) != 0) { skippedAnimationFrames = 2; - } else if (plr[pnum]._pIFlags & ISPL_FASTRECOVER) { + } else if ((plr[pnum]._pIFlags & ISPL_FASTRECOVER) != 0) { skippedAnimationFrames = 1; } else { skippedAnimationFrames = 0; @@ -1820,7 +1820,7 @@ StartPlayerKill(int pnum, int earflag) SetPlrAnims(pnum); } - if (!(p->_pGFXLoad & PFILE_DEATH)) { + if ((p->_pGFXLoad & PFILE_DEATH) == 0) { LoadPlrGFX(pnum, PFILE_DEATH); } @@ -2546,7 +2546,7 @@ bool PlrHitMonst(int pnum, int m) } break; case MC_DEMON: - if (plr[pnum]._pIFlags & ISPL_3XDAMVDEM) { + if ((plr[pnum]._pIFlags & ISPL_3XDAMVDEM) != 0) { dam *= 3; } break; @@ -2561,7 +2561,7 @@ bool PlrHitMonst(int pnum, int m) } dam <<= 6; - if (plr[pnum].pDamAcFlags & 0x08) { + if ((plr[pnum].pDamAcFlags & 0x08) != 0) { int r = GenerateRnd(201); if (r >= 100) r = 100 + (r - 100) * 5; @@ -2572,7 +2572,7 @@ bool PlrHitMonst(int pnum, int m) dam >>= 2; if (pnum == myplr) { - if (plr[pnum].pDamAcFlags & 0x04) { + if ((plr[pnum].pDamAcFlags & 0x04) != 0) { dam2 += plr[pnum]._pIGetHit << 6; if (dam2 >= 0) { ApplyPlrDamage(pnum, 0, 1, dam2); @@ -2582,7 +2582,7 @@ bool PlrHitMonst(int pnum, int m) monster[m]._mhitpoints -= dam; } - if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + if ((plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) != 0) { skdam = GenerateRnd(dam / 8); plr[pnum]._pHitPoints += skdam; if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { @@ -2598,7 +2598,7 @@ bool PlrHitMonst(int pnum, int m) if (plr[pnum]._pIFlags & ISPL_STEALMANA_3) { skdam = 3 * dam / 100; } - if (plr[pnum]._pIFlags & ISPL_STEALMANA_5) { + if ((plr[pnum]._pIFlags & ISPL_STEALMANA_5) != 0) { skdam = 5 * dam / 100; } plr[pnum]._pMana += skdam; @@ -2615,7 +2615,7 @@ bool PlrHitMonst(int pnum, int m) if (plr[pnum]._pIFlags & ISPL_STEALLIFE_3) { skdam = 3 * dam / 100; } - if (plr[pnum]._pIFlags & ISPL_STEALLIFE_5) { + if ((plr[pnum]._pIFlags & ISPL_STEALLIFE_5) != 0) { skdam = 5 * dam / 100; } plr[pnum]._pHitPoints += skdam; @@ -2628,7 +2628,7 @@ bool PlrHitMonst(int pnum, int m) } drawhpflag = true; } - if (plr[pnum]._pIFlags & ISPL_NOHEALPLR) { + if ((plr[pnum]._pIFlags & ISPL_NOHEALPLR) != 0) { monster[m]._mFlags |= MFLAG_NOHEAL; } #ifdef _DEBUG @@ -2648,7 +2648,7 @@ bool PlrHitMonst(int pnum, int m) M_StartHit(m, pnum, dam); monster[m]._mmode = MM_STONE; } else { - if (plr[pnum]._pIFlags & ISPL_KNOCKBACK) { + if ((plr[pnum]._pIFlags & ISPL_KNOCKBACK) != 0) { M_GetKnockback(m); } M_StartHit(m, pnum, dam); @@ -2675,7 +2675,7 @@ bool PlrHitPlr(int pnum, int8_t p) return rv; } - if (plr[p]._pSpellFlags & 1) { + if ((plr[p]._pSpellFlags & 1) != 0) { return rv; } @@ -2730,7 +2730,7 @@ bool PlrHitPlr(int pnum, int8_t p) } } skdam = dam << 6; - if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + if ((plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) != 0) { tac = GenerateRnd(skdam / 8); plr[pnum]._pHitPoints += tac; if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { @@ -2817,7 +2817,7 @@ bool PM_DoAttack(int pnum) if (!(plr[pnum]._pIFlags & ISPL_FIREDAM) || !(plr[pnum]._pIFlags & ISPL_LIGHTDAM)) { if (plr[pnum]._pIFlags & ISPL_FIREDAM) { AddMissile(dx, dy, 1, 0, 0, MIS_WEAPEXP, TARGET_MONSTERS, pnum, 0, 0); - } else if (plr[pnum]._pIFlags & ISPL_LIGHTDAM) { + } else if ((plr[pnum]._pIFlags & ISPL_LIGHTDAM) != 0) { AddMissile(dx, dy, 2, 0, 0, MIS_WEAPEXP, TARGET_MONSTERS, pnum, 0, 0); } } @@ -2915,19 +2915,19 @@ bool PM_DoRangeAttack(int pnum) if (arrows != 1) { int angle = arrow == 0 ? -1 : 1; int x = plr[pnum]._pVar1 - plr[pnum]._px; - if (x) + if (x != 0) yoff = x < 0 ? angle : -angle; int y = plr[pnum]._pVar2 - plr[pnum]._py; - if (y) + if (y != 0) xoff = y < 0 ? -angle : angle; } int dmg = 4; mistype = MIS_ARROW; - if (plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) { + if ((plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) != 0) { mistype = MIS_FARROW; } - if (plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) { + if ((plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) != 0) { mistype = MIS_LARROW; } if ((plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) != 0 && (plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) != 0) { @@ -4144,7 +4144,7 @@ void ModifyPlrMag(int p, int l) plr[p]._pMaxManaBase += ms; plr[p]._pMaxMana += ms; - if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + if ((plr[p]._pIFlags & ISPL_NOMANA) == 0) { plr[p]._pManaBase += ms; plr[p]._pMana += ms; } diff --git a/Source/quests.cpp b/Source/quests.cpp index ca565466..8ef1cfb9 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -694,7 +694,7 @@ void ResyncQuests() } if (currlevel == quests[Q_MUSHROOM]._qlevel) { if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && quests[Q_MUSHROOM]._qvar1 == QS_INIT) { - SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); + SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, true); quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED; } else { if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { @@ -709,7 +709,7 @@ void ResyncQuests() } if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && quests[Q_VEIL]._qvar1 == 0) { quests[Q_VEIL]._qvar1 = 1; - SpawnQuestItem(IDI_GLDNELIX, 0, 0, 5, 1); + SpawnQuestItem(IDI_GLDNELIX, 0, 0, 5, true); } if (setlevel && setlvlnum == SL_VILEBETRAYER) { if (quests[Q_BETRAYER]._qvar1 >= 4) diff --git a/Source/render.cpp b/Source/render.cpp index 76be0dc7..e4fdfebe 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -402,21 +402,21 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, size_t n, BYTE *tbl, DWORD mask) if (sgOptions.Graphics.bBlendedTransparancy) { // Blended transparancy if (light_table_index == lightmax) { // Complete darkness for (size_t i = 0; i < n; i++, mask <<= 1) { - if (mask & 0x80000000) + if ((mask & 0x80000000) != 0) dst[i] = 0; else dst[i] = paletteTransparencyLookup[0][dst[i]]; } } else if (light_table_index == 0) { // Fully lit for (size_t i = 0; i < n; i++, mask <<= 1) { - if (mask & 0x80000000) + if ((mask & 0x80000000) != 0) dst[i] = src[i]; else dst[i] = paletteTransparencyLookup[dst[i]][src[i]]; } } else { // Partially lit for (size_t i = 0; i < n; i++, mask <<= 1) { - if (mask & 0x80000000) + if ((mask & 0x80000000) != 0) dst[i] = tbl[src[i]]; else dst[i] = paletteTransparencyLookup[dst[i]][tbl[src[i]]]; @@ -518,7 +518,7 @@ RenderTile(CelOutputBuffer out, int x, int y) } #ifdef _DEBUG - if (GetAsyncKeyState(DVL_VK_MENU) & 0x8000) { + if ((GetAsyncKeyState(DVL_VK_MENU) & 0x8000) != 0) { mask = &SolidMask[TILE_HEIGHT - 1]; } #endif diff --git a/Source/restrict.cpp b/Source/restrict.cpp index ceff13ac..8dbd7dd1 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -17,7 +17,7 @@ void ReadOnlyTest() { const std::string path = GetPrefPath() + "Diablo1ReadOnlyTest.foo"; FILE *f = fopen(path.c_str(), "wt"); - if (!f) { + if (f == nullptr) { DirErrorDlg(GetPrefPath().c_str()); } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 38eceb33..5cc6efd3 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -60,11 +60,11 @@ char arch_draw_type; /** * Specifies whether transparency is active for the current CEL file being decoded. */ -int cel_transparency_active; +bool cel_transparency_active; /** * Specifies whether foliage (tile has extra content that overlaps previous tile) being rendered. */ -int cel_foliage_active = false; +bool cel_foliage_active = false; /** * Specifies the current dungeon piece ID of the level, as used during rendering of the level tiles. */ @@ -290,7 +290,7 @@ void DrawMissile(const CelOutputBuffer &out, int x, int y, int sx, int sy, bool int i; MissileStruct *m; - if (!(dFlags[x][y] & BFLAG_MISSILE)) + if ((dFlags[x][y] & BFLAG_MISSILE) == 0) return; if (dMissile[x][y] != -1) { @@ -346,7 +346,7 @@ static void DrawMonster(const CelOutputBuffer &out, int x, int y, int mx, int my return; } - if (!(dFlags[x][y] & BFLAG_LIT)) { + if ((dFlags[x][y] & BFLAG_LIT) == 0) { Cl2DrawLightTbl(out, mx, my, monster[m]._mAnimData, monster[m]._mAnimFrame, monster[m].MType->width, 1); return; } @@ -591,7 +591,7 @@ static void drawCell(const CelOutputBuffer &out, int x, int y, int sx, int sy) */ static void drawFloor(const CelOutputBuffer &out, int x, int y, int sx, int sy) { - cel_transparency_active = 0; + cel_transparency_active = false; light_table_index = dLight[x][y]; arch_draw_type = 1; // Left @@ -682,7 +682,7 @@ static void DrawMonsterHelper(const CelOutputBuffer &out, int x, int y, int oy, } pMonster = &monster[mi]; - if (pMonster->_mFlags & MFLAG_HIDDEN) { + if ((pMonster->_mFlags & MFLAG_HIDDEN) != 0) { return; } @@ -787,14 +787,14 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in } DrawObject(out, sx, sy, dx, dy, true); DrawItem(out, sx, sy, dx, dy, true); - if (bFlag & BFLAG_PLAYERLR) { + if ((bFlag & BFLAG_PLAYERLR) != 0) { assert((DWORD)(sy - 1) < MAXDUNY); DrawPlayerHelper(out, sx, sy - 1, dx, dy); } if (bFlag & BFLAG_MONSTLR && negMon < 0) { DrawMonsterHelper(out, sx, sy, -1, dx, dy); } - if (bFlag & BFLAG_DEAD_PLAYER) { + if ((bFlag & BFLAG_DEAD_PLAYER) != 0) { DrawDeadPlayer(out, sx, sy, dx, dy); } if (dPlayer[sx][sy] > 0) { @@ -812,13 +812,13 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in if (bArch != 0) { cel_transparency_active = TransList[bMap]; #ifdef _DEBUG - if (GetAsyncKeyState(DVL_VK_MENU) & 0x8000) { - cel_transparency_active = 0; // Turn transparency off here for debugging + if ((GetAsyncKeyState(DVL_VK_MENU) & 0x8000) != 0) { + cel_transparency_active = false; // Turn transparency off here for debugging } #endif CelClippedBlitLightTransTo(out, dx, dy, pSpecialCels, bArch, 64); #ifdef _DEBUG - if (GetAsyncKeyState(DVL_VK_MENU) & 0x8000) { + if ((GetAsyncKeyState(DVL_VK_MENU) & 0x8000) != 0) { cel_transparency_active = TransList[bMap]; // Turn transparency back to its normal state } #endif @@ -870,7 +870,7 @@ static void scrollrt_drawFloor(const CelOutputBuffer &out, int x, int y, int sx, // Jump to next row sy += TILE_HEIGHT / 2; - if (i & 1) { + if ((i & 1) != 0) { x++; columns--; sx += TILE_WIDTH / 2; @@ -928,7 +928,7 @@ static void scrollrt_draw(const CelOutputBuffer &out, int x, int y, int sx, int // Jump to next row sy += TILE_HEIGHT / 2; - if (i & 1) { + if ((i & 1) != 0) { x++; columns--; sx += TILE_WIDTH / 2; @@ -1058,21 +1058,21 @@ void CalcTileOffset(int *offsetX, int *offsetY) void TilesInView(int *rcolumns, int *rrows) { int columns = gnScreenWidth / TILE_WIDTH; - if (gnScreenWidth % TILE_WIDTH) { + if ((gnScreenWidth % TILE_WIDTH) != 0) { columns++; } int rows = gnViewportHeight / TILE_HEIGHT; - if (gnViewportHeight % TILE_HEIGHT) { + if ((gnViewportHeight % TILE_HEIGHT) != 0) { rows++; } if (!zoomflag) { // Half the number of tiles, rounded up - if (columns & 1) { + if ((columns & 1) != 0) { columns++; } columns /= 2; - if (rows & 1) { + if ((rows & 1) != 0) { rows++; } rows /= 2; @@ -1116,7 +1116,7 @@ void CalcViewportGeometry() tileRows++; tileOffsetY -= TILE_HEIGHT / 2; } - } else if (tileColums & 1 && lrow & 1) { + } else if ((tileColums & 1) != 0 && (lrow & 1) != 0) { // Offset tile to vertically align the player when both rows and colums are odd ShiftGrid(&tileShiftX, &tileShiftY, 0, -1); tileRows++; @@ -1283,7 +1283,7 @@ void DrawView(const CelOutputBuffer &out, int StartX, int StartY) if (helpflag) { DrawHelp(out); } - if (msgflag) { + if (msgflag != EMSG_NONE) { DrawDiabloMsg(out); } if (deathflag) { @@ -1423,7 +1423,7 @@ static void DrawFPS(const CelOutputBuffer &out) DWORD tc, frames; char String[12]; - if (frameflag && gbActive && pPanelText) { + if (frameflag && gbActive && pPanelText != nullptr) { frameend++; tc = SDL_GetTicks(); frames = tc - framestart; diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 9ad2e072..84f8688b 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -33,8 +33,8 @@ extern bool IsMovingMouseCursorWithController(); extern int light_table_index; extern DWORD level_cel_block; extern char arch_draw_type; -extern int cel_transparency_active; -extern int cel_foliage_active; +extern bool cel_transparency_active; +extern bool cel_foliage_active; extern int level_piece_id; extern bool AutoMapShowItems; diff --git a/Source/sha.cpp b/Source/sha.cpp index ddb9418c..050192bb 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -140,7 +140,7 @@ void SHA1Result(int n, char Message_Digest[SHA1HashSize]) int i; Message_Digest_Block = (DWORD *)Message_Digest; - if (Message_Digest) { + if (Message_Digest != nullptr) { for (i = 0; i < 5; i++) { *Message_Digest_Block = SDL_SwapLE32(sgSHA1[n].state[i]); Message_Digest_Block++; @@ -151,7 +151,7 @@ void SHA1Result(int n, char Message_Digest[SHA1HashSize]) void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]) { SHA1Input(&sgSHA1[n], data, 64); - if (Message_Digest) + if (Message_Digest != nullptr) SHA1Result(n, Message_Digest); } diff --git a/Source/sound.cpp b/Source/sound.cpp index 182b5a6a..c0ff02e2 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -89,7 +89,7 @@ void snd_play_snd(TSnd *pSnd, int lVolume, int lPan) SoundSample *DSB; DWORD tc; - if (!pSnd || !gbSoundOn) { + if (pSnd == nullptr || !gbSoundOn) { return; } @@ -147,8 +147,8 @@ TSnd *sound_file_load(const char *path, bool stream) void sound_file_cleanup(TSnd *sound_file) { - if (sound_file) { - if (sound_file->DSB) { + if (sound_file != nullptr) { + if (sound_file->DSB != nullptr) { sound_file->DSB->Stop(); sound_file->DSB->Release(); delete sound_file->DSB; @@ -205,7 +205,7 @@ void music_start(uint8_t nTrack) assert((DWORD)nTrack < NUM_MUSIC); music_stop(); if (gbMusicOn) { - if (spawn_mpq) + if (spawn_mpq != nullptr) trackPath = sgszSpawnMusicTracks[nTrack]; else trackPath = sgszMusicTracks[nTrack]; diff --git a/Source/spells.cpp b/Source/spells.cpp index 7c2fca8f..9ba7604e 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -121,10 +121,10 @@ bool IsReadiedSpellValid(const PlayerStruct &player) return true; case RSPLTYPE_CHARGES: - return player._pISpells & GetSpellBitmask(player._pRSpell); + return (player._pISpells & GetSpellBitmask(player._pRSpell)) != 0; case RSPLTYPE_SCROLL: - return player._pScrlSpells & GetSpellBitmask(player._pRSpell); + return (player._pScrlSpells & GetSpellBitmask(player._pRSpell)) != 0; default: return false; diff --git a/Source/storm/storm.cpp b/Source/storm/storm.cpp index a70dadf8..ee5fb9dd 100644 --- a/Source/storm/storm.cpp +++ b/Source/storm/storm.cpp @@ -119,7 +119,7 @@ bool SFileOpenFile(const char *filename, HANDLE *phFile) result = SFileOpenFileEx((HANDLE)diabdat_mpq, filename, SFILE_OPEN_FROM_MPQ, phFile); } - if (!result || !*phFile) { + if (!result || (*phFile == nullptr)) { SDL_Log("%s: Not found: %s", __FUNCTION__, filename); } return result; @@ -134,11 +134,11 @@ bool SBmpLoadImage(const char *pszFileName, SDL_Color *pPalette, BYTE *pBuffer, BYTE *dataPtr, *fileBuffer; BYTE byte; - if (pdwWidth) + if (pdwWidth != nullptr) *pdwWidth = 0; - if (dwHeight) + if (dwHeight != nullptr) *dwHeight = 0; - if (pdwBpp) + if (pdwBpp != nullptr) *pdwBpp = 0; if (!pszFileName || !*pszFileName) { @@ -157,10 +157,10 @@ bool SBmpLoadImage(const char *pszFileName, SDL_Color *pPalette, BYTE *pBuffer, return false; } - while (strchr(pszFileName, 92)) + while (strchr(pszFileName, 92) != nullptr) pszFileName = strchr(pszFileName, 92) + 1; - while (strchr(pszFileName + 1, 46)) + while (strchr(pszFileName + 1, 46) != nullptr) pszFileName = strchr(pszFileName, 46); // omit all types except PCX @@ -183,14 +183,14 @@ bool SBmpLoadImage(const char *pszFileName, SDL_Color *pPalette, BYTE *pBuffer, // than image width for efficiency. const int xSkip = dwBuffersize / height - width; - if (pdwWidth) + if (pdwWidth != nullptr) *pdwWidth = width; - if (dwHeight) + if (dwHeight != nullptr) *dwHeight = height; - if (pdwBpp) + if (pdwBpp != nullptr) *pdwBpp = pcxhdr.BitsPerPixel; - if (!pBuffer) { + if (pBuffer == nullptr) { SFileSetFilePointer(hFile, 0, nullptr, DVL_FILE_END); fileBuffer = nullptr; } else { @@ -201,7 +201,7 @@ bool SBmpLoadImage(const char *pszFileName, SDL_Color *pPalette, BYTE *pBuffer, fileBuffer = (BYTE *)malloc(size); } - if (fileBuffer) { + if (fileBuffer != nullptr) { SFileReadFile(hFile, fileBuffer, size, nullptr, nullptr); dataPtr = fileBuffer; @@ -264,11 +264,11 @@ bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue) float getIniFloat(const char *sectionName, const char *keyName, float defaultValue) { radon::Section *section = getIni().getSection(sectionName); - if (!section) + if (section == nullptr) return defaultValue; radon::Key *key = section->getKey(keyName); - if (!key) + if (key == nullptr) return defaultValue; return key->getFloatValue(); @@ -279,11 +279,11 @@ bool getIniValue(const char *sectionName, const char *keyName, char *string, int strncpy(string, defaultString, stringSize); radon::Section *section = getIni().getSection(sectionName); - if (!section) + if (section == nullptr) return false; radon::Key *key = section->getKey(keyName); - if (!key) + if (key == nullptr) return false; std::string value = key->getStringValue(); @@ -299,7 +299,7 @@ void setIniValue(const char *sectionName, const char *keyName, const char *value radon::File &ini = getIni(); radon::Section *section = ini.getSection(sectionName); - if (!section) { + if (section == nullptr) { ini.addSection(sectionName); section = ini.getSection(sectionName); } @@ -307,7 +307,7 @@ void setIniValue(const char *sectionName, const char *keyName, const char *value std::string stringValue(value, len ? len : strlen(value)); radon::Key *key = section->getKey(keyName); - if (!key) { + if (key == nullptr) { section->addKey(radon::Key(keyName, stringValue)); } else { key->setValue(stringValue); diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp index 413c7c6b..8777f889 100644 --- a/Source/storm/storm_net.cpp +++ b/Source/storm/storm_net.cpp @@ -160,13 +160,13 @@ bool SNetCreateGame(const char *pszGameName, const char *pszGamePassword, char * dvlnet_inst->setup_gameinfo(std::move(gameInitInfo)); std::string defaultName; - if (!pszGameName) { + if (pszGameName == nullptr) { defaultName = dvlnet_inst->make_default_gamename(); pszGameName = defaultName.c_str(); } strncpy(gpszGameName, pszGameName, sizeof(gpszGameName) - 1); - if (pszGamePassword) + if (pszGamePassword != nullptr) strncpy(gpszGamePassword, pszGamePassword, sizeof(gpszGamePassword) - 1); *playerID = dvlnet_inst->create(pszGameName, pszGamePassword); return *playerID != -1; @@ -177,9 +177,9 @@ bool SNetJoinGame(char *pszGameName, char *pszGamePassword, int *playerID) #ifndef NONET std::lock_guard lg(storm_net_mutex); #endif - if (pszGameName) + if (pszGameName != nullptr) strncpy(gpszGameName, pszGameName, sizeof(gpszGameName) - 1); - if (pszGamePassword) + if (pszGamePassword != nullptr) strncpy(gpszGamePassword, pszGamePassword, sizeof(gpszGamePassword) - 1); *playerID = dvlnet_inst->join(pszGameName, pszGamePassword); return *playerID != -1; diff --git a/Source/storm/storm_svid.cpp b/Source/storm/storm_svid.cpp index a07d5fe9..5b27f091 100644 --- a/Source/storm/storm_svid.cpp +++ b/Source/storm/storm_svid.cpp @@ -247,10 +247,10 @@ void SVidPlayBegin(const char *filename, int flags, HANDLE *video) } SVidLoop = false; - if (flags & 0x40000) + if ((flags & 0x40000) != 0) SVidLoop = true; - bool enableVideo = !(flags & 0x100000); - bool enableAudio = !(flags & 0x1000000); + bool enableVideo = (flags & 0x100000) == 0; + bool enableAudio = (flags & 0x1000000) == 0; //0x8 // Non-interlaced //0x200, 0x800 // Upscale video //0x80000 // Center horizontally @@ -310,7 +310,7 @@ void SVidPlayBegin(const char *filename, int flags, HANDLE *video) smk_info_video(SVidSMK, &SVidWidth, &SVidHeight, nullptr); #ifndef USE_SDL1 - if (renderer) { + if (renderer != nullptr) { SDL_DestroyTexture(texture); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, SVidWidth, SVidHeight); if (texture == nullptr) { @@ -398,7 +398,7 @@ bool SVidPlayContinue() } #ifndef USE_SDL1 - if (renderer) { + if (renderer != nullptr) { if (SDL_BlitSurface(SVidSurface, nullptr, GetOutputSurface(), nullptr) <= -1) { SDL_Log("%s", SDL_GetError()); return false; @@ -473,10 +473,10 @@ void SVidPlayEnd(HANDLE video) SVidRestartMixer(); } - if (SVidSMK) + if (SVidSMK != nullptr) smk_close(SVidSMK); - if (SVidBuffer) { + if (SVidBuffer != nullptr) { mem_free_dbg(SVidBuffer); SVidBuffer = nullptr; } @@ -492,7 +492,7 @@ void SVidPlayEnd(HANDLE video) memcpy(orig_palette, SVidPreviousPalette, sizeof(orig_palette)); #ifndef USE_SDL1 - if (renderer) { + if (renderer != nullptr) { SDL_DestroyTexture(texture); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, gnScreenWidth, gnScreenHeight); if (texture == nullptr) { diff --git a/Source/themes.cpp b/Source/themes.cpp index 64d9e3b6..ad843c29 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -376,7 +376,7 @@ bool CheckThemeRoom(int tv) for (i = 0; i < MAXDUNX; i++) { if (dTransVal[i][j] != tv) continue; - if (dFlags[i][j] & BFLAG_POPULATED) + if ((dFlags[i][j] & BFLAG_POPULATED) != 0) return false; tarea++; @@ -501,7 +501,7 @@ void PlaceThemeMonsts(int t, int f) numscattypes = 0; for (i = 0; i < nummtypes; i++) { - if (Monsters[i].mPlaceFlags & PLACE_SCATTER) { + if ((Monsters[i].mPlaceFlags & PLACE_SCATTER) != 0) { scattertypes[numscattypes] = i; numscattypes++; } diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index c63540d4..02061098 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -20,7 +20,7 @@ int tmsg_get(Uint8 *pbMsg) int len; TMsg *head; - if (!sgpTimedMsgHead) + if (sgpTimedMsgHead == nullptr) return 0; if ((int)(sgpTimedMsgHead->hdr.dwTime - SDL_GetTicks()) >= 0) @@ -43,7 +43,7 @@ void tmsg_add(Uint8 *pbMsg, Uint8 bLen) msg->hdr.dwTime = SDL_GetTicks() + gnTickDelay * 10; msg->hdr.bLen = bLen; memcpy(msg->body, pbMsg, bLen); - for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) { + for (tail = &sgpTimedMsgHead; *tail != nullptr; tail = &(*tail)->hdr.pNext) { ; } *tail = msg; @@ -58,7 +58,7 @@ void tmsg_cleanup() { TMsg *next; - while (sgpTimedMsgHead) { + while (sgpTimedMsgHead != nullptr) { next = sgpTimedMsgHead->hdr.pNext; MemFreeDbg(sgpTimedMsgHead); sgpTimedMsgHead = next; diff --git a/Source/towners.cpp b/Source/towners.cpp index eb3a30c0..09d1602f 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -199,7 +199,7 @@ void NewTownerAnim(int tnum, BYTE *pAnim, uint8_t numFrames, int Delay) towners[tnum]._tAnimDelay = Delay; } -void InitTownerInfo(int i, int w, int sel, _talker_id t, int x, int y, int ao) +void InitTownerInfo(int i, int w, bool sel, _talker_id t, int x, int y, int ao) { memset(&towners[i], 0, sizeof(TownerStruct)); towners[i]._tSelFlag = sel; @@ -406,7 +406,7 @@ void InitFarmer() { int i; - InitTownerInfo(numtowners, 96, 1, TOWN_FARMER, 62, 16, -1); + InitTownerInfo(numtowners, 96, true, TOWN_FARMER, 62, 16, -1); InitQstSnds(numtowners, TOWN_FARMER); towners[numtowners]._tNData = LoadFileInMem("Towners\\Farmer\\Farmrn2.CEL", nullptr); for (i = 0; i < 8; i++) { @@ -422,7 +422,7 @@ void InitCowFarmer() { int i; - InitTownerInfo(numtowners, 96, 1, TOWN_COWFARM, 61, 22, -1); + InitTownerInfo(numtowners, 96, true, TOWN_COWFARM, 61, 22, -1); InitQstSnds(numtowners, TOWN_COWFARM); if (quests[Q_JERSEY]._qactive != QUEST_DONE) { towners[numtowners]._tNData = LoadFileInMem("Towners\\Farmer\\cfrmrn2.CEL", nullptr); @@ -442,7 +442,7 @@ void InitGirl() { int i; - InitTownerInfo(numtowners, 96, 1, TOWN_GIRL, 77, 43, -1); + InitTownerInfo(numtowners, 96, true, TOWN_GIRL, 77, 43, -1); InitQstSnds(numtowners, TOWN_GIRL); if (quests[Q_GIRL]._qactive != QUEST_DONE) { towners[numtowners]._tNData = LoadFileInMem("Towners\\Girl\\Girlw1.CEL", nullptr); @@ -493,7 +493,7 @@ void FreeTownerGFX() for (i = 0; i < NUM_TOWNERS; i++) { if (towners[i]._tNData == pCowCels) { towners[i]._tNData = nullptr; - } else if (towners[i]._tNData) { + } else if (towners[i]._tNData != nullptr) { MemFreeDbg(towners[i]._tNData); } } @@ -728,7 +728,8 @@ void TalkToTowner(int p, int t) { int i, dx, dy; ItemStruct *Item; - int qt, t2; + int qt; + bool t2; dx = abs(plr[p]._px - towners[t]._tx); dy = abs(plr[p]._py - towners[t]._ty); @@ -953,7 +954,7 @@ void TalkToTowner(int p, int t) } } } else if (t == GetActiveTowner(TOWN_BMAID)) { - if (!plr[p]._pLvlVisited[21] && PlrHasItem(p, IDI_MAPOFDOOM, &i)) { + if (!plr[p]._pLvlVisited[21] && PlrHasItem(p, IDI_MAPOFDOOM, &i) != nullptr) { quests[Q_GRAVE]._qactive = QUEST_ACTIVE; quests[Q_GRAVE]._qlog = true; quests[Q_GRAVE]._qmsg = TEXT_GRAVE8; @@ -998,7 +999,7 @@ void TalkToTowner(int p, int t) } if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && quests[Q_MUSHROOM]._qmsg == TEXT_MUSH10 && PlrHasItem(p, IDI_BRAIN, &i) != nullptr) { RemoveInvItem(p, i); - SpawnQuestItem(IDI_SPECELIX, towners[t]._tx, towners[t]._ty + 1, 0, 0); + SpawnQuestItem(IDI_SPECELIX, towners[t]._tx, towners[t]._ty + 1, 0, false); InitQTextMsg(TEXT_MUSH4); quests[Q_MUSHROOM]._qvar1 = QS_BRAINGIVEN; Qtalklist[TOWN_HEALER][Q_MUSHROOM] = TEXT_NONE; @@ -1068,10 +1069,10 @@ void TalkToTowner(int p, int t) } else if (towners[t]._ttype == TOWN_FARMER) { if (!qtextflag) { qt = TEXT_FARMER1; - t2 = 1; + t2 = true; switch (quests[Q_FARMER]._qactive) { case QUEST_NOTAVAIL: - if (PlrHasItem(p, IDI_RUNEBOMB, &i)) { + if (PlrHasItem(p, IDI_RUNEBOMB, &i) != nullptr) { qt = TEXT_FARMER2; quests[Q_FARMER]._qactive = QUEST_ACTIVE; quests[Q_FARMER]._qvar1 = 1; @@ -1093,17 +1094,17 @@ void TalkToTowner(int p, int t) quests[Q_FARMER]._qlog = true; quests[Q_FARMER]._qmsg = TEXT_FARMER1; SpawnRuneBomb(towners[t]._tx + 1, towners[t]._ty); - t2 = 1; + t2 = true; break; } case QUEST_ACTIVE: - if (PlrHasItem(p, IDI_RUNEBOMB, &i)) + if (PlrHasItem(p, IDI_RUNEBOMB, &i) != nullptr) qt = TEXT_FARMER2; else qt = TEXT_FARMER3; break; case QUEST_INIT: - if (PlrHasItem(p, IDI_RUNEBOMB, &i)) { + if (PlrHasItem(p, IDI_RUNEBOMB, &i) != nullptr) { qt = TEXT_FARMER2; quests[Q_FARMER]._qactive = QUEST_ACTIVE; quests[Q_FARMER]._qvar1 = 1; @@ -1127,7 +1128,7 @@ void TalkToTowner(int p, int t) quests[Q_FARMER]._qlog = true; quests[Q_FARMER]._qmsg = TEXT_FARMER1; SpawnRuneBomb(towners[t]._tx + 1, towners[t]._ty); - t2 = 1; + t2 = true; } break; case QUEST_DONE: @@ -1135,7 +1136,7 @@ void TalkToTowner(int p, int t) SpawnRewardItem(IDI_AURIC, towners[t]._tx + 1, towners[t]._ty); quests[Q_FARMER]._qactive = QUEST_HIVE_DONE; quests[Q_FARMER]._qlog = false; - t2 = 1; + t2 = true; break; case QUEST_HIVE_DONE: qt = TEXT_NONE; @@ -1158,16 +1159,16 @@ void TalkToTowner(int p, int t) } else if (towners[t]._ttype == TOWN_COWFARM) { if (!qtextflag) { qt = TEXT_JERSEY1; - t2 = 1; - if (PlrHasItem(p, IDI_GREYSUIT, &i)) { + t2 = true; + if (PlrHasItem(p, IDI_GREYSUIT, &i) != nullptr) { qt = TEXT_JERSEY7; RemoveInvItem(p, i); - } else if (PlrHasItem(p, IDI_BROWNSUIT, &i)) { + } else if (PlrHasItem(p, IDI_BROWNSUIT, &i) != nullptr) { SpawnUnique(UITEM_BOVINE, towners[t]._tx + 1, towners[t]._ty); RemoveInvItem(p, i); qt = TEXT_JERSEY8; quests[Q_JERSEY]._qactive = QUEST_DONE; - } else if (PlrHasItem(p, IDI_RUNEBOMB, &i)) { + } else if (PlrHasItem(p, IDI_RUNEBOMB, &i) != nullptr) { qt = TEXT_JERSEY5; quests[Q_JERSEY]._qactive = QUEST_ACTIVE; quests[Q_JERSEY]._qvar1 = 1; @@ -1217,7 +1218,7 @@ void TalkToTowner(int p, int t) quests[Q_JERSEY]._qmsg = TEXT_JERSEY4; quests[Q_JERSEY]._qlog = true; SpawnRuneBomb(towners[t]._tx + 1, towners[t]._ty); - t2 = 1; + t2 = true; } break; default: @@ -1239,8 +1240,8 @@ void TalkToTowner(int p, int t) } else if (towners[t]._ttype == TOWN_GIRL) { if (!qtextflag) { qt = TEXT_GIRL1; - t2 = 0; - if (!PlrHasItem(p, IDI_THEODORE, &i) || quests[Q_GIRL]._qactive == QUEST_DONE) { + t2 = false; + if (PlrHasItem(p, IDI_THEODORE, &i) == nullptr || quests[Q_GIRL]._qactive == QUEST_DONE) { switch (quests[Q_GIRL]._qactive) { case 0: qt = TEXT_GIRL2; @@ -1248,7 +1249,7 @@ void TalkToTowner(int p, int t) quests[Q_GIRL]._qvar1 = 1; quests[Q_GIRL]._qlog = true; quests[Q_GIRL]._qmsg = TEXT_GIRL2; - t2 = 1; + t2 = true; break; case 1: qt = TEXT_GIRL2; @@ -1256,11 +1257,11 @@ void TalkToTowner(int p, int t) quests[Q_GIRL]._qlog = true; quests[Q_GIRL]._qmsg = TEXT_GIRL2; quests[Q_GIRL]._qactive = QUEST_ACTIVE; - t2 = 1; + t2 = true; break; case 2: qt = TEXT_GIRL3; - t2 = 1; + t2 = true; break; case 3: qt = TEXT_NONE; @@ -1276,10 +1277,10 @@ void TalkToTowner(int p, int t) CreateAmulet(towners[t]._tx, towners[t]._ty, 13, false, true); quests[Q_GIRL]._qlog = false; quests[Q_GIRL]._qactive = QUEST_DONE; - t2 = 1; + t2 = true; } if (qt != -1) { - if (t2 != 0) { + if (t2) { InitQTextMsg(qt); } else { PlaySFX(alltext[qt].sfxnr); diff --git a/Source/track.cpp b/Source/track.cpp index 7f9fba8a..e697549a 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -12,7 +12,7 @@ namespace devilution { namespace { -BYTE sgbIsScrolling; +bool sgbIsScrolling; Uint32 sgdwLastWalk; bool sgbIsWalking;