- Exhumed: Amend b6ec41e2b1 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.
This commit is contained in:
Mitchell Richters 2020-10-22 19:29:31 +11:00
parent e702a13ef4
commit d90badef6f

View file

@ -402,13 +402,21 @@ void GameInterface::Ticker()
int weap2 = localInput.getNewWeapon(); int weap2 = localInput.getNewWeapon();
if (weap2 == WeaponSel_Next) if (weap2 == WeaponSel_Next)
{ {
auto newWeap = currWeap == 6 ? 1 : currWeap + 2; auto newWeap = currWeap == 6 ? 0 : currWeap + 1;
localInput.setNewWeapon(newWeap); while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)))
{
newWeap++;
}
localInput.setNewWeapon(newWeap + 1);
} }
else if (weap2 == WeaponSel_Prev) else if (weap2 == WeaponSel_Prev)
{ {
auto newWeap = currWeap == 0 ? 7 : currWeap; auto newWeap = currWeap == 0 ? 6 : currWeap - 1;
localInput.setNewWeapon(newWeap); while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)))
{
newWeap--;
}
localInput.setNewWeapon(newWeap + 1);
} }
else if (weap2 == WeaponSel_Alt) else if (weap2 == WeaponSel_Alt)
{ {