Merge branch 'last-lap-points' into 'master'

Fix player->lappoints for ending last lap (resolves #1086)

Closes #1086

See merge request KartKrew/Kart!1969
This commit is contained in:
Oni 2024-03-01 01:13:09 +00:00
commit f7f98ff6d1
2 changed files with 49 additions and 37 deletions

View file

@ -1956,7 +1956,46 @@ static void K_HandleLapIncrement(player_t *player)
player->cheatchecknum = 0; player->cheatchecknum = 0;
player->laps++; player->laps++;
K_UpdateAllPlayerPositions();
// P_DoPlayerExit can edit latestlap, so we do this first
boolean lapisfresh = (player->laps > player->latestlap);
if (lapisfresh) // mcgamer would be proud
{
player->latestlap = player->laps;
}
// finished race exit setup
if (player->laps > numlaps)
{
pflags_t applyflags = 0;
if (specialstageinfo.valid == true)
{
// Don't permit a win just by sneaking ahead of the UFO/emerald.
if (!(specialstageinfo.ufo == NULL || P_MobjWasRemoved(specialstageinfo.ufo)))
{
applyflags |= PF_NOCONTEST;
HU_DoTitlecardCEcho(player, "EMPTY\\HANDED?", false);
}
}
P_DoPlayerExit(player, applyflags);
if (netgame && lapisfresh)
CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players]));
}
else
{
UINT32 skinflags = (demo.playback)
? demo.skinlist[demo.currentskinid[(player-players)]].flags
: skins[player->skin].flags;
if (skinflags & SF_IRONMAN)
{
SetRandomFakePlayerSkin(player, true);
}
K_UpdateAllPlayerPositions(); // P_DoPlayerExit calls this
}
if (G_TimeAttackStart() && !linecrossed) if (G_TimeAttackStart() && !linecrossed)
{ {
@ -1979,16 +2018,13 @@ static void K_HandleLapIncrement(player_t *player)
rainbowstartavailable = false; rainbowstartavailable = false;
} }
if (player->laps == 1 && modeattacking & ATTACKING_SPB) if (player->laps == 1 && (modeattacking & ATTACKING_SPB))
{ {
P_SpawnMobj(player->mo->x - FixedMul(1000*mapobjectscale, FINECOSINE(player->mo->angle >> ANGLETOFINESHIFT)), P_SpawnMobj(player->mo->x - FixedMul(1000*mapobjectscale, FINECOSINE(player->mo->angle >> ANGLETOFINESHIFT)),
player->mo->y - FixedMul(1000*mapobjectscale, FINESINE(player->mo->angle >> ANGLETOFINESHIFT)), player->mo->y - FixedMul(1000*mapobjectscale, FINESINE(player->mo->angle >> ANGLETOFINESHIFT)),
player->mo->z, MT_SPB); player->mo->z, MT_SPB);
} }
if (netgame && player->laps > numlaps)
CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players]));
if (gametyperules & GTR_SPECIALSTART) if (gametyperules & GTR_SPECIALSTART)
{ {
if (player->laps > numlaps) if (player->laps > numlaps)
@ -2019,7 +2055,7 @@ static void K_HandleLapIncrement(player_t *player)
} }
} }
if (player->laps > player->latestlap) if (lapisfresh)
{ {
if (player->laps > 1) if (player->laps > 1)
{ {
@ -2050,8 +2086,6 @@ static void K_HandleLapIncrement(player_t *player)
} }
} }
player->latestlap = player->laps;
// Set up lap animation vars // Set up lap animation vars
if (player->latestlap > 1) if (player->latestlap > 1)
{ {
@ -2074,34 +2108,6 @@ static void K_HandleLapIncrement(player_t *player)
} }
} }
// finished race exit setup
if (player->laps > numlaps)
{
pflags_t applyflags = 0;
if (specialstageinfo.valid == true)
{
// Don't permit a win just by sneaking ahead of the UFO/emerald.
if (!(specialstageinfo.ufo == NULL || P_MobjWasRemoved(specialstageinfo.ufo)))
{
applyflags |= PF_NOCONTEST;
HU_DoTitlecardCEcho(player, "EMPTY\\HANDED?", false);
}
}
P_DoPlayerExit(player, applyflags);
}
else
{
UINT32 skinflags = (demo.playback)
? demo.skinlist[demo.currentskinid[(player-players)]].flags
: skins[player->skin].flags;
if (skinflags & SF_IRONMAN)
{
SetRandomFakePlayerSkin(player, true);
}
}
thwompsactive = true; // Lap 2 effects thwompsactive = true; // Lap 2 effects
{ {

View file

@ -1275,7 +1275,7 @@ void P_DoPlayerExit(player_t *player, pflags_t flags)
} }
} }
K_InitPlayerTally(player); //K_InitPlayerTally(player); -- we defer this to P_PlayerAfterThink
if (demo.playback == false) if (demo.playback == false)
{ {
@ -4465,6 +4465,12 @@ void P_PlayerAfterThink(player_t *player)
} }
#endif #endif
if (player->exiting && !K_PlayerTallyActive(player))
{
// We defer P_DoPlayerExit tallies to the end of the tic.
K_InitPlayerTally(player);
}
if (P_IsObjectOnGround(player->mo) == true) if (P_IsObjectOnGround(player->mo) == true)
{ {
player->outrun = 0; player->outrun = 0;