The targeter layers now use a proper Caller

This will avoid having to check for certain stuff and also allow them to not be destroyed when the ReadyWeapon is null like before
This commit is contained in:
Leonard2 2016-06-01 23:20:18 +02:00
commit e1f139ddcd
4 changed files with 33 additions and 19 deletions

View file

@ -1364,9 +1364,15 @@ void APowerTargeter::EndEffect ()
Super::EndEffect();
if (Owner != nullptr && Owner->player != nullptr)
{
Owner->player->GetPSprite(PSP_TARGETCENTER)->SetState(nullptr);
Owner->player->GetPSprite(PSP_TARGETLEFT)->SetState(nullptr);
Owner->player->GetPSprite(PSP_TARGETRIGHT)->SetState(nullptr);
// Calling GetPSprite here could crash if we're creating a new game.
// This is because P_SetupLevel nulls the player's mo before destroying
// every DThinker which in turn ends up calling this.
// However P_SetupLevel is only called after G_NewInit which calls
// every player's dtor which destroys all their psprites.
DPSprite *pspr;
if ((pspr = Owner->player->FindPSprite(PSP_TARGETCENTER)) != nullptr) pspr->SetState(nullptr);
if ((pspr = Owner->player->FindPSprite(PSP_TARGETLEFT)) != nullptr) pspr->SetState(nullptr);
if ((pspr = Owner->player->FindPSprite(PSP_TARGETRIGHT)) != nullptr) pspr->SetState(nullptr);
}
}