mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-27 03:31:08 +00:00
Move quake calculation code to r_main.c, keep timer in p_tick.c
This commit is contained in:
parent
a546b553c4
commit
90a93a516e
2 changed files with 25 additions and 22 deletions
22
src/p_tick.c
22
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);
|
||||
|
|
25
src/r_main.c
25
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;
|
||||
|
|
Loading…
Reference in a new issue