diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index ae53ff4dd1e..50d97c0a62d 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -62,7 +62,8 @@ extern float BackbuttonAlpha; // [RH] Keep GCC quiet by not using offsetof on Actor types. #define DEFINE_FLAG(prefix, name, type, variable) { (unsigned int)prefix##_##name, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native } #define DEFINE_PROTECTED_FLAG(prefix, name, type, variable) { (unsigned int)prefix##_##name, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native|VARF_ReadOnly|VARF_InternalAccess } -#define DEFINE_FLAG2(symbol, name, type, variable) { (unsigned int)symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native } +#define DEFINE_FLAG2(symbol, name, type, variable) { (unsigned int)symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native | VARF_Protected } +#define DEFINE_FLAG2d(symbol, name, type, variable) { (unsigned int)symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native } #define DEFINE_FLAG2_DEPRECATED(symbol, name, type, variable) { (unsigned int)symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable), VARF_Native|VARF_Deprecated } #define DEFINE_DEPRECATED_FLAG(name) { DEPF_##name, #name, -1, 0, true } #define DEFINE_DUMMY_FLAG(name, deprec) { DEPF_UNUSED, #name, -1, 0, deprec? VARF_Deprecated:0 } @@ -77,14 +78,14 @@ static FFlagDef InternalActorFlagDefs[]= static FFlagDef ActorFlagDefs[]= { - DEFINE_FLAG2(CSTAT_SPRITE_BLOCK, BLOCK, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_TRANSLUCENT, TRANSLUCENT, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_XFLIP, XFLIP, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_YFLIP, YFLIP, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_ONE_SIDE, ONE_SIDE, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_YCENTER, YCENTER, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_BLOCK_HITSCAN, BLOCK_HITSCAN, DCoreActor, spr.cstat), - DEFINE_FLAG2(CSTAT_SPRITE_INVISIBLE, INVISIBLE, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_BLOCK, BLOCK, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_TRANSLUCENT, TRANSLUCENT, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_XFLIP, XFLIP, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_YFLIP, YFLIP, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_ONE_SIDE, ONE_SIDE, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_YCENTER, YCENTER, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_BLOCK_HITSCAN, BLOCK_HITSCAN, DCoreActor, spr.cstat), + DEFINE_FLAG2d(CSTAT_SPRITE_INVISIBLE, INVISIBLE, DCoreActor, spr.cstat), DEFINE_FLAG2(CSTAT2_SPRITE_MAPPED, MAPPED, DCoreActor, spr.cstat2), DEFINE_FLAG2(CSTAT2_SPRITE_NOSHADOW, NOSHADOW, DCoreActor, spr.cstat2), DEFINE_FLAG2(CSTAT2_SPRITE_DECAL, DECAL, DCoreActor, spr.cstat2), diff --git a/source/core/thingdef_properties.cpp b/source/core/thingdef_properties.cpp index 1b519be9280..d6e9139a0c3 100644 --- a/source/core/thingdef_properties.cpp +++ b/source/core/thingdef_properties.cpp @@ -83,6 +83,11 @@ static PClassActor *FindClassTentative(const char *name, PClass *ancestor, bool //========================================================================== void ModActorFlag(DCoreActor *actor, FFlagDef *fd, bool set) { + // if it's a CSTAT flag, mark it as protected so that map spawned actors do not override it. + if (fd->varflags & VARF_Protected) + { + static_cast(actor->GetClass())->ActorInfo()->DefaultCstat |= fd->flagbit; + } // Little-Endian machines only need one case, because all field sizes // start at the same address. (Unless the machine has unaligned access // exceptions, in which case you'll need multiple cases for it too.)