Fixed a crash with heretic's ChickenPlayer class

This commit is contained in:
Leonard2 2016-07-08 11:55:04 +02:00
parent 05d1df3571
commit 5c182c7fd7
2 changed files with 7 additions and 3 deletions

View File

@ -532,7 +532,10 @@ public:
void TickPSprites();
void DestroyPSprites();
DPSprite *FindPSprite(int layer);
DPSprite *GetPSprite(PSPLayers layer); // Used ONLY for compatibility with the old hardcoded layers.
// Used ONLY for compatibility with the old hardcoded layers.
// Make sure that a state is properly set after calling this unless
// you are 100% sure the context already implies the layer exists.
DPSprite *GetPSprite(PSPLayers layer);
};
// Bookkeeping on players - state.

View File

@ -123,9 +123,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers)
void P_UpdateBeak (AActor *self)
{
if (self->player != nullptr)
DPSprite *pspr;
if (self->player != nullptr && (pspr = self->player->FindPSprite(PSP_WEAPON)) != nullptr)
{
self->player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP + self->player->chickenPeck / 2;
pspr->y = WEAPONTOP + self->player->chickenPeck / 2;
}
}