diff --git a/src/scripting/backend/scopebarrier.cpp b/src/scripting/backend/scopebarrier.cpp index 4d9d6d2fc..fda9de3c3 100644 --- a/src/scripting/backend/scopebarrier.cpp +++ b/src/scripting/backend/scopebarrier.cpp @@ -44,6 +44,19 @@ int FScopeBarrier::FlagsFromSide(int side) } } +int FScopeBarrier::ObjectFlagsFromSide(int side) +{ + switch (side) + { + case Side_Play: + return OF_Play; + case Side_UI: + return OF_UI; + default: + return 0; + } +} + // used for errors const char* FScopeBarrier::StringFromSide(int side) { @@ -72,6 +85,14 @@ int FScopeBarrier::ChangeSideInFlags(int flags, int side) return flags; } +// this modifies OF_ flags and sets the side properly. +int FScopeBarrier::ChangeSideInObjectFlags(int flags, int side) +{ + flags &= ~(OF_UI | OF_Play); + flags |= ObjectFlagsFromSide(side); + return flags; +} + FScopeBarrier::FScopeBarrier() { sidefrom = -1; diff --git a/src/scripting/backend/scopebarrier.h b/src/scripting/backend/scopebarrier.h index ed4f25a10..514db7a97 100644 --- a/src/scripting/backend/scopebarrier.h +++ b/src/scripting/backend/scopebarrier.h @@ -35,12 +35,15 @@ struct FScopeBarrier // static int FlagsFromSide(int side); + static int ObjectFlagsFromSide(int side); // used for errors static const char* StringFromSide(int side); // this modifies VARF_ flags and sets the side properly. static int ChangeSideInFlags(int flags, int side); + // this modifies OF_ flags and sets the side properly. + static int ChangeSideInObjectFlags(int flags, int side); FScopeBarrier(); FScopeBarrier(int flags1, int flags2, const char* name); diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 5519d2166..14eceb0cb 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -501,10 +501,13 @@ void ZCCCompiler::CreateStructTypes() Error(s->strct, "Struct %s has incompatible flags", s->NodeName().GetChars()); } + if (outer) s->Type()->ObjectFlags = FScopeBarrier::ChangeSideInObjectFlags(s->Type()->ObjectFlags, FScopeBarrier::SideFromObjectFlags(outer->ObjectFlags)); if (s->strct->Flags & ZCC_UIFlag) - s->Type()->ObjectFlags |= OF_UI; + s->Type()->ObjectFlags = FScopeBarrier::ChangeSideInObjectFlags(s->Type()->ObjectFlags, FScopeBarrier::Side_UI); if (s->strct->Flags & ZCC_Play) - s->Type()->ObjectFlags |= OF_Play; + s->Type()->ObjectFlags = FScopeBarrier::ChangeSideInObjectFlags(s->Type()->ObjectFlags, FScopeBarrier::Side_Play); + if (s->strct->Flags & ZCC_ClearScope) + s->Type()->ObjectFlags = FScopeBarrier::ChangeSideInObjectFlags(s->Type()->ObjectFlags, FScopeBarrier::Side_PlainData); // don't inherit the scope from the outer class s->strct->Symbol = new PSymbolType(s->NodeName(), s->Type()); syms->AddSymbol(s->strct->Symbol);