Skip to content

Commit

Permalink
- set a default bitmask for the cstat flags.
Browse files Browse the repository at this point in the history
These need to be combined with the flags from the map, so we need to know which ones are being used by the actor defaults.
  • Loading branch information
coelckers committed Jan 23, 2022
1 parent 04a380c commit 0a6a5fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 10 additions & 9 deletions source/core/thingdef_data.cpp
Expand Up @@ -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 }
Expand All @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions source/core/thingdef_properties.cpp
Expand Up @@ -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<PClassActor*>(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.)
Expand Down

0 comments on commit 0a6a5fe

Please sign in to comment.