Skip to content

Commit

Permalink
Zoom fixes
Browse files Browse the repository at this point in the history
- Fixed zoom being forcefully disabled if any player were dead, even in freecam
- Moved zoom-toggling logic to `G_Ticker()`
- Used `P_PitchToSlope()` to calculate chasecam slope
  • Loading branch information
MrAlaux committed May 26, 2024
1 parent aea0e7e commit 18414c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
## Bug Fixes

- **Crosshair not being drawn if the chasecam mode were set** even if the chasecam itself were disabled
- **Zoom being forcefully disabled if any player were dead**
22 changes: 21 additions & 1 deletion src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,25 @@ void G_Ticker(void)
}
}

// [Nugget] Freecam
// [Nugget] /---------------------------------------------------------------

// Zoom -------------------------------------------------

static boolean zoomKeyDown = false;

if (!M_InputGameActive(input_zoom)
|| !(gamestate == GS_LEVEL || gamestate == GS_DEMOSCREEN))
{
zoomKeyDown = false;
}
else if (STRICTMODE(!zoomKeyDown))
{
zoomKeyDown = true;
R_SetZoom(!R_GetZoom());
}

// Freecam ----------------------------------------------

if (R_GetFreecamOn())
{
fixed_t x = 0,
Expand Down Expand Up @@ -3358,6 +3376,8 @@ void G_Ticker(void)
R_UpdateFreecam(x, y, z, angle, pitch, center, lock);
}

// [Nugget] ---------------------------------------------------------------/

oldleveltime = leveltime;

// do main actions
Expand Down
17 changes: 5 additions & 12 deletions src/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ void P_PlayerThink (player_t* player)
{
ticcmd_t* cmd;
weapontype_t newweapon;
static boolean zoomKeyDown = false; // [Nugget]

// [AM] Assume we can interpolate at the beginning
// of the tic.
Expand Down Expand Up @@ -708,22 +707,16 @@ void P_PlayerThink (player_t* player)
if (player->playerstate == PST_DEAD)
{
// [Nugget] Disable zoom upon death
if (R_GetZoom() == ZOOM_ON) { R_SetZoom(ZOOM_OFF); }
if (player == &players[displayplayer] && R_GetZoom() == ZOOM_ON
&& !R_GetFreecamOn())
{
R_SetZoom(ZOOM_OFF);
}

P_DeathThink (player);
return;
}

if (!M_InputGameActive(input_zoom))
{
zoomKeyDown = false;
}
else if (STRICTMODE(zoomKeyDown == false))
{
zoomKeyDown = true;
R_SetZoom(!R_GetZoom());
}

// Move around.
// Reactiontime is used to prevent movement
// for a bit after a teleport.
Expand Down
2 changes: 1 addition & 1 deletion src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ void R_SetupFrame (player_t *player)

if (chasecam_on)
{
fixed_t slope = basepitch ? (fixed_t) ((int64_t) finetangent[(ANG90 - basepitch) >> ANGLETOFINESHIFT] * SCREENHEIGHT / ACTUALHEIGHT) : 0;
fixed_t slope = -P_PitchToSlope(basepitch);

static fixed_t oldextradist = 0, extradist = 0;

Expand Down

0 comments on commit 18414c0

Please sign in to comment.