- fixed handling of dummy flags.

This commit is contained in:
Christoph Oelckers 2018-11-25 10:06:00 +01:00
parent d6b781312c
commit f4789bdefc
3 changed files with 20 additions and 16 deletions

View file

@ -530,8 +530,8 @@ FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bo
{ {
forInternalFlags.fieldsize = 4; forInternalFlags.fieldsize = 4;
forInternalFlags.name = ""; forInternalFlags.name = "";
forInternalFlags.flagbit = field->bitval >= 0? 1 << field->bitval : DEPF_UNUSED; forInternalFlags.flagbit = field->Offset? 1 << field->bitval : DEPF_UNUSED;
forInternalFlags.structoffset = field->bitval >= 0 ? field->Offset->Offset : -1; forInternalFlags.structoffset = field->Offset? (int)field->Offset->Offset : -1;
forInternalFlags.varflags = 0; forInternalFlags.varflags = 0;
return &forInternalFlags; return &forInternalFlags;
} }
@ -548,8 +548,8 @@ FFlagDef *FindFlag (const PClass *type, const char *part1, const char *part2, bo
{ {
forInternalFlags.fieldsize = 4; forInternalFlags.fieldsize = 4;
forInternalFlags.name = ""; forInternalFlags.name = "";
forInternalFlags.flagbit = field->bitval >= 0 ? 1 << field->bitval : DEPF_UNUSED; forInternalFlags.flagbit = field->Offset ? 1 << field->bitval : DEPF_UNUSED;
forInternalFlags.structoffset = field->bitval >= 0 ? field->Offset->Offset : -1; forInternalFlags.structoffset = field->Offset ? (int)field->Offset->Offset : -1;
forInternalFlags.varflags = 0; forInternalFlags.varflags = 0;
return &forInternalFlags; return &forInternalFlags;
} }

View file

@ -1468,15 +1468,19 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Propertie
} }
else else
{ {
field = dyn_cast<PField>(type->FindSymbol(referenced, true)); if (referenced != NAME_None)
if (field == nullptr)
{ {
Error(p, "Variable %s not found in %s", referenced.GetChars(), type->TypeName.GetChars()); field = dyn_cast<PField>(type->FindSymbol(referenced, true));
} if (field == nullptr)
if (!field->Type->isInt() || field->Type->Size != 4) {
{ Error(p, "Variable %s not found in %s", referenced.GetChars(), type->TypeName.GetChars());
Error(p, "Variable %s in %s must have a size of 4 bytes for use as flag storage", 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; FString qualifiedname;
@ -1498,7 +1502,7 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Propertie
} }
} }
if (p->BitValue >= 0) if (field != nullptr)
type->VMType->AddNativeField(FStringf("b%s", name.GetChars()), TypeSInt32, field->Offset, 0, 1 << p->BitValue); type->VMType->AddNativeField(FStringf("b%s", name.GetChars()), TypeSInt32, field->Offset, 0, 1 << p->BitValue);
} }
} }

View file

@ -80,10 +80,10 @@ class Weapon : StateProvider
flagdef CheatNotWeapon: WeaponFlags, 18; // Give cheat considers this not a weapon (used by Sigil) flagdef CheatNotWeapon: WeaponFlags, 18; // Give cheat considers this not a weapon (used by Sigil)
// no-op flags // no-op flags
flagdef NoLMS: WeaponFlags, -1; flagdef NoLMS: none, 0;
flagdef Allow_With_Respawn_Invul: WeaponFlags, -1; flagdef Allow_With_Respawn_Invul: none, 0;
flagdef BFG: WeaponFlags, -1; flagdef BFG: none, 0;
flagdef Explosive: WeaponFlags, -1; flagdef Explosive: none, 0;
Default Default
{ {