From 445bc148b789f92389c30947ccc127d126f58e87 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 22 Feb 2013 02:42:42 +0000 Subject: [PATCH] - Fixed: r4067 completely disabled weapon switching via A_ReFire. SVN r4157 (trunk) --- src/d_player.h | 1 + src/g_shared/a_artifacts.cpp | 1 - src/p_pspr.cpp | 19 +++++++++++++++---- src/p_pspr.h | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 76c70819d..48c387444 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -215,6 +215,7 @@ enum WF_DISABLESWITCH = 1 << 4, // Disable weapon switching completely WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon. WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function. + WF_REFIRESWITCHOK = 1 << 7, // Mirror WF_WEAPONSWITCHOK for A_ReFire }; #define WPIECE1 1 diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index ac9ccde8a..adad4e2c4 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1107,7 +1107,6 @@ void APowerWeaponLevel2::EndEffect () Super::EndEffect(); if (player != NULL) { - if (player->ReadyWeapon != NULL && player->ReadyWeapon->WeaponFlags & WIF_POWERED_UP) { diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 62874e938..85830ac55 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -480,12 +480,22 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) // //============================================================================ -void DoReadyWeaponToSwitch (AActor *self) +void DoReadyWeaponToSwitch (AActor *self, bool switchable) { // Prepare for switching action. player_t *player; if (self && (player = self->player)) - player->WeaponState |= WF_WEAPONSWITCHOK; + { + if (switchable) + { + player->WeaponState |= WF_WEAPONSWITCHOK | WF_REFIRESWITCHOK; + } + else + { + // WF_WEAPONSWITCHOK is automatically cleared every tic by P_SetPsprite(). + player->WeaponState &= ~WF_REFIRESWITCHOK; + } + } } void DoReadyWeaponDisableSwitch (AActor *self, INTBOOL disable) @@ -497,6 +507,7 @@ void DoReadyWeaponDisableSwitch (AActor *self, INTBOOL disable) if (disable) { player->WeaponState |= WF_DISABLESWITCH; + player->WeaponState &= ~WF_REFIRESWITCHOK; } else { @@ -592,7 +603,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady) ACTION_PARAM_START(1); ACTION_PARAM_INT(paramflags, 0); - if (!(paramflags & WRF_NoSwitch)) DoReadyWeaponToSwitch(self); + DoReadyWeaponToSwitch(self, !(paramflags & WRF_NoSwitch)); if ((paramflags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(self, !(paramflags & WRF_NoPrimary), !(paramflags & WRF_NoSecondary)); if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self); if ((paramflags & WRF_AllowReload)) DoReadyWeaponToReload(self); @@ -742,7 +753,7 @@ void A_ReFire(AActor *self, FState *state) { return; } - pending = player->PendingWeapon == WP_NOCHANGE && (player->WeaponState & WF_WEAPONSWITCHOK); + pending = player->PendingWeapon != WP_NOCHANGE && (player->WeaponState & WF_REFIRESWITCHOK); if ((player->cmd.ucmd.buttons & BT_ATTACK) && !player->ReadyWeapon->bAltFire && !pending && player->health > 0) { diff --git a/src/p_pspr.h b/src/p_pspr.h index 83cce732a..ca9b45ee8 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -94,7 +94,7 @@ void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype, angle_t pitch void DoReadyWeapon(AActor * self); void DoReadyWeaponToBob(AActor * self); void DoReadyWeaponToFire(AActor * self, bool primary = true, bool secondary = true); -void DoReadyWeaponToSwitch(AActor * self); +void DoReadyWeaponToSwitch(AActor * self, bool switchable = true); DECLARE_ACTION(A_Raise) void A_ReFire(AActor *self, FState *state = NULL);