diff --git a/src/d_player.h b/src/d_player.h index 48649de7a..e932223aa 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -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. diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index b70e4ff08..7f62d5f0e 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -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; } }