From 02b411f7ee175a71e13f6d810430b20cabe345c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Jan 2025 23:23:54 +0100 Subject: [PATCH] kill redundant laptime code just use the newer one --- src/d_player.h | 1 + src/doomstat.h | 1 - src/g_game.c | 2 -- src/p_setup.c | 6 +++++- src/p_spec.c | 8 ++------ src/p_user.c | 37 ++++++++++--------------------------- src/y_inter.c | 6 +++--- 7 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b18fea1eb..d6702e2c0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -351,6 +351,7 @@ typedef enum typedef enum { LAP_CUR, + LAP_BEST, LAP_LAST, LAP__MAX } laptime_e; diff --git a/src/doomstat.h b/src/doomstat.h index f70f97059..e68f1da89 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -482,7 +482,6 @@ extern boolean startedInFreePlay; extern boolean legitimateexit; extern boolean comebackshowninfo; -extern tic_t curlap, bestlap; extern INT16 votelevels[4][2]; extern SINT8 votes[MAXPLAYERS]; diff --git a/src/g_game.c b/src/g_game.c index 9618d2e50..52e13968d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -279,8 +279,6 @@ boolean startedInFreePlay; // Map was started in free play // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message? -tic_t curlap; // Current lap time -tic_t bestlap; // Best lap time static INT16 randmapbuffer[NUMMAPS+1]; // Buffer for maps RandMap is allowed to roll tic_t hidetime; diff --git a/src/p_setup.c b/src/p_setup.c index 30e5a09f2..f4c34c17e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2116,7 +2116,11 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].lives = 1; // SRB2Kart players[i].realtime = racecountdown = exitcountdown = 0; - curlap = bestlap = 0; // SRB2Kart + + for (INT32 j = 0; j < LAP__MAX; j++) + { + players[i].laptime[j] = 0; + } players[i].gotcontinue = false; diff --git a/src/p_spec.c b/src/p_spec.c index 2e10770ac..55eb0671a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3912,17 +3912,13 @@ DoneSection2: CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players])); // SRB2Kart: save best lap for record attack - if (player == &players[consoleplayer]) + if (player->laptime[LAP_CUR] < player->laptime[LAP_BEST] || player->laptime[LAP_BEST] == 0) { - if (curlap < bestlap || bestlap == 0) - bestlap = curlap; - curlap = 0; + player->laptime[LAP_BEST] = player->laptime[LAP_CUR]; } - // ONLY FOR HUD player->laptime[LAP_LAST] = player->laptime[LAP_CUR]; player->laptime[LAP_CUR] = 0; - // player->starposttime = player->realtime; player->starpostnum = 0; diff --git a/src/p_user.c b/src/p_user.c index 0d52fea00..a51a9507c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2927,24 +2927,15 @@ static void P_DeathThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; player->laptime[LAP_CUR] = 0; } @@ -4691,25 +4682,15 @@ void P_PlayerThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; - player->laptime[LAP_CUR] = 0; } } @@ -4821,21 +4802,23 @@ void P_PlayerThink(player_t *player) player->linkcount = 0; } - // Move around. - // Reactiontime is used to prevent movement - // for a bit after a teleport. if (player->mo->reactiontime) + { + // Reactiontime is used to prevent movement + // for a bit after a teleport. player->mo->reactiontime--; + } else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { - { - P_DoZoomTube(player); - } + P_DoZoomTube(player); player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); } else + { + // Move around. P_MovePlayer(player); + } if (!player->mo) { diff --git a/src/y_inter.c b/src/y_inter.c index 42fdb346f..994d44199 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -721,13 +721,13 @@ static void Y_UpdateRecordReplays(void) if ((mainrecords[gamemap-1]->time == 0) || (players[consoleplayer].realtime < mainrecords[gamemap-1]->time)) mainrecords[gamemap-1]->time = players[consoleplayer].realtime; - if ((mainrecords[gamemap-1]->lap == 0) || (bestlap < mainrecords[gamemap-1]->lap)) - mainrecords[gamemap-1]->lap = bestlap; + if ((mainrecords[gamemap-1]->lap == 0) || (players[consoleplayer].laptime[LAP_BEST] < mainrecords[gamemap-1]->lap)) + mainrecords[gamemap-1]->lap = players[consoleplayer].laptime[LAP_BEST]; // Save demo! bestdemo[255] = '\0'; lastdemo[255] = '\0'; - G_SetDemoTime(players[consoleplayer].realtime, bestlap); + G_SetDemoTime(players[consoleplayer].realtime, players[consoleplayer].laptime[LAP_BEST]); G_CheckDemoStatus(); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755);