Add INFLIVES macro, to make it easier to find infinite lives-related code

This commit is contained in:
Monster Iestyn 2018-08-23 20:09:39 +01:00
parent 32bcf11cda
commit aa863e481e
8 changed files with 22 additions and 19 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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));

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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);