diff --git a/src/info.h b/src/info.h index c355c2f95..eead0b4d1 100644 --- a/src/info.h +++ b/src/info.h @@ -179,7 +179,7 @@ public: static PClassActor *StaticFindStateOwner (const FState *state); static PClassActor *StaticFindStateOwner (const FState *state, PClassActor *info); - static FString StaticGetStateName(const FState *state); + static FString StaticGetStateName(const FState *state, PClassActor *info = nullptr); static FRandom pr_statetics; }; diff --git a/src/p_states.cpp b/src/p_states.cpp index 2fb9031cf..dcb5b75db 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -131,9 +131,17 @@ PClassActor *FState::StaticFindStateOwner (const FState *state, PClassActor *inf // //========================================================================== -FString FState::StaticGetStateName(const FState *state) +FString FState::StaticGetStateName(const FState *state, PClassActor *info) { auto so = FState::StaticFindStateOwner(state); + if (so == nullptr) + { + so = FState::StaticFindStateOwner(state, info); + } + if (so == nullptr) + { + return ""; + } return FStringf("%s.%d", so->TypeName.GetChars(), int(state - so->GetStates())); } diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 3d21cbbf8..111afbccf 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -376,7 +376,7 @@ static void CheckLabel(PClassActor *obj, FStateLabel *slb, int useflag, FName st if (!(state->UseFlags & useflag)) { GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "%s references state %s as %s state, but this state is not flagged for use as %s.\n", - obj->TypeName.GetChars(), FState::StaticGetStateName(state).GetChars(), statename.GetChars(), descript); + obj->TypeName.GetChars(), FState::StaticGetStateName(state, obj).GetChars(), statename.GetChars(), descript); } } if (slb->Children != nullptr) @@ -427,7 +427,7 @@ static void CheckStates(PClassActor *obj) if (state->NextState && (state->UseFlags & state->NextState->UseFlags) != state->UseFlags) { GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "State %s links to a state with incompatible restrictions.\n", - FState::StaticGetStateName(state).GetChars()); + FState::StaticGetStateName(state, obj).GetChars()); } } }