- 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.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;
}

View file

@ -1467,6 +1467,8 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Propertie
prefix = referenced;
}
else
{
if (referenced != NAME_None)
{
field = dyn_cast<PField>(type->FindSymbol(referenced, true));
if (field == nullptr)
@ -1477,6 +1479,8 @@ bool ZCCCompiler::CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Propertie
{
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<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
{