Cleaned underwater next/prev weapon fix

This commit is contained in:
carnivoroussociety 2021-08-14 01:55:24 +10:00 committed by Christoph Oelckers
parent 1957fc53be
commit c3d03f21da

View file

@ -2203,16 +2203,15 @@ void WeaponProcess(PLAYER *pPlayer) {
} }
if (pPlayer->newWeapon) if (pPlayer->newWeapon)
{ {
if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !checkFired6or7(pPlayer)) // skip banned weapons when underwater and using next/prev weapon key inputs if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->newWeapon) && !checkFired6or7(pPlayer) && !VanillaMode() && !DemoRecordStatus()) // skip banned weapons when underwater and using next/prev weapon key inputs
{ {
const bool next = prevNewWeaponVal == WeaponSel_Next, prev = prevNewWeaponVal == WeaponSel_Prev; if (prevNewWeaponVal == WeaponSel_Next || prevNewWeaponVal == WeaponSel_Prev) // if player switched weapons
if ((next || prev) && !VanillaMode() && !DemoRecordStatus()) // if player switched weapons
{ {
PLAYER tmpPlayer = *pPlayer; PLAYER tmpPlayer = *pPlayer;
tmpPlayer.curWeapon = pPlayer->newWeapon; // set current banned weapon to curweapon so WeaponFindNext() can find the next weapon tmpPlayer.curWeapon = pPlayer->newWeapon; // set current banned weapon to curweapon so WeaponFindNext() can find the next weapon
for (int i = 0; i < 3; i++) // attempt twice to find a new weapon for (int i = 0; i < 3; i++) // attempt twice to find a new weapon
{ {
tmpPlayer.curWeapon = WeaponFindNext(&tmpPlayer, NULL, next ? 1 : 0); tmpPlayer.curWeapon = WeaponFindNext(&tmpPlayer, NULL, (char)(prevNewWeaponVal == WeaponSel_Next));
if (!BannedUnderwater(tmpPlayer.curWeapon)) // if new weapon is not a banned weapon, set to new current weapon if (!BannedUnderwater(tmpPlayer.curWeapon)) // if new weapon is not a banned weapon, set to new current weapon
{ {
pPlayer->newWeapon = tmpPlayer.curWeapon; pPlayer->newWeapon = tmpPlayer.curWeapon;