From 1b837a81efc4de30235abbecd323ddb34b6f2348 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Jul 2024 16:07:11 +0200 Subject: [PATCH] improve teleport interpolation stuff --- src/g_game.c | 11 ++++++++++- src/p_spec.c | 6 +----- src/p_telept.c | 23 ++++++++++++++--------- src/s_sound.c | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index aaa6b6fbe..887fd8ffd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2108,7 +2108,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) olddisplayplayer = (*displayplayerp); /* Check if anyone is available to view. */ - if (( playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer) ) == -1) + if ((playernum = G_FindView(playernum, viewnum, onlyactive, playernum < olddisplayplayer)) == -1) return; /* Focus our target view first so that we don't take its player. */ @@ -2117,6 +2117,10 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) { camerap = &camera[viewnum-1]; P_ResetCamera(&players[(*displayplayerp)], camerap); + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewnum); } if (viewnum > splits) @@ -2129,6 +2133,11 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = G_FindView(0, viewd, onlyactive, false); P_ResetCamera(&players[(*displayplayerp)], camerap); + + + // Make sure the viewport doesn't interpolate at all into + // its new position -- just snap instantly into place. + R_ResetViewInterpolation(viewd); } } diff --git a/src/p_spec.c b/src/p_spec.c index 5e64f4422..734cc4113 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2371,11 +2371,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) y = sides[line->sidenum[0]].rowoffset; z = line->frontsector->ceilingheight; - P_UnsetThingPosition(mo); - mo->x += x; - mo->y += y; - mo->z += z; - P_SetThingPosition(mo); + P_SetOrigin(mo, mo->x + x, mo->y + y, mo->z + z); if (mo->player) { diff --git a/src/p_telept.c b/src/p_telept.c index 7c9da2269..a7cef7b1d 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -82,8 +82,13 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player == &players[displayplayers[i]] && camera[i].chase) + if (thing->player != &players[displayplayers[i]]) + continue; + + if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); + + R_ResetViewInterpolation(i + 1); } // don't run in place after a teleport @@ -153,14 +158,14 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { - if (thing->player == &players[displayplayers[i]]) - { - localangle[i] = angle; - if (camera[i].chase) - P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); - break; - } + if (thing->player != &players[displayplayers[i]]) + continue; + + localangle[i] = angle; + if (camera[i].chase) + P_ResetCamera(thing->player, &camera[i]); + + R_ResetViewInterpolation(i + 1); } // don't run in place after a teleport diff --git a/src/s_sound.c b/src/s_sound.c index 470f73f82..b6b7952da 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1989,7 +1989,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 strncpy(newmusic, mmusic, 6); - if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; // No Music (empty string)