From 143dd3d2cfca6b970e125d3335a572b79f987db0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 22 Nov 2020 18:59:59 +0100 Subject: [PATCH] - fixed weapon cycling in Exhumed. The sword was checked for ammo (and failed) and wraparound was not handled. Fixes #193 --- source/exhumed/src/exhumed.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 6be7e5c77..a04f2c40b 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -402,16 +402,17 @@ void GameInterface::Ticker() if (weap2 == WeaponSel_Next) { auto newWeap = currWeap == 6 ? 0 : currWeap + 1; - while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)) || (nPlayerWeapons[nLocalPlayer] & (1 << newWeap) && PlayerList[nLocalPlayer].nAmmo[newWeap] == 0)) + while (newWeap != 0 && (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)) || (nPlayerWeapons[nLocalPlayer] & (1 << newWeap) && PlayerList[nLocalPlayer].nAmmo[newWeap] == 0))) { newWeap++; + if (newWeap > 6) newWeap = 0; } localInput.setNewWeapon(newWeap + 1); } else if (weap2 == WeaponSel_Prev) { auto newWeap = currWeap == 0 ? 6 : currWeap - 1; - while (!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)) || (nPlayerWeapons[nLocalPlayer] & (1 << newWeap) && PlayerList[nLocalPlayer].nAmmo[newWeap] == 0)) + while (newWeap != 0 && ((!(nPlayerWeapons[nLocalPlayer] & (1 << newWeap)) || (nPlayerWeapons[nLocalPlayer] & (1 << newWeap) && PlayerList[nLocalPlayer].nAmmo[newWeap] == 0)))) { newWeap--; }