From f0d0a0f07bc1facfcb9dbdea5825d71aaf17b187 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Tue, 17 Oct 2023 22:18:49 -0700 Subject: [PATCH] Reset player lap when they reset to track --- src/d_player.h | 2 ++ src/k_kart.c | 1 + src/k_respawn.c | 7 ++++++- src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index 7a42351cb..1b9744efb 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -852,6 +852,8 @@ struct player_t UINT8 sliptideZipDelay; // How long since the last sliptide? Only boost once you've been straightened out for a bit. UINT16 sliptideZipBoost; // The actual boost granted from sliptideZip. + UINT8 lastsafelap; + mobj_t *stumbleIndicator; mobj_t *sliptideZipIndicator; mobj_t *whip; diff --git a/src/k_kart.c b/src/k_kart.c index af38c6f82..1b3e02257 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8968,6 +8968,7 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player) (K_GetWaypointIsEnabled(bestwaypoint) == true)) { player->respawn.wp = bestwaypoint; + player->lastsafelap = player->laps; } } diff --git a/src/k_respawn.c b/src/k_respawn.c index cec0f57df..852459810 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -403,7 +403,12 @@ static void K_MovePlayerToRespawnPoint(player_t *player) P_SetThingPosition(player->mo); // We are no longer traveling from death location to 1st waypoint, so use standard timings - player->respawn.fast = false; + // (and reset their lap so they can't cross the finish the wrong way!) + if (player->respawn.fast) + { + player->respawn.fast = false; + player->laps = player->lastsafelap; + } // At the first valid waypoint, permit extra player control options. player->respawn.init = false; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 65844d2f0..6fe1e325d 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -329,6 +329,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->sliptideZipDelay); else if (fastcmp(field,"sliptideZipBoost")) lua_pushinteger(L, plr->sliptideZipBoost); + else if (fastcmp(field,"lastsafelap")) + lua_pushinteger(L, plr->lastsafelap); else if (fastcmp(field,"instaWhipCharge")) lua_pushinteger(L, plr->instaWhipCharge); else if (fastcmp(field,"instaWhipCooldown")) @@ -809,6 +811,8 @@ static int player_set(lua_State *L) plr->sliptideZipDelay = luaL_checkinteger(L, 3); else if (fastcmp(field,"sliptideZipBoost")) plr->sliptideZipBoost = luaL_checkinteger(L, 3); + else if (fastcmp(field,"lastsafelap")) + plr->lastsafelap = luaL_checkinteger(L, 3); else if (fastcmp(field,"instaWhipCharge")) plr->instaWhipCharge = luaL_checkinteger(L, 3); else if (fastcmp(field,"instaWhipCooldown")) diff --git a/src/p_saveg.c b/src/p_saveg.c index dd8714cb1..4a8fd3027 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -539,6 +539,8 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT8(save->p, players[i].sliptideZipDelay); WRITEUINT16(save->p, players[i].sliptideZipBoost); + WRITEUINT8(save->p, players[i].lastsafelap); + WRITEMEM(save->p, players[i].public_key, PUBKEYLENGTH); WRITEUINT8(save->p, players[i].instaWhipCharge); @@ -1052,6 +1054,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].sliptideZipDelay = READUINT8(save->p); players[i].sliptideZipBoost = READUINT16(save->p); + players[i].lastsafelap = READUINT8(save->p); + READMEM(save->p, players[i].public_key, PUBKEYLENGTH); players[i].instaWhipCharge = READUINT8(save->p);