From b6d0492478d197d82fb9ac2a1eb12bef733811a5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Dec 2018 18:51:24 +0100 Subject: [PATCH] - fixed crash with weapons which remove themselves from the inventory but continue calling action functions. This is still an error, so now this throws a meaningful exception. --- src/info.cpp | 8 ++++++++ wadsrc/static/zscript/shared/player.txt | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/info.cpp b/src/info.cpp index a513f67af..c4be50d47 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -131,6 +131,10 @@ void FState::CheckCallerType(AActor *self, AActor *stateowner) ThrowAbortException(X_OTHER, "Bad function prototype in function call to %s", ActionFunc->PrintableName.GetChars()); } auto cls = static_cast(requiredType)->PointedClass(); + if (check == nullptr) + { + ThrowAbortException(X_OTHER, "%s called without valid caller. %s expected", ActionFunc->PrintableName.GetChars(), cls->TypeName.GetChars()); + } if (!check->IsKindOf(cls)) { ThrowAbortException(X_OTHER, "Invalid class %s in function call to %s. %s expected", check->GetClass()->TypeName.GetChars(), ActionFunc->PrintableName.GetChars(), cls->TypeName.GetChars()); @@ -223,6 +227,10 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info, } err.stacktrace.AppendFormat("Called from %sstate %s in %s\n", callinfo, FState::StaticGetStateName(this).GetChars(), stateowner->GetClass()->TypeName.GetChars()); } + else + { + err.stacktrace.AppendFormat("Called from state %s\n", FState::StaticGetStateName(this).GetChars()); + } throw; } diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index c4fa07484..b56a60a54 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -2256,7 +2256,7 @@ class PSprite : Object native play Tics--; // [BC] Apply double firing speed. if (bPowDouble && Tics && (Owner.mo.FindInventory ("PowerDoubleFiringSpeed", true))) Tics--; - if (!Tics) SetState(CurState.NextState); + if (!Tics && Caller != null) SetState(CurState.NextState); } } }