diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 8d901ec2e..4056794a4 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -95,7 +95,7 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio if (position == ps_weapon && !nofunction) { // A_WeaponReady will re-set these as needed - player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK); + player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONSWITCHOK | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK); } psp = &player->psprites[position]; @@ -565,30 +565,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady) ACTION_PARAM_START(1); ACTION_PARAM_INT(paramflags, 0); - if (!(paramflags & WRF_NoSwitch)) - { - DoReadyWeaponToSwitch(self); - } - else if (self->player != NULL) - { - self->player->cheats &= ~CF_WEAPONSWITCHOK; - } - 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); - } - if ((paramflags & WRF_AllowZoom)) - { - DoReadyWeaponToZoom(self); - } + if (!(paramflags & WRF_NoSwitch)) DoReadyWeaponToSwitch(self); + 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); + if ((paramflags & WRF_AllowZoom)) DoReadyWeaponToZoom(self); } //--------------------------------------------------------------------------- @@ -649,20 +631,15 @@ void P_CheckWeaponSwitch (player_t *player) if (!player || !(weapon = player->ReadyWeapon)) return; - if (player->health <= 0) - { // Dead, so put the weapon away. - P_SetPsprite(player, ps_weapon, weapon->GetDownState()); - } - else if (!(player->cheats & CF_WEAPONSWITCHOK)) - { // Weapon changing has been disabled. - player->PendingWeapon = WP_NOCHANGE; - } - else if (player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) - { // Put the weapon away if the player has a pending weapon + // Put the weapon away if the player has a pending weapon or has died. + if ((player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) || player->health <= 0) + { P_SetPsprite (player, ps_weapon, weapon->GetDownState()); + return; } else if (player->morphTics != 0) - { // Morphed classes cannot change weapons, so don't even try again. + { + // morphed classes cannot change weapons so don't even try again. player->PendingWeapon = WP_NOCHANGE; } } @@ -1073,7 +1050,10 @@ void P_MovePsprites (player_t *player) } player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; - P_CheckWeaponSwitch (player); + if (player->cheats & CF_WEAPONSWITCHOK) + { + P_CheckWeaponSwitch (player); + } if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT)) { P_CheckWeaponFire (player);