- fixed handling of dummy flags.

This commit is contained in:
Christoph Oelckers 2018-11-25 10:06:00 +01:00 committed by drfrag
parent 96e9dbd967
commit 376c47bef6
3 changed files with 20 additions and 16 deletions

View file

@ -538,8 +538,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;
}
@ -556,8 +556,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;
}

View file

@ -1477,15 +1477,19 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Propertie
}
else
{
field = dyn_cast<PField>(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<PField>(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;
@ -1507,7 +1511,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);
}
}

View file

@ -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
{