Fixup respawning logic and remove softlocktimer

* Fix respawning at 0,0,0 if you cross the finish line without touching the
  ground and dying (on waypoint maps)
* Fix a broken lap check making you respawn at 0,0,0 on kart sprint maps
* Properly reset your lap count when respawning
* softlocktimer will be replaced with another solution due to various issues
This commit is contained in:
GenericHeroGuy 2025-09-04 21:53:04 +02:00
parent 770bbafb25
commit 244dde08eb
6 changed files with 16 additions and 30 deletions

View file

@ -583,7 +583,6 @@ struct player_t
// Respawn
UINT8 dropdash; // Gain a burst of speed when you drop while respawning
UINT8 respawn; // Timer given when you die.
UINT8 softlocktimer; // Tracks how fast you died after respawning. Use for softlock prevention.
UINT16 flashing;
UINT16 spinouttimer; // Spin-out from a banana peel or oil slick (was "pw_bananacam")

View file

@ -3150,7 +3150,17 @@ void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo)
void G_DoReborn(INT32 playernum)
{
player_t *player = &players[playernum];
boolean starpost = false;
if (!K_UsingLegacyCheckpoints() && player->lastsafelap != player->laps)
{
// no lap cheating! but more importantly, make sure your lap count matches your respawn point
player->laps = player->lastsafelap;
player->starpostnum = player->lastsafestarpost;
}
// waypoint maps don't need to force respawning at player starts nearly as often
const boolean sprint = K_UsingLegacyCheckpoints() ? mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE && player->laps > 1 : player->laps > 0;
const boolean starpost = !player->spectator && (sprint || player->starpostnum || (!K_UsingLegacyCheckpoints() && player->starposttime));
// Make sure objectplace is OFF when you first start the level!
OP_ResetObjectplace();
@ -3159,12 +3169,6 @@ void G_DoReborn(INT32 playernum)
// respawn at the start
mobj_t *oldmo = NULL;
if (player->spectator)
;
else if ((player->starpostnum || ((player->nextwaypoint != NULL) && player->starposttime))
|| ((mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) && player->laps)) // SRB2kart
starpost = true;
// first dissasociate the corpse
if (player->mo)
{

View file

@ -3032,7 +3032,6 @@ static void K_RespawnChecker(player_t *player)
player->mo->colorized = false;
player->dropdash = 0;
player->respawn = 0;
player->softlocktimer = 3*TICRATE;
}
}
}
@ -8213,9 +8212,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->checkskip)
player->checkskip--;
if (player->softlocktimer)
player->softlocktimer--;
if (player->bigwaypointgap && (player->bigwaypointgap > AUTORESPAWN_THRESHOLD || !P_PlayerInPain(player)))
{
player->bigwaypointgap--;
@ -10770,12 +10766,6 @@ void K_UpdateAllPlayerPositions(void)
continue;
}
if (player->respawn > 0 && player->lastsafelap != player->laps)
{
player->laps = player->lastsafelap;
player->starpostnum = player->lastsafestarpost;
}
K_UpdatePlayerWaypoints(player);
}
}

View file

@ -251,7 +251,6 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT8(save->p, players[i].dropdash);
WRITEUINT8(save->p, players[i].respawn);
WRITEUINT8(save->p, players[i].softlocktimer);
WRITEUINT16(save->p, players[i].flashing);
WRITEUINT16(save->p, players[i].spinouttimer);
@ -600,7 +599,6 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].dropdash = READUINT8(save->p);
players[i].respawn = READUINT8(save->p);
players[i].softlocktimer = READUINT8(save->p);
players[i].flashing = READUINT16(save->p);
players[i].spinouttimer = READUINT16(save->p);

View file

@ -1994,10 +1994,13 @@ static void K_HandleLapIncrement(player_t *player)
player->starposttime = player->realtime;
player->starpostnum = 0;
player->lastsafestarpost = 0;
player->laps++;
if (mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)
if (!K_UsingLegacyCheckpoints())
{
// do nothing, let waypoint code handle respawn positions
}
else if (mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)
{
// SRB2Kart 281118
// Save the player's time and position.

View file

@ -2512,14 +2512,6 @@ static void P_DeathThink(player_t *player)
else
player->karthud[khud_timeovercam] = 0;
// If the player dies too fast or dies during respawn...
// Set players next respawn point to the next waypoint for extra safety.
if (player->softlocktimer > 0 || player->respawn > 0)
{
// Now a clean function! Neat, eh?
K_SetRespawnAtNextWaypoint(player);
}
K_KartPlayerHUDUpdate(player);
if (player->pflags & PF_NOCONTEST)