From c150116f79aa04479f0cec0e697c546567af7a54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 16 Jul 2016 19:55:00 +0200 Subject: [PATCH] - fixed: When changing weapons due to starting or ending a Tome of Power effect, the PSprite's caller needs to be changed. In this case the PSprite animation won't be changed, only the ReadyWeapon. But in order to work, the PSprite's caller needs to change as well so that the next weapon check does not fail. --- src/g_shared/a_artifacts.cpp | 17 ++++++++++++++++- src/g_shared/a_weapons.cpp | 13 ++++++++++++- src/p_pspr.h | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 07071daa6..b5ac970ca 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1127,12 +1127,27 @@ void APowerWeaponLevel2::InitEffect () assert (sister->SisterWeapon == weapon); - Owner->player->ReadyWeapon = sister; if (weapon->GetReadyState() != sister->GetReadyState()) { + Owner->player->ReadyWeapon = sister; P_SetPsprite(Owner->player, PSP_WEAPON, sister->GetReadyState()); } + else + { + DPSprite *psp = Owner->player->FindPSprite(PSP_WEAPON); + if (psp != nullptr && psp->GetCaller() == Owner->player->ReadyWeapon) + { + // If the weapon changes but the state does not, we have to manually change the PSprite's caller here. + psp->SetCaller(sister); + Owner->player->ReadyWeapon = sister; + } + else + { + // Something went wrong. Initiate a regular weapon change. + Owner->player->PendingWeapon = sister; + } + } } //=========================================================================== diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index e7ebfc77b..575914fe8 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -642,7 +642,18 @@ void AWeapon::EndPowerup () } else { - Owner->player->ReadyWeapon = SisterWeapon; + DPSprite *psp = Owner->player->FindPSprite(PSP_WEAPON); + if (psp != nullptr && psp->GetCaller() == Owner->player->ReadyWeapon) + { + // If the weapon changes but the state does not, we have to manually change the PSprite's caller here. + psp->SetCaller(SisterWeapon); + Owner->player->ReadyWeapon = SisterWeapon; + } + else + { + // Something went wrong. Initiate a regular weapon change. + Owner->player->PendingWeapon = SisterWeapon; + } } } } diff --git a/src/p_pspr.h b/src/p_pspr.h index a7cf49f8c..41d258df8 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -76,6 +76,7 @@ public: FState* GetState() const { return State; } DPSprite* GetNext() { return Next; } AActor* GetCaller() { return Caller; } + void SetCaller(AActor *newcaller) { Caller = newcaller; } double x, y; double oldx, oldy;