From 63fe657c7d80cba4893441131200a308c90747a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 05:25:25 +0200 Subject: [PATCH 01/13] Do not set hu_stopped on interpolated frame --- src/d_clisrv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f9110bb2d..1c24606f3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6405,19 +6405,21 @@ boolean TryRunTics(tic_t realtics) } #endif - if (neededtic > gametic) + ticking = neededtic > gametic; + + if (ticking) { - hu_stopped = false; + if (realtics) + hu_stopped = false; } if (player_joining) { - hu_stopped = true; + if (realtics) + hu_stopped = true; return false; } - ticking = neededtic > gametic; - if (ticking) { // run the count * tics @@ -6448,7 +6450,8 @@ boolean TryRunTics(tic_t realtics) } else { - hu_stopped = true; + if (realtics) + hu_stopped = true; } return ticking; -- 2.54.0 From f9e1cdb9403cad483a98b0599a97b76918b332e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 06:08:23 +0200 Subject: [PATCH 02/13] P_Ticker: update view interpolation at the start of a tic --- src/p_setup.c | 1 - src/p_tick.c | 16 +++++++++++++--- src/p_user.c | 1 - 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 17d050dc4..c9e05f9ec 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3011,7 +3011,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) if (rendermode != render_none && !reloadinggamestate) { - R_ResetViewInterpolation(0); R_ResetViewInterpolation(0); R_UpdateMobjInterpolators(); } diff --git a/src/p_tick.c b/src/p_tick.c index 7405792d0..19f18f725 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -434,10 +434,21 @@ void P_Ticker(boolean run) { INT32 i; - //Increment jointime even if paused. + // Increment jointime and quittime even if paused for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) - ++players[i].jointime; + { + players[i].jointime++; + } + } + + if (run) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + } if (objectplacing) { @@ -672,7 +683,6 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); - R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index a9b1b6b72..31297c132 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4002,7 +4002,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); - R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); -- 2.54.0 From afd7b850053e33665624aea156437482cc59c1ce Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 12:49:29 +0200 Subject: [PATCH 03/13] R_ResetViewInterpolation: wait an extra tic if R_UpdateViewInterpolation has not run yet, do not add extra time for subsequent calls --- src/r_fps.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index 9ccba8a7b..7dcdcf9a9 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -23,6 +23,7 @@ #include "r_state.h" #include "z_zone.h" #include "console.h" // con_startup_loadprogress +#include "i_time.h" #ifdef HWRENDER #include "hardware/hw_main.h" // for cv_grshearing @@ -79,6 +80,7 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS]; static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS]; static viewvars_t *oldview = &pview_old[0]; +static tic_t last_view_update; static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; viewvars_t *newview = &pview_new[0]; @@ -207,21 +209,27 @@ void R_UpdateViewInterpolation(void) if (oldview_invalid[i]) oldview_invalid[i]--; } + + last_view_update = I_GetTime(); } void R_ResetViewInterpolation(UINT8 p) { + // Wait an extra tic if the interpolation state hasn't + // updated yet. + int t = last_view_update == I_GetTime() ? 1 : 2; + if (p == 0) { UINT8 i; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - oldview_invalid[i]++; + oldview_invalid[i] = t; } } else { - oldview_invalid[p - 1]++; + oldview_invalid[p - 1] = t; } } -- 2.54.0 From ccd691548e5795aaf5f5c505491c77297c45dfd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 12:53:24 +0200 Subject: [PATCH 04/13] more R_ResetViewInterpolation stuff --- src/p_spec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index c0ad9ea7f..9a06be92a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2097,7 +2097,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) camera[i].reset = true; camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); R_RelativeTeleportViewInterpolation(i, x, y, z, 0); - R_ResetViewInterpolation(i + 1); // reset view interp as well break; } } @@ -2485,6 +2484,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 422: // Cut away to another view { mobj_t *altview; + INT32 i; if (!mo || !mo->player) // only players have views return; @@ -2496,6 +2496,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!altview) return; + if (gamestate == GS_LEVEL) + { + for (i = 0; i <= splitscreen; i++) + { + if (displayplayers[i] == (mo->player - players)) + { + R_ResetViewInterpolation(i + 1); + } + } + } + P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; -- 2.54.0 From 112c9398e7d51c63489d658935d9d5d8dbcb46b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 12:56:19 +0200 Subject: [PATCH 05/13] add missing break --- src/p_telept.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_telept.c b/src/p_telept.c index a7cef7b1d..ceed7dc93 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -166,6 +166,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle P_ResetCamera(thing->player, &camera[i]); R_ResetViewInterpolation(i + 1); + break; } // don't run in place after a teleport -- 2.54.0 From a754e9c08a79d04d0b4411860478d87c48d71283 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:00:07 +0200 Subject: [PATCH 06/13] HACK: reset interp values in case 412 teleporter without using P_Setorigin since that function does some wonky stuff and idk if that would be synch safe --- src/p_spec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index 9a06be92a..96d7ef9b8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2079,6 +2079,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mo->y += y; mo->z += z; P_SetThingPosition(mo); + mo->old_x = mo->x; + mo->old_y = mo->y; + mo->old_z = mo->z; if (mo->player) { -- 2.54.0 From 8e799ddd74b813ab259f336dcb885a56da7bd158 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:04:43 +0200 Subject: [PATCH 07/13] fix a interp bug where the jitter on tally increase would be for only one rendered frame, not one full tic. --- src/y_inter.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index b62566e0a..bbfccf959 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -463,14 +463,12 @@ void Y_IntermissionDrawer(void) for (i = 0; i < data.match.numplayers; i++) { - boolean dojitter = data.match.jitter[data.match.num[i]]; - data.match.jitter[data.match.num[i]] = 0; - if (data.match.num[i] != MAXPLAYERS && playeringame[data.match.num[i]] && !players[data.match.num[i]].spectator) { char strtime[MAXPLAYERNAME+1]; - if (dojitter) + // Apply the jitter offset (later reversed) + if (data.match.jitter[data.match.num[i]] > 0) y--; V_DrawCenteredString(x+6, y, 0, va("%d", data.match.pos[i])); @@ -559,7 +557,7 @@ void Y_IntermissionDrawer(void) } } - if (dojitter) + if (data.match.jitter[data.match.num[i]] > 0) y++; } else @@ -666,8 +664,16 @@ void Y_Ticker(void) return; } - if (intertic < TICRATE || intertic & 1 || endtic != -1) + if (intertic < TICRATE || endtic != -1) + { return; + } + + if (data.match.rankingsmode && intertic & 1) + { + memset(data.match.jitter, 0, sizeof (data.match.jitter)); + return; + } if (intertype == int_race || intertype == int_match) { -- 2.54.0 From 595648a2b30b227c12c43f10c9a62dbbf585312e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:12:27 +0200 Subject: [PATCH 08/13] Interpolate view, even when paused https://github.com/KartKrewDev/RingRacers/commit/3320faec8cebecb124882d38c7ec0ad37b79340a#diff-607b68058edc6124b3061267d902aabeddb6ba338c6483df0af8b1a7cf796a01R43 --- src/d_main.c | 3 +++ src/r_main.c | 5 +++-- src/r_main.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9ca370c2a..28c1dd594 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -825,11 +825,14 @@ void D_SRB2Loop(void) { rendertimefrac = FRACUNIT; } + + rendertimefrac_unpaused = g_time.timefrac; } else { renderdeltatics = realtics * FRACUNIT; rendertimefrac = FRACUNIT; + rendertimefrac_unpaused = FRACUNIT; } if ((interp || doDisplay) && !frameskip) diff --git a/src/r_main.c b/src/r_main.c index c85ef09f2..e0cc44ea9 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -75,6 +75,7 @@ line_t *portalclipline; INT32 portalclipstart, portalclipend; fixed_t rendertimefrac; +fixed_t rendertimefrac_unpaused; fixed_t renderdeltatics; boolean renderisnewtic; @@ -1353,7 +1354,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1480,7 +1481,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } #define ANGLED_PORTALS diff --git a/src/r_main.h b/src/r_main.h index 8766ea65c..e6ae49103 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,6 +33,8 @@ extern size_t validcount, linecount, loopcount, framecount; // The fraction of a tic being drawn (for interpolation between two tics) extern fixed_t rendertimefrac; +// Same as rendertimefrac but not suspended when the game is paused +extern fixed_t rendertimefrac_unpaused; // Evaluated delta tics for this frame (how many tics since the last frame) extern fixed_t renderdeltatics; // The current render is a new logical tic -- 2.54.0 From 90d64c4e1590cc86613938af9e90d40ebf026427 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 13:32:46 +0200 Subject: [PATCH 09/13] fix main menu interpolation apparently in main menu, opening the menu pauses the game so rendertimefrac was FRACUNIT and didnt interpolate --- src/f_finale.c | 10 +++++----- src/r_main.c | 5 +++++ src/r_main.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 7f86303c0..18eab51eb 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -170,8 +170,8 @@ static void F_SkyScroll(INT32 scrollspeed) w = (vid.width / vid.dupx)<width)*16))<width)<width)*16))<width)*16))<width)<width)*16))<= 20) V_DrawSmallScaledPatch(84, 87, 0, ttkart); else if (finalecount >= 10) - V_DrawSciencePatch((84< Date: Sun, 6 Oct 2024 14:30:21 +0200 Subject: [PATCH 10/13] only do this in replays otherwise shit will jitter during netlag --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f61753a19..90b4bbd55 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1359,7 +1359,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } void R_SetupFrame(player_t *player, boolean skybox) @@ -1486,7 +1486,7 @@ void R_SetupFrame(player_t *player, boolean skybox) newview->player = player; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); } #define ANGLED_PORTALS -- 2.54.0 From b2cac971068ebee6049038a57208f9cfcfc81e95 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 14:52:35 +0200 Subject: [PATCH 11/13] fix this --- src/p_spec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 96d7ef9b8..af3687bfb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2499,6 +2499,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!altview) return; + P_SetTarget(&mo->player->awayviewmobj, altview); + mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + if (gamestate == GS_LEVEL) { for (i = 0; i <= splitscreen; i++) @@ -2510,9 +2513,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } - P_SetTarget(&mo->player->awayviewmobj, altview); - mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; - if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle { INT32 aim; -- 2.54.0 From ef763487a5f3c187e0aefb3cc7a6dbb99aac8235 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Oct 2024 18:35:26 +0200 Subject: [PATCH 12/13] this doesent make much sense tbh --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 471d29fa2..8be5bd2c2 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -818,7 +818,7 @@ void D_SRB2Loop(void) { renderdeltatics = FLOAT_TO_FIXED(deltatics); - if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) + if (!(paused || P_AutoPause()) && !hu_stopped) { rendertimefrac = g_time.timefrac; } -- 2.54.0 From 6816c6dd19a5d29a6fec449d79588484316177f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 Nov 2024 15:43:46 +0100 Subject: [PATCH 13/13] add some paranthesis here --- src/r_fps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_fps.c b/src/r_fps.c index 660dc7d7a..0f86160a6 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -217,7 +217,7 @@ void R_ResetViewInterpolation(UINT8 p) { // Wait an extra tic if the interpolation state hasn't // updated yet. - int t = last_view_update == I_GetTime() ? 1 : 2; + int t = ((last_view_update == I_GetTime()) ? 1 : 2); if (p == 0) { -- 2.54.0