From 05d1df3571c5a0023529d1bf878facd2f96ca517 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Sat, 18 Jun 2016 10:48:13 +0200 Subject: [PATCH] Fixed crashes with the A_CrispyPlayer and A_HandLower action functions Simply using FindPSprite in those functions wouldn't be enough because if a mod is using the firehands layer when they are called this would go very wrong --- src/g_strife/a_strifestuff.cpp | 25 ++++++++++++++++++++----- src/p_pspr.cpp | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index c0e280762..4533016ec 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -378,14 +378,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer) if (self->player != nullptr && self->player->mo == self) { - self->player->playerstate = PST_DEAD; - DPSprite *psp; psp = self->player->GetPSprite(PSP_STRIFEHANDS); + FState *firehandslower = self->FindState("FireHandsLower"); FState *firehands = self->FindState("FireHands"); - if (firehandslower != NULL && firehands != NULL && firehands < firehandslower) - psp->SetState(psp->GetState() + (firehandslower - firehands)); + FState *state = psp->GetState(); + + if (state != nullptr && firehandslower != nullptr && firehands != nullptr && firehands < firehandslower) + { + self->player->playerstate = PST_DEAD; + psp->SetState(state + (firehandslower - firehands)); + } + else if (state == nullptr) + { + psp->SetState(nullptr); + } } return 0; } @@ -397,13 +405,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_HandLower) if (self->player != nullptr) { DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); + + if (psp->GetState() == nullptr) + { + psp->SetState(nullptr); + return 0; + } + psp->y += 9; if (psp->y > WEAPONBOTTOM*2) { psp->SetState(nullptr); } + if (self->player->extralight > 0) self->player->extralight--; } return 0; } - diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 94a0084dd..2e285b34a 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -231,6 +231,9 @@ DPSprite *player_t::GetPSprite(PSPLayers layer) } if (layer == PSP_STRIFEHANDS) { + // Some of the old hacks rely on this layer coming from the FireHands state. + // This is the ONLY time a psprite's state is actually null. + pspr->State = nullptr; pspr->y = WEAPONTOP; }