summaryrefslogtreecommitdiff
path: root/src/hexen/g_game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hexen/g_game.c')
-rw-r--r--src/hexen/g_game.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c
index 6d10dcfd..3593ffe2 100644
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -451,9 +451,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
// Weapon cycling. Switch to previous or next weapon.
// (Disabled when player is a pig).
-
- if (players[consoleplayer].morphTics == 0 && next_weapon != 0)
+ if (gamestate == GS_LEVEL
+ && players[consoleplayer].morphTics == 0 && next_weapon != 0)
{
+ int start_i;
+
if (players[consoleplayer].pendingweapon == WP_NOCHANGE)
{
i = players[consoleplayer].readyweapon;
@@ -463,9 +465,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic)
i = players[consoleplayer].pendingweapon;
}
+ // Don't loop forever.
+ start_i = i;
do {
- i = (i + next_weapon) % NUMWEAPONS;
- } while (!players[consoleplayer].weaponowned[i]);
+ i = (i + next_weapon + NUMWEAPONS) % NUMWEAPONS;
+ } while (i != start_i && !players[consoleplayer].weaponowned[i]);
cmd->buttons |= BT_CHANGE;
cmd->buttons |= i << BT_WEAPONSHIFT;