Skip to content

Commit

Permalink
Always Run + Run = Walk (heretic) (#550)
Browse files Browse the repository at this point in the history
* Always Run + Run = Walk (heretic)

* Simplify heretic walk logic
  • Loading branch information
kraflab committed Mar 23, 2020
1 parent 15ad8be commit 44eff69
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/heretic/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)

strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe]
|| joybuttons[joybstrafe];
speed = joybspeed >= MAX_JOY_BUTTONS
|| gamekeydown[key_speed]
|| joybuttons[joybspeed];

// [crispy] when "always run" is active,
// pressing the "run" key will result in walking
speed = (joybspeed >= MAX_JOY_BUTTONS)
^ (gamekeydown[key_speed] || joybuttons[joybspeed]);

// haleyjd: removed externdriver crap

Expand Down

4 comments on commit 44eff69

@fabiangreffrath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kraflab Ah, I am stupid. Now we have replaced an OR condition with an XOR one which means that the second part of the check is evaluated even if the first is already true. This means we dereference the joybspeed element of the joybuttons array even if we know that joybspeed >= MAX_JOY_BUTTONS. Could you please add another check to prevent this? Thanks!

@kraflab
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have caught that. Will update tomorrow after work!

@fabiangreffrath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Heretic even have an "always run" toggle key binding?

@kraflab
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite yet 🙂

Please sign in to comment.