From 4f998fa87951c1c2f5324a3688b0e721fccd49c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Nov 2016 23:24:10 +0100 Subject: [PATCH] - finished the state usage parser. - added state usage specifiers to Actor and Inventory. The states in these classes must be set to full access so that any existing mod can link to them. --- src/namedef.h | 1 + src/scripting/zscript/zcc_compile.cpp | 33 ++++++++++++++++++++++ wadsrc/static/zscript/actor.txt | 2 +- wadsrc/static/zscript/shared/inventory.txt | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/namedef.h b/src/namedef.h index f8475f716..e9324d44b 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -736,3 +736,4 @@ xx(DamageFunction) xx(Length) xx(Unit) xx(StateLabel) +xx(Overlay) diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index b8c0a2a38..2603fea7d 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2387,6 +2387,39 @@ void ZCCCompiler::CompileStates() for (auto s : c->States) { + int flags; + if (s->Flags != nullptr) + { + flags = 0; + auto p = s->Flags; + do + { + switch (p->Id) + { + case NAME_Actor: + flags |= SUF_ACTOR; + break; + case NAME_Overlay: + flags |= SUF_OVERLAY; + break; + case NAME_Weapon: + flags |= SUF_WEAPON; + break; + case NAME_Item: + flags |= SUF_ITEM; + break; + default: + Error(p, "Unknown States qualifier %s", FName(p->Id).GetChars()); + break; + } + + p = static_cast(p->SiblingNext); + } while (p != s->Flags); + } + else + { + flags = static_cast(c->Type())->DefaultStateUsage; + } auto st = s->Body; if (st != nullptr) do { diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index c55c7cd3a..09b5683c8 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -489,7 +489,7 @@ class Actor : Thinker native return ACS_ExecuteAlways(-int(script), mapnum, arg1, arg2, arg3); } - States + States(Actor, Overlay, Weapon, Item) { Spawn: TNT1 A -1; diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index c6fb203a8..a6d7af835 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -16,7 +16,7 @@ class Inventory : Actor native private native void A_RestoreSpecialThing1(); private native void A_RestoreSpecialThing2(); - States + States(Actor, Overlay, Weapon, Item) { HideDoomish: TNT1 A 1050;