- 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.
This commit is contained in:
Christoph Oelckers 2018-12-03 18:51:24 +01:00 committed by drfrag
parent d8d52f67b4
commit e176410ab6
2 changed files with 9 additions and 1 deletions

View file

@ -138,6 +138,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<PObjectPointer*>(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());
@ -230,6 +234,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;
}

View file

@ -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);
}
}
}