Skip to content

Commit

Permalink
Fix using controller to pan in automap
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Sep 16, 2023
1 parent 313a948 commit 4cf5828
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 50 deletions.
2 changes: 2 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#### DOOM Retro v5.0.1

* A crash no longer occurs when loading a savegame from a [*DSDHacked*](https://doomwiki.org/wiki/DSDHacked)-compatible WAD.
* A bug is fixed whereby no music or sound effects would play when opening *DOOM Retro* for the first time after installing it.
* Panning around the automap using a controller’s left thumbstick when the `am_followmode` CVAR is `off` now works as intended.
* These changes have been made when playing [*Smooth DOOM MBF21*](https://www.doomworld.com/forum/topic/133318/):
* Ammo casings will no disappear and leave blood splats on the floor.
* Blood splats now appear around corpses spawned at the start of a map when the `r_corpses_moreblood` CVAR is `on`.
Expand Down
60 changes: 10 additions & 50 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,16 @@ bool AM_Responder(const event_t *ev)

if (!am_followmode)
{
if (!movement)
{
m_paninc.x = 0;
m_paninc.y = 0;
mtof_zoommul = FRACUNIT;
ftom_zoommul = FRACUNIT;
}

movement = false;

// pan right with left thumbstick
if (gamecontrollerthumbLX > 0)
{
Expand All @@ -1061,26 +1071,6 @@ bool AM_Responder(const event_t *ev)
* ((float)(gamecontrollerthumbLX) / SHRT_MAX) * 1.2f);
}

// pan right with right thumbstick
if (gamecontrollerthumbRX > 0
&& gamecontrollerthumbRX > gamecontrollerthumbLX)
{
movement = true;
speedtoggle = AM_GetSpeedToggle();
m_paninc.x = (fixed_t)(FTOM(F_PANINC)
* ((float)gamecontrollerthumbRX / SHRT_MAX) * 1.2f);
}

// pan left with right thumbstick
else if (gamecontrollerthumbRX < 0
&& gamecontrollerthumbRX < gamecontrollerthumbLX)
{
movement = true;
speedtoggle = AM_GetSpeedToggle();
m_paninc.x = (fixed_t)(FTOM(F_PANINC)
* ((float)(gamecontrollerthumbRX) / SHRT_MAX) * 1.2f);
}

// pan up with left thumbstick
if (gamecontrollerthumbLY < 0)
{
Expand All @@ -1098,37 +1088,7 @@ bool AM_Responder(const event_t *ev)
m_paninc.y = -(fixed_t)(FTOM(F_PANINC)
* ((float)gamecontrollerthumbLY / SHRT_MAX) * 1.2f);
}

// pan up with right thumbstick
if (gamecontrollerthumbRY < 0
&& gamecontrollerthumbRY < gamecontrollerthumbLY)
{
movement = true;
speedtoggle = AM_GetSpeedToggle();
m_paninc.y = -(fixed_t)(FTOM(F_PANINC)
* ((float)(gamecontrollerthumbRY) / SHRT_MAX) * 1.2f);
}

// pan down with right thumbstick
else if (gamecontrollerthumbRY > 0
&& gamecontrollerthumbRY > gamecontrollerthumbLY)
{
movement = true;
speedtoggle = AM_GetSpeedToggle();
m_paninc.y = -(fixed_t)(FTOM(F_PANINC)
* ((float)gamecontrollerthumbRY / SHRT_MAX) * 1.2f);
}
}

if (!movement)
{
m_paninc.x = 0;
m_paninc.y = 0;
mtof_zoommul = FRACUNIT;
ftom_zoommul = FRACUNIT;
}
else
movement = false;
}

if ((viewplayer->cheats & CF_MYPOS) && !am_followmode && (m_paninc.x || m_paninc.y))
Expand Down
3 changes: 3 additions & 0 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ void G_BuildTiccmd(ticcmd_t *cmd)
int forward = 0;
int side = 0;

if (automapactive && !am_followmode && viewplayer->health > 0)
return;

memset(cmd, 0, sizeof(ticcmd_t));

strafe = (gamekeydown[keyboardstrafe] || mousebuttons[mousestrafe] || (gamecontrollerbuttons & gamecontrollerstrafe));
Expand Down

0 comments on commit 4cf5828

Please sign in to comment.