Call GetPSprite here to update the ReadyWeapon but avoid doing so if it

is null

TickPSprites will take care of destroying the weapon/flash layers if the
ReadyWeapon is null
This commit is contained in:
Leonard2 2016-05-30 15:37:02 +02:00
parent f14a840777
commit 9ee5e57340

View file

@ -341,16 +341,14 @@ void DPSprite::SetState(FState *newstate, bool pending)
void P_BringUpWeapon (player_t *player) void P_BringUpWeapon (player_t *player)
{ {
FState *newstate;
AWeapon *weapon; AWeapon *weapon;
DPSprite *psweapon = player->GetPSprite(PSP_WEAPON);
if (player->PendingWeapon == WP_NOCHANGE) if (player->PendingWeapon == WP_NOCHANGE)
{ {
if (player->ReadyWeapon != nullptr) if (player->ReadyWeapon != nullptr)
{ {
psweapon->y = WEAPONTOP; player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
psweapon->SetState(player->ReadyWeapon->GetReadyState()); player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetReadyState());
} }
return; return;
} }
@ -367,28 +365,25 @@ void P_BringUpWeapon (player_t *player)
weapon = weapon->SisterWeapon; weapon = weapon->SisterWeapon;
} }
player->PendingWeapon = WP_NOCHANGE;
player->ReadyWeapon = weapon;
player->mo->weaponspecial = 0;
if (weapon != nullptr) if (weapon != nullptr)
{ {
if (weapon->UpSound) if (weapon->UpSound)
{ {
S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM); S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM);
} }
newstate = weapon->GetUpState ();
player->refire = 0; player->refire = 0;
player->GetPSprite(PSP_WEAPON)->y = player->cheats & CF_INSTANTWEAPSWITCH
? WEAPONTOP : WEAPONBOTTOM;
// make sure that the previous weapon's flash state is terminated.
// When coming here from a weapon drop it may still be active.
player->GetPSprite(PSP_FLASH)->SetState(nullptr);
player->GetPSprite(PSP_WEAPON)->SetState(weapon->GetUpState());
} }
else
{
newstate = nullptr;
}
player->PendingWeapon = WP_NOCHANGE;
player->ReadyWeapon = weapon;
psweapon->y = player->cheats & CF_INSTANTWEAPSWITCH
? WEAPONTOP : WEAPONBOTTOM;
// make sure that the previous weapon's flash state is terminated.
// When coming here from a weapon drop it may still be active.
player->GetPSprite(PSP_FLASH)->SetState(nullptr);
psweapon->SetState(newstate);
player->mo->weaponspecial = 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------