diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index a4dfbc16c5..210fb7cfc3 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -530,8 +530,8 @@ FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bo { forInternalFlags.fieldsize = 4; forInternalFlags.name = ""; - forInternalFlags.flagbit = field->bitval >= 0? 1 << field->bitval : DEPF_UNUSED; - forInternalFlags.structoffset = field->bitval >= 0 ? field->Offset->Offset : -1; + forInternalFlags.flagbit = field->Offset? 1 << field->bitval : DEPF_UNUSED; + forInternalFlags.structoffset = field->Offset? (int)field->Offset->Offset : -1; forInternalFlags.varflags = 0; return &forInternalFlags; } @@ -548,8 +548,8 @@ FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bo { forInternalFlags.fieldsize = 4; forInternalFlags.name = ""; - forInternalFlags.flagbit = field->bitval >= 0 ? 1 << field->bitval : DEPF_UNUSED; - forInternalFlags.structoffset = field->bitval >= 0 ? field->Offset->Offset : -1; + forInternalFlags.flagbit = field->Offset ? 1 << field->bitval : DEPF_UNUSED; + forInternalFlags.structoffset = field->Offset ? (int)field->Offset->Offset : -1; forInternalFlags.varflags = 0; return &forInternalFlags; } diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 512a2f801b..52ab582faf 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1468,15 +1468,19 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray &Propertie } else { - field = dyn_cast(type->FindSymbol(referenced, true)); - if (field == nullptr) + if (referenced != NAME_None) { - Error(p, "Variable %s not found in %s", referenced.GetChars(), type->TypeName.GetChars()); - } - if (!field->Type->isInt() || field->Type->Size != 4) - { - Error(p, "Variable %s in %s must have a size of 4 bytes for use as flag storage", referenced.GetChars(), type->TypeName.GetChars()); + field = dyn_cast(type->FindSymbol(referenced, true)); + if (field == nullptr) + { + Error(p, "Variable %s not found in %s", referenced.GetChars(), type->TypeName.GetChars()); + } + if (!field->Type->isInt() || field->Type->Size != 4) + { + Error(p, "Variable %s in %s must have a size of 4 bytes for use as flag storage", referenced.GetChars(), type->TypeName.GetChars()); + } } + else field = nullptr; FString qualifiedname; @@ -1498,7 +1502,7 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray &Propertie } } - if (p->BitValue >= 0) + if (field != nullptr) type->VMType->AddNativeField(FStringf("b%s", name.GetChars()), TypeSInt32, field->Offset, 0, 1 << p->BitValue); } } diff --git a/wadsrc/static/zscript/inventory/weapons.txt b/wadsrc/static/zscript/inventory/weapons.txt index eabe72292f..add0409124 100644 --- a/wadsrc/static/zscript/inventory/weapons.txt +++ b/wadsrc/static/zscript/inventory/weapons.txt @@ -80,10 +80,10 @@ class Weapon : StateProvider flagdef CheatNotWeapon: WeaponFlags, 18; // Give cheat considers this not a weapon (used by Sigil) // no-op flags - flagdef NoLMS: WeaponFlags, -1; - flagdef Allow_With_Respawn_Invul: WeaponFlags, -1; - flagdef BFG: WeaponFlags, -1; - flagdef Explosive: WeaponFlags, -1; + flagdef NoLMS: none, 0; + flagdef Allow_With_Respawn_Invul: none, 0; + flagdef BFG: none, 0; + flagdef Explosive: none, 0; Default {