From f46e3bacb204f658ef14acf2d5fb71202fec05e3 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 29 Aug 2020 11:08:31 +0300 Subject: [PATCH] - fixed getting state name with incomplete list of actor classes https://forum.zdoom.org/viewtopic.php?t=69713 --- src/gamedata/info.h | 2 +- src/p_states.cpp | 10 +++++++++- src/scripting/thingdef.cpp | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gamedata/info.h b/src/gamedata/info.h index 92e51e9459..ba2bbb3351 100644 --- a/src/gamedata/info.h +++ b/src/gamedata/info.h @@ -172,7 +172,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 ab38a7f635..2e52243b19 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -128,9 +128,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 17811949b0..88a5e0bf4a 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -321,7 +321,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) @@ -372,7 +372,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()); } } }