From aa863e481e7dd2baff6938316fdf3ac13d7ff2a9 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 23 Aug 2018 20:09:39 +0100 Subject: [PATCH] Add INFLIVES macro, to make it easier to find infinite lives-related code --- src/d_player.h | 5 ++++- src/hu_stuff.c | 4 ++-- src/m_cheat.c | 2 +- src/m_menu.c | 6 +++--- src/p_inter.c | 2 +- src/p_user.c | 8 ++++---- src/st_stuff.c | 10 +++++----- src/y_inter.c | 4 ++-- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 7bee5f337..59f9ba42a 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -382,7 +382,7 @@ typedef struct player_s fixed_t height; // Bounding box changes. fixed_t spinheight; - SINT8 lives; + SINT8 lives; // number of lives - if == INFLIVES, the player has infinite lives SINT8 continues; // continues that player has acquired SINT8 xtralife; // Ring Extra Life counter @@ -491,4 +491,7 @@ typedef struct player_s #endif } player_t; +// Value for infinite lives +#define INFLIVES 0x7F + #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 28438599c..6697eb09b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1275,7 +1275,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I } } - if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != 0x7f)) //show lives + if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE|(greycheck ? V_60TRANS : 0), va("%dx", players[tab[i].num].lives)); else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT) { @@ -1413,7 +1413,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline | (greycheck ? V_TRANSLUCENT : 0) | V_ALLOWLOWERCASE, name); - if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != 0x7f)) //show lives + if (G_GametypeUsesLives() && !(gametype == GT_COOP && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE, va("%dx", players[tab[i].num].lives)); else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT) V_DrawSmallScaledPatch(x-28, y-4, 0, tagico); diff --git a/src/m_cheat.c b/src/m_cheat.c index b572b84eb..56bef02a3 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -918,7 +918,7 @@ void Command_Setlives_f(void) { SINT8 lives = atoi(COM_Argv(1)); if (lives == -1) - players[consoleplayer].lives = 0x7f; // infinity! + players[consoleplayer].lives = INFLIVES; // infinity! else { // P_GivePlayerLives does value clamping diff --git a/src/m_menu.c b/src/m_menu.c index f99f5d860..778f24ad9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5277,7 +5277,7 @@ static void M_PandorasBox(INT32 choice) CV_StealthSetValue(&cv_dummyrings, max(players[consoleplayer].spheres, 0)); else CV_StealthSetValue(&cv_dummyrings, max(players[consoleplayer].rings, 0)); - if (players[consoleplayer].lives == 0x7f) + if (players[consoleplayer].lives == INFLIVES) CV_StealthSetValue(&cv_dummylives, -1); else CV_StealthSetValue(&cv_dummylives, players[consoleplayer].lives); @@ -6334,7 +6334,7 @@ skipsign: y += 25; tempx = x + 10; - if (savegameinfo[savetodraw].lives != 0x7f + if (savegameinfo[savetodraw].lives != INFLIVES && savegameinfo[savetodraw].lives > 9) tempx -= 4; @@ -6361,7 +6361,7 @@ skiplife: V_DrawScaledPatch(tempx + 9, y + 2, 0, patch); tempx += 16; - if (savegameinfo[savetodraw].lives == 0x7f) + if (savegameinfo[savetodraw].lives == INFLIVES) V_DrawCharacter(tempx, y + 1, '\x16', false); else V_DrawString(tempx, y, 0, va("%d", savegameinfo[savetodraw].lives)); diff --git a/src/p_inter.c b/src/p_inter.c index ce8bba6b6..a4493c466 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2253,7 +2253,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if ((target->player->lives <= 1) && (netgame || multiplayer) && (gametype == GT_COOP) && (cv_cooplives.value == 0)) ; - else if (!target->player->bot && !target->player->spectator && !G_IsSpecialStage(gamemap) && (target->player->lives != 0x7f) + else if (!target->player->bot && !target->player->spectator && !G_IsSpecialStage(gamemap) && (target->player->lives != INFLIVES) && G_GametypeUsesLives()) { target->player->lives -= 1; // Lose a life Tails 03-11-2000 diff --git a/src/p_user.c b/src/p_user.c index fd09b0847..100663d91 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -927,7 +927,7 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) player->rings = 0; // Now extra life bonuses are handled here instead of in P_MovePlayer, since why not? - if (!ultimatemode && !modeattacking && !G_IsSpecialStage(gamemap) && G_GametypeUsesLives() && player->lives != 0x7f) + if (!ultimatemode && !modeattacking && !G_IsSpecialStage(gamemap) && G_GametypeUsesLives() && player->lives != INFLIVES) { INT32 gainlives = 0; @@ -986,7 +986,7 @@ void P_GivePlayerLives(player_t *player, INT32 numlives) if (gamestate == GS_LEVEL) { - if (player->lives == 0x7f || (gametype != GT_COOP && gametype != GT_COMPETITION)) + if (player->lives == INFLIVES || (gametype != GT_COOP && gametype != GT_COMPETITION)) { P_GivePlayerRings(player, 100*numlives); return; @@ -8377,7 +8377,7 @@ boolean P_GetLives(player_t *player) if (!(netgame || multiplayer) || (gametype != GT_COOP) || (cv_cooplives.value == 1) - || (player->lives == 0x7f)) + || (player->lives == INFLIVES)) return true; if ((cv_cooplives.value == 2 || cv_cooplives.value == 0) && player->lives > 0) @@ -8404,7 +8404,7 @@ boolean P_GetLives(player_t *player) { if (cv_cooplives.value == 2 && (P_IsLocalPlayer(player) || P_IsLocalPlayer(&players[maxlivesplayer]))) S_StartSound(NULL, sfx_jshard); // placeholder - if (players[maxlivesplayer].lives != 0x7f) + if (players[maxlivesplayer].lives != INFLIVES) players[maxlivesplayer].lives--; player->lives++; if (player->lives < 1) diff --git a/src/st_stuff.c b/src/st_stuff.c index 0079b8da9..5fbd2eafc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -807,7 +807,7 @@ static void ST_drawLivesArea(void) // lives number if (gametype == GT_RACE) { - livescount = 0x7f; + livescount = INFLIVES; notgreyedout = true; } else if ((netgame || multiplayer) && gametype == GT_COOP && cv_cooplives.value == 3) @@ -826,9 +826,9 @@ static void ST_drawLivesArea(void) if (players[i].lives > 1) notgreyedout = true; - if (players[i].lives == 0x7f) + if (players[i].lives == INFLIVES) { - livescount = 0x7f; + livescount = INFLIVES; break; } else if (livescount < 99) @@ -837,11 +837,11 @@ static void ST_drawLivesArea(void) } else { - livescount = (((netgame || multiplayer) && gametype == GT_COOP && cv_cooplives.value == 0) ? 0x7f : stplyr->lives); + livescount = (((netgame || multiplayer) && gametype == GT_COOP && cv_cooplives.value == 0) ? INFLIVES : stplyr->lives); notgreyedout = true; } - if (livescount == 0x7f) + if (livescount == INFLIVES) V_DrawCharacter(hudinfo[HUD_LIVES].x+50, hudinfo[HUD_LIVES].y+8, '\x16' | 0x80 | hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, false); else diff --git a/src/y_inter.c b/src/y_inter.c index 966d84477..fff6d2ebf 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1874,7 +1874,7 @@ static void Y_AwardCoopBonuses(void) players[i].score = MAXSCORE; } - ptlives = (!ultimatemode && !modeattacking && players[i].lives != 0x7f) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; + ptlives = (!ultimatemode && !modeattacking && players[i].lives != INFLIVES) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; if (ptlives) P_GivePlayerLives(&players[i], ptlives); @@ -1918,7 +1918,7 @@ static void Y_AwardSpecialStageBonus(void) players[i].score = MAXSCORE; // grant extra lives right away since tally is faked - ptlives = (!ultimatemode && !modeattacking && players[i].lives != 0x7f) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; + ptlives = (!ultimatemode && !modeattacking && players[i].lives != INFLIVES) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; if (ptlives) P_GivePlayerLives(&players[i], ptlives);