From e7f78ce9110728933787cef6ead329db87ff5385 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 15 Apr 2022 22:24:34 +0200 Subject: [PATCH] - handle cases of empty state labels in ZScript. Sadly this cannot print a full error message because it got no context for it when it is detected. --- src/playsim/p_map.cpp | 5 +---- src/scripting/thingdef.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index ddb4bf1b9..6db3970bf 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -4767,10 +4767,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, PClassActor *type = PClass::FindActor(pufftype); if (type == NULL) { - if (victim != NULL) - { - memset(victim, 0, sizeof(*victim)); - } + if (victim != NULL) *victim = {}; Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars()); return NULL; } diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 1c060b61c..711ddbaea 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -318,6 +318,12 @@ static void CheckLabel(PClassActor *obj, FStateLabel *slb, int useflag, FName st auto state = slb->State; if (state != nullptr) { + if (intptr_t(state) <= 0xffff) + { + // can't do much here aside from printing a message and aborting. + I_Error("Bad state label %s in actor %s", slb->Label.GetChars(), obj->TypeName.GetChars()); + } + 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",