- 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.
This commit is contained in:
Christoph Oelckers 2022-04-15 22:24:34 +02:00
parent 3724f8a67c
commit e7f78ce911
2 changed files with 7 additions and 4 deletions

View file

@ -4767,10 +4767,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
PClassActor *type = PClass::FindActor(pufftype); PClassActor *type = PClass::FindActor(pufftype);
if (type == NULL) if (type == NULL)
{ {
if (victim != NULL) if (victim != NULL) *victim = {};
{
memset(victim, 0, sizeof(*victim));
}
Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars()); Printf("Attempt to spawn unknown actor type '%s'\n", pufftype.GetChars());
return NULL; return NULL;
} }

View file

@ -318,6 +318,12 @@ static void CheckLabel(PClassActor *obj, FStateLabel *slb, int useflag, FName st
auto state = slb->State; auto state = slb->State;
if (state != nullptr) 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)) 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", 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",