From d90badef6fd4992399c4bd0478e409b4e0ba79ec Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 22 Oct 2020 19:29:31 +1100 Subject: [PATCH] - Exhumed: Amend b6ec41e2b1ac2e815f77cc28a7e5ac0e2b42a605 to ensure next/prev weapon is actually available before trying to switch to it. * Fixes https://forum.zdoom.org/viewtopic.php?f=340&t=70266. --- source/exhumed/src/exhumed.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 8bdbe32f8..56ef8e08d 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -402,13 +402,21 @@ void GameInterface::Ticker() int weap2 = localInput.getNewWeapon(); if (weap2 == WeaponSel_Next) { - auto newWeap = currWeap == 6 ? 1 : currWeap + 2; - localInput.setNewWeapon(newWeap); + auto newWeap = currWeap == 6 ? 0 : currWeap + 1; + while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap))) + { + newWeap++; + } + localInput.setNewWeapon(newWeap + 1); } else if (weap2 == WeaponSel_Prev) { - auto newWeap = currWeap == 0 ? 7 : currWeap; - localInput.setNewWeapon(newWeap); + auto newWeap = currWeap == 0 ? 6 : currWeap - 1; + while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap))) + { + newWeap--; + } + localInput.setNewWeapon(newWeap + 1); } else if (weap2 == WeaponSel_Alt) {