Replace verticalflip in sector_t with a sector flag that's accessible via Lua and UDMF

This commit is contained in:
MascaraSnake 2021-12-30 18:50:02 +01:00
parent 86e2fefcac
commit b3863c57be
10 changed files with 20 additions and 11 deletions

View file

@ -79,6 +79,7 @@ sectorflags
triggerspecial_touch = "Trigger on Edge Touch";
triggerspecial_headbump = "Trigger on Headbump";
invertprecip = "Invert Precipitation";
gravityflip = "Flip Objects in Reverse Gravity";
heatwave = "Heat Wave";
}

View file

@ -340,7 +340,7 @@ static inline int lib_getenum(lua_State *L)
}
else if (fastncmp("MSF_", word, 3)) {
p = word + 4;
for (i = 0; i < 5; i++)
for (i = 0; i < 6; i++)
if (MSF_LIST[i] && fastcmp(p, MSF_LIST[i])) {
lua_pushinteger(L, ((lua_Integer)1 << i));
return 1;

View file

@ -4472,11 +4472,12 @@ const char *const ML_LIST[16] = {
};
// Sector flags
const char *const MSF_LIST[5] = {
const char *const MSF_LIST[6] = {
"FLIPSPECIAL_FLOOR",
"FLIPSPECIAL_CEILING",
"TRIGGERSPECIAL_TOUCH",
"TRIGGERSPECIAL_HEADBUMP",
"GRAVITYFLIP",
"HEATWAVE",
};

View file

@ -65,7 +65,7 @@ extern const char *const MAPTHINGFLAG_LIST[4];
extern const char *const PLAYERFLAG_LIST[];
extern const char *const GAMETYPERULE_LIST[];
extern const char *const ML_LIST[16]; // Linedef flags
extern const char* const MSF_LIST[5]; // Sector flags
extern const char* const MSF_LIST[6]; // Sector flags
extern const char *COLOR_ENUMS[];
extern const char *const POWERS_LIST[];
extern const char *const HUDITEMS_LIST[];

View file

@ -753,6 +753,7 @@ static int sector_set(lua_State *L)
return LUA_ErrSetDirectly(L, "sector_t", "taglist");
case sector_flags:
sector->flags = luaL_checkinteger(L, 3);
CheckForReverseGravity |= (sector->flags & MSF_GRAVITYFLIP);
break;
case sector_gravity:
sector->gravity = luaL_checkfixed(L, 3);

View file

@ -1463,7 +1463,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
gravityadd = -FixedMul(gravity, gravfactor);
if (rover->master->frontsector->verticalflip && gravityadd > 0)
if ((rover->master->frontsector->flags & MSF_GRAVITYFLIP) && gravityadd > 0)
mo->eflags |= MFE_VERTICALFLIP;
no3dfloorgrav = false;
@ -1475,7 +1475,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
{
gravityadd = -FixedMul(gravity, P_GetSectorGravityFactor(mo->subsector->sector));
if (mo->subsector->sector->verticalflip && gravityadd > 0)
if ((mo->subsector->sector->flags & MSF_GRAVITYFLIP) && gravityadd > 0)
mo->eflags |= MFE_VERTICALFLIP;
}

View file

@ -1213,7 +1213,10 @@ static void UnArchiveSectors(void)
sectors[i].ceilinglightabsolute = READUINT8(save_p);
}
if (diff3 & SD_FLAG)
{
sectors[i].flags = READUINT32(save_p);
CheckForReverseGravity |= (sectors[i].flags & MSF_GRAVITYFLIP);
}
if (diff3 & SD_GRAVITY)
sectors[i].gravity = READFIXED(save_p);

View file

@ -1000,7 +1000,6 @@ static void P_InitializeSector(sector_t *ss)
ss->extra_colormap = NULL;
ss->gravityptr = NULL;
ss->verticalflip = false;
ss->cullheight = NULL;
@ -1674,6 +1673,8 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
sectors[i].flags |= MSF_TRIGGERSPECIAL_HEADBUMP;
else if (fastcmp(param, "invertprecip") && fastcmp("true", val))
sectors[i].flags |= MSF_INVERTPRECIP;
else if (fastcmp(param, "gravityflip") && fastcmp("true", val))
sectors[i].flags |= MSF_GRAVITYFLIP;
else if (fastcmp(param, "heatwave") && fastcmp("true", val))
sectors[i].flags |= MSF_HEATWAVE;
else if (fastcmp(param, "friction"))

View file

@ -5994,6 +5994,8 @@ void P_SpawnSpecials(boolean fromnetsave)
sector = sectors;
for (i = 0; i < numsectors; i++, sector++)
{
CheckForReverseGravity |= (sector->flags & MSF_GRAVITYFLIP);
if (!sector->special)
continue;
@ -6116,11 +6118,11 @@ void P_SpawnSpecials(boolean fromnetsave)
sectors[s].gravityptr = &sectors[sec].floorheight; // This allows it to change in realtime!
if (lines[i].flags & ML_NOCLIMB)
sectors[s].verticalflip = true;
sectors[s].flags |= MSF_GRAVITYFLIP;
else
sectors[s].verticalflip = false;
sectors[s].flags &= ~MSF_GRAVITYFLIP;
CheckForReverseGravity = sectors[s].verticalflip;
CheckForReverseGravity |= (sectors[s].flags & MSF_GRAVITYFLIP);
}
break;

View file

@ -284,7 +284,8 @@ typedef enum
MSF_TRIGGERSPECIAL_HEADBUMP = 1<<3,
// invertprecip - inverts presence of precipitation
MSF_INVERTPRECIP = 1<<4,
MSF_HEATWAVE = 1<<5, // heat wave effect
MSF_GRAVITYFLIP = 1<<5,
MSF_HEATWAVE = 1<<6,
} sectorflags_t;
@ -368,7 +369,6 @@ typedef struct sector_s
fixed_t gravity; // per-sector gravity factor
fixed_t *gravityptr; // For binary format: Read gravity from floor height of master sector
boolean verticalflip; // If gravity < 0, then allow flipped physics
sectorflags_t flags;
INT32 friction;