From 92f17189b0ccc04336d9eb5698eb7c968cdb7da9 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Thu, 23 Oct 2025 23:15:26 +0200 Subject: [PATCH] Repair and interpolate overtime/jitters --- src/k_hud.c | 76 +++++++++++++++++++++++++++------------------------ src/p_inter.c | 42 ++++++++++++++++++++++------ src/p_tick.c | 42 ---------------------------- src/v_video.h | 2 ++ 4 files changed, 75 insertions(+), 87 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 916670223..20c77b1c5 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1612,9 +1612,9 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI // TIME_Y = 6; // 6 tic_t worktime; - INT32 jitter = 0; - boolean overtime = false; - UINT8 *textcolor = 0; + fixed_t jitter = 0; + boolean overtime = false, fastjitter = false, countdown = false; + UINT8 *textcolor = NULL; INT32 splitflags = 0; if (!mode) @@ -1623,37 +1623,26 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI if (timelimitintics > 0) { - /* - if (drawtime >= (timelimitintics - 5*TICRATE) && ((drawtime*4)/TICRATE) % 2 == 0) - { - dontdraw = true; - } - */ if (drawtime >= timelimitintics) { overtime = true; - jitter = 2; - if (drawtime & 2) - jitter = -jitter; - drawtime = 0; + jitter = 1; } else { drawtime = timelimitintics - drawtime; + countdown = true; if (secretextratime) ; else if (extratimeintics) { jitter = 2; - if (leveltime & 1) - jitter = -jitter; + fastjitter = true; } else if (drawtime <= 5*TICRATE) { jitter = ((drawtime <= 3*TICRATE) && (((drawtime-1) % TICRATE) >= TICRATE-2)) ? 3 : 1; - if (drawtime & 2) - jitter = -jitter; } } } @@ -1673,11 +1662,22 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI if (drawtime != UINT32_MAX && worktime >= 100) { - jitter = (drawtime & 1 ? 1 : -1); + jitter = 1; + fastjitter = true; worktime = 99; drawtime = (100*(60*TICRATE))-1; } + if (fastjitter) + { + jitter *= R_GetTimeFrac(RTF_LEVEL) * (leveltime & 1 ? 1 : -1); + } + else + { + if (drawtime & 2) jitter = -jitter; + jitter *= !!(drawtime & 1) != countdown ? FRACUNIT - R_GetTimeFrac(RTF_LEVEL) : R_GetTimeFrac(RTF_LEVEL); + } + if (mode && drawtime == UINT32_MAX) V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); else if (overtime) @@ -1691,24 +1691,28 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI textcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_ORANGE, GTC_CACHE); } - V_DrawStringScaledEx( - (TIME_X + 33) << FRACBITS, - (TIME_Y + 3) << FRACBITS, - FRACUNIT, - FRACUNIT, - FRACUNIT, - FRACUNIT, - splitflags, - textcolor, - KART_FONT, - va("OVERTIME!") - ); + const char *overtimestr = "OVERTIME"; + for (UINT8 i = 0; i < strlen(overtimestr); i++) + { + V_DrawStringScaledEx( + (TIME_X + 33 + 12*i + (i == 6 ? -4 : i == 7 ? -1 : 0)) << FRACBITS, + ((TIME_Y + 3) << FRACBITS) + (i & 1 ? jitter : -jitter), + FRACUNIT, + FRACUNIT, + FRACUNIT, + FRACUNIT, + splitflags, + textcolor, + KART_FONT, + va("%c", overtimestr[i]) + ); + } } else { // minutes time 00 __ __ - V_DrawKartString(TX, TY+3+jitter, splitflags, va("%d", worktime/10)); - V_DrawKartString(TX+12, TY+3-jitter, splitflags, va("%d", worktime%10)); + V_DrawKartStringAtFixed(TX< 0) { if (secretextratime) { @@ -1043,11 +1044,22 @@ void P_CheckTimeLimit(void) } else { - if (timelimitintics + starttime - leveltime <= 3*TICRATE) + if (timelimitintics > 60*TICRATE && !itembreaker) { - if (((timelimitintics + starttime - leveltime) % TICRATE) == 0) - S_StartSound(NULL, sfx_s3ka7); - } + if (timeleft == 60*TICRATE) + S_StartSound(NULL, sfx_cdfm67); // guys it's a bell it's just like splatoon guys + if (timeleft == 59*TICRATE) + S_StartSound(NULL, sfx_bhurry); // hurry up :)))) + } + + // last five second countdown + if (timeleft % TICRATE == 0) + { + if (timeleft <= 5*TICRATE) + S_StartSound(NULL, sfx_kc35); // 5, 4 + if (timeleft <= 3*TICRATE) + S_StartSound(NULL, sfx_kc3d); // 3, 2, 1 + } } return; } @@ -1055,7 +1067,7 @@ void P_CheckTimeLimit(void) if (gameaction == ga_completed) return; - if ((grandprixinfo.gp == false) && (cv_overtime.value)) + if (!itembreaker && !grandprixinfo.gp && cv_overtime.value) { INT32 playerarray[MAXPLAYERS]; INT32 tempplayer = 0; @@ -1074,7 +1086,7 @@ void P_CheckTimeLimit(void) #ifdef TESTOVERTIMEINFREEPLAY if (timelimitintics > 0 && (gametyperules & GTR_TIMELIMIT) && startedInFreePlay) { - return; + goto overtimesound; } #endif @@ -1116,18 +1128,30 @@ void P_CheckTimeLimit(void) //End the round if the top players aren't tied. if (players[playerarray[0]].roundscore == players[playerarray[1]].roundscore) - return; + goto overtimesound; } else { //In team match and CTF, determining a tie is much simpler. =P if (redscore == bluescore) - return; + goto overtimesound; } } } P_DoAllPlayersExit(0, false); + return; + +overtimesound: + if (timeleft == 0) + { + S_StartSound(NULL, sfx_s3k50); // overtime warning + S_StartSound(NULL, sfx_s3k9d); + } + if (timeleft == -2*TICRATE) + S_StartSoundAtVolume(NULL, sfx_s3k50, 128); + if (timeleft == -4*TICRATE) + S_StartSoundAtVolume(NULL, sfx_s3k50, 96); } /** Checks if a player's score is over the pointlimit and the round should end. diff --git a/src/p_tick.c b/src/p_tick.c index 86fdde2ed..d07cef0e2 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -840,48 +840,6 @@ void P_Ticker(boolean run) } } - if (timelimitintics > 0) - { - // last minute - if (timelimitintics > 60*TICRATE && leveltime == timelimitintics - 60*TICRATE + starttime) - { - S_StartSound(NULL, sfx_cdfm67); // guys it's a bell it's just like splatoon guys - } - if (timelimitintics > 60*TICRATE && leveltime == timelimitintics - 59*TICRATE + starttime) - { - S_StartSound(NULL, sfx_bhurry); // hurry up :)))) - } - - // overtime - if (gameaction != ga_completed && leveltime == timelimitintics + 1 + starttime) - { - S_StartSound(NULL, sfx_s3k50); // overtime warning - S_StartSound(NULL, sfx_s3k9d); - } - if (gameaction != ga_completed && leveltime == timelimitintics + 2*TICRATE + starttime) - { - S_StartSoundAtVolume(NULL, sfx_s3k50, 128); - } - if (gameaction != ga_completed && leveltime == timelimitintics + 4*TICRATE + starttime) - { - S_StartSoundAtVolume(NULL, sfx_s3k50, 96); - } - - // last five second countdown - if (leveltime == timelimitintics - 5 * TICRATE + starttime || - leveltime == timelimitintics - 4 * TICRATE + starttime) - { - S_StartSound(NULL, sfx_kc35); // 5, 4 - } - if (leveltime == timelimitintics - TICRATE + starttime || - leveltime == timelimitintics - 2 * TICRATE + starttime || - leveltime == timelimitintics - 3 * TICRATE + starttime) - { - S_StartSound(NULL, sfx_kc35); - S_StartSound(NULL, sfx_kc3d); // 3, 2, 1 - } - } - // Change timing of start music based on gametyperules { tic_t startingtime = (gametyperules & GTR_NOCOUNTDOWN) ? introtime : starttime; diff --git a/src/v_video.h b/src/v_video.h index e0a20f0dd..c3c664f37 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -305,6 +305,8 @@ char * V_ScaledWordWrap( V__DrawDupxString (x,y,FRACUNIT,option,HU_FONT,string) #define V_DrawKartString( x,y,option,string ) \ V__DrawDupxString (x,y,FRACUNIT,option,KART_FONT,string) +#define V_DrawKartStringAtFixed( x,y,option,string ) \ + V__DrawOneScaleString (x,y,FRACUNIT,option,KART_FONT,string) void V_DrawCenteredString(INT32 x, INT32 y, INT32 option, const char *string); void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string);