From 90a93a516e8fe5658dc960277fab74f6232ed6d3 Mon Sep 17 00:00:00 2001 From: GoldenTails Date: Tue, 6 Sep 2022 18:42:12 -0500 Subject: [PATCH] Move quake calculation code to r_main.c, keep timer in p_tick.c --- src/p_tick.c | 22 ---------------------- src/r_main.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 4915c5df2..5430e651c 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -739,29 +739,7 @@ void P_Ticker(boolean run) countdown2--; if (quake.time) - { - fixed_t ir = quake.intensity>>1; - - if (quake.epicenter) { - // Calculate 3D distance from epicenter, using camera. - // Uses only player 1 camera because only one quake variable exists. - fixed_t xydist = R_PointToDist2(camera.x, camera.y, quake.epicenter->x, quake.epicenter->y); - fixed_t dist = R_PointToDist2(0, camera.z, xydist, quake.epicenter->z); - - // More effect closer to epicenter, outside of radius = no effect - if (!quake.radius || dist > quake.radius) - ir = 0; - else - ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius)); - } - - quake.x = M_RandomRange(-ir,ir); - quake.y = M_RandomRange(-ir,ir); - quake.z = M_RandomRange(-ir,ir); --quake.time; - } - else - quake.x = quake.y = quake.z = 0; if (metalplayback) G_ReadMetalTic(metalplayback); diff --git a/src/r_main.c b/src/r_main.c index f19962d41..f5992f98b 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1123,6 +1123,7 @@ void R_SetupFrame(player_t *player) { camera_t *thiscam; boolean chasecam = false; + boolean ispaused = paused || P_AutoPause(); if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer]) @@ -1191,6 +1192,30 @@ void R_SetupFrame(player_t *player) } } } + + if (quake.time && !ispaused) + { + fixed_t ir = quake.intensity>>1; + + if (quake.epicenter) { + // Calculate 3D distance from epicenter, using the camera. + fixed_t xydist = R_PointToDist2(thiscam->x, thiscam->y, quake.epicenter->x, quake.epicenter->y); + fixed_t dist = R_PointToDist2(0, thiscam->z, xydist, quake.epicenter->z); + + // More effect closer to epicenter, outside of radius = no effect + if (!quake.radius || dist > quake.radius) + ir = 0; + else + ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius)); + } + + quake.x = M_RandomRange(-ir,ir); + quake.y = M_RandomRange(-ir,ir); + quake.z = M_RandomRange(-ir,ir); + } + else if (!ispaused) + quake.x = quake.y = quake.z = 0; + viewz += quake.z; viewplayer = player;