mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-24 21:31:46 +00:00
Merge branch 'udmf-absolutez' into 'next'
Add absolute Z height flag for mapthings in UDMF See merge request STJr/SRB2!2015
This commit is contained in:
commit
b533594a33
7 changed files with 25 additions and 16 deletions
|
@ -277,8 +277,8 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
|
||||||
}
|
}
|
||||||
else if (fastncmp("MTF_", word, 4)) {
|
else if (fastncmp("MTF_", word, 4)) {
|
||||||
p = word+4;
|
p = word+4;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; MAPTHINGFLAG_LIST[i]; i++)
|
||||||
if (MAPTHINGFLAG_LIST[i] && fastcmp(p, MAPTHINGFLAG_LIST[i])) {
|
if (fastcmp(p, MAPTHINGFLAG_LIST[i])) {
|
||||||
CacheAndPushConstant(L, word, ((lua_Integer)1<<i));
|
CacheAndPushConstant(L, word, ((lua_Integer)1<<i));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4410,11 +4410,12 @@ const char *const MOBJEFLAG_LIST[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *const MAPTHINGFLAG_LIST[4] = {
|
const char *const MAPTHINGFLAG_LIST[] = {
|
||||||
"EXTRA", // Extra flag for objects.
|
"EXTRA", // Extra flag for objects.
|
||||||
"OBJECTFLIP", // Reverse gravity flag for objects.
|
"OBJECTFLIP", // Reverse gravity flag for objects.
|
||||||
"OBJECTSPECIAL", // Special flag used with certain objects.
|
"OBJECTSPECIAL", // Special flag used with certain objects.
|
||||||
"AMBUSH" // Deaf monsters/do not react to sound.
|
"AMBUSH", // Deaf monsters/do not react to sound.
|
||||||
|
"ABSOLUTEZ" // Absolute spawn height flag for objects.
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *const PLAYERFLAG_LIST[] = {
|
const char *const PLAYERFLAG_LIST[] = {
|
||||||
|
|
|
@ -62,7 +62,7 @@ extern const char *const MOBJTYPE_LIST[];
|
||||||
extern const char *const MOBJFLAG_LIST[];
|
extern const char *const MOBJFLAG_LIST[];
|
||||||
extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2
|
extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2
|
||||||
extern const char *const MOBJEFLAG_LIST[];
|
extern const char *const MOBJEFLAG_LIST[];
|
||||||
extern const char *const MAPTHINGFLAG_LIST[4];
|
extern const char *const MAPTHINGFLAG_LIST[];
|
||||||
extern const char *const PLAYERFLAG_LIST[];
|
extern const char *const PLAYERFLAG_LIST[];
|
||||||
extern const char *const GAMETYPERULE_LIST[];
|
extern const char *const GAMETYPERULE_LIST[];
|
||||||
extern const char *const ML_LIST[]; // Linedef flags
|
extern const char *const ML_LIST[]; // Linedef flags
|
||||||
|
|
|
@ -62,6 +62,10 @@ enum
|
||||||
#define MTF_AMBUSH 8
|
#define MTF_AMBUSH 8
|
||||||
|
|
||||||
// Do not use bit five or after, as they are used for object z-offsets.
|
// Do not use bit five or after, as they are used for object z-offsets.
|
||||||
|
// Unless it's exclusive to UDMF.
|
||||||
|
|
||||||
|
// Flag to use Z as absolute spawn height, ignoring the floor and ceiling.
|
||||||
|
#define MTF_ABSOLUTEZ 16
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
17
src/p_mobj.c
17
src/p_mobj.c
|
@ -11864,7 +11864,7 @@ void P_MovePlayerToStarpost(INT32 playernum)
|
||||||
mapthing_t *huntemeralds[MAXHUNTEMERALDS];
|
mapthing_t *huntemeralds[MAXHUNTEMERALDS];
|
||||||
INT32 numhuntemeralds;
|
INT32 numhuntemeralds;
|
||||||
|
|
||||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale)
|
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale, const boolean absolutez)
|
||||||
{
|
{
|
||||||
const subsector_t *ss = R_PointInSubsector(x, y);
|
const subsector_t *ss = R_PointInSubsector(x, y);
|
||||||
|
|
||||||
|
@ -11874,9 +11874,9 @@ fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const f
|
||||||
|
|
||||||
// Establish height.
|
// Establish height.
|
||||||
if (flip)
|
if (flip)
|
||||||
return P_GetSectorCeilingZAt(ss->sector, x, y) - dz - FixedMul(scale, offset + mobjinfo[mobjtype].height);
|
return (absolutez ? dz : P_GetSectorCeilingZAt(ss->sector, x, y) - dz) - FixedMul(scale, offset + mobjinfo[mobjtype].height);
|
||||||
else
|
else
|
||||||
return P_GetSectorFloorZAt(ss->sector, x, y) + dz + FixedMul(scale, offset);
|
return (absolutez ? dz : P_GetSectorFloorZAt(ss->sector, x, y) + dz) + FixedMul(scale, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
|
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
|
||||||
|
@ -11884,6 +11884,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
||||||
fixed_t dz = mthing->z << FRACBITS; // Base offset from the floor.
|
fixed_t dz = mthing->z << FRACBITS; // Base offset from the floor.
|
||||||
fixed_t offset = 0; // Specific scaling object offset.
|
fixed_t offset = 0; // Specific scaling object offset.
|
||||||
boolean flip = (!!(mobjinfo[mobjtype].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
|
boolean flip = (!!(mobjinfo[mobjtype].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
|
||||||
|
boolean absolutez = !!(mthing->options & MTF_ABSOLUTEZ);
|
||||||
|
|
||||||
switch (mobjtype)
|
switch (mobjtype)
|
||||||
{
|
{
|
||||||
|
@ -11939,7 +11940,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
||||||
offset += mthing->args[0] ? 0 : 24*FRACUNIT;
|
offset += mthing->args[0] ? 0 : 24*FRACUNIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dz + offset)) // Snap to the surfaces when there's no offset set.
|
if (!(dz + offset) && !absolutez) // Snap to the surfaces when there's no offset set.
|
||||||
{
|
{
|
||||||
if (flip)
|
if (flip)
|
||||||
return ONCEILINGZ;
|
return ONCEILINGZ;
|
||||||
|
@ -11947,7 +11948,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
|
||||||
return ONFLOORZ;
|
return ONFLOORZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return P_GetMobjSpawnHeight(mobjtype, x, y, dz, offset, flip, mthing->scale);
|
return P_GetMobjSpawnHeight(mobjtype, x, y, dz, offset, flip, mthing->scale, absolutez);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing)
|
static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing)
|
||||||
|
@ -13444,7 +13445,7 @@ void P_SpawnHoop(mapthing_t *mthing)
|
||||||
vector4_t v, res;
|
vector4_t v, res;
|
||||||
fixed_t x = mthing->x << FRACBITS;
|
fixed_t x = mthing->x << FRACBITS;
|
||||||
fixed_t y = mthing->y << FRACBITS;
|
fixed_t y = mthing->y << FRACBITS;
|
||||||
fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, 0, false, mthing->scale);
|
fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, 0, false, mthing->scale, mthing->options & MTF_ABSOLUTEZ);
|
||||||
|
|
||||||
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
|
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
|
||||||
hoopcenter->spawnpoint = mthing;
|
hoopcenter->spawnpoint = mthing;
|
||||||
|
@ -13571,7 +13572,7 @@ static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numi
|
||||||
itemtypes[r] = P_GetMobjtypeSubstitute(&dummything, itemtypes[r]);
|
itemtypes[r] = P_GetMobjtypeSubstitute(&dummything, itemtypes[r]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, mthing->options & MTF_OBJECTFLIP, mthing->scale);
|
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, mthing->options & MTF_OBJECTFLIP, mthing->scale, mthing->options & MTF_ABSOLUTEZ);
|
||||||
|
|
||||||
for (r = 0; r < numitems; r++)
|
for (r = 0; r < numitems; r++)
|
||||||
{
|
{
|
||||||
|
@ -13630,7 +13631,7 @@ static void P_SpawnItemCircle(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 n
|
||||||
itemtypes[i] = P_GetMobjtypeSubstitute(&dummything, itemtypes[i]);
|
itemtypes[i] = P_GetMobjtypeSubstitute(&dummything, itemtypes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, false, mthing->scale);
|
z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, 0, false, mthing->scale, mthing->options & MTF_ABSOLUTEZ);
|
||||||
|
|
||||||
for (i = 0; i < numitems; i++)
|
for (i = 0; i < numitems; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -491,7 +491,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing);
|
||||||
void P_MovePlayerToStarpost(INT32 playernum);
|
void P_MovePlayerToStarpost(INT32 playernum);
|
||||||
void P_AfterPlayerSpawn(INT32 playernum);
|
void P_AfterPlayerSpawn(INT32 playernum);
|
||||||
|
|
||||||
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale);
|
fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t dz, const fixed_t offset, const boolean flip, const fixed_t scale, const boolean absolutez);
|
||||||
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y);
|
fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y);
|
||||||
|
|
||||||
mobj_t *P_SpawnMapThing(mapthing_t *mthing);
|
mobj_t *P_SpawnMapThing(mapthing_t *mthing);
|
||||||
|
|
|
@ -2033,6 +2033,8 @@ static void ParseTextmapThingParameter(UINT32 i, const char *param, const char *
|
||||||
// Flags
|
// Flags
|
||||||
else if (fastcmp(param, "flip") && fastcmp("true", val))
|
else if (fastcmp(param, "flip") && fastcmp("true", val))
|
||||||
mapthings[i].options |= MTF_OBJECTFLIP;
|
mapthings[i].options |= MTF_OBJECTFLIP;
|
||||||
|
else if (fastcmp(param, "absolutez") && fastcmp("true", val))
|
||||||
|
mapthings[i].options |= MTF_ABSOLUTEZ;
|
||||||
|
|
||||||
else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9)
|
else if (fastncmp(param, "stringarg", 9) && strlen(param) > 9)
|
||||||
{
|
{
|
||||||
|
@ -6781,7 +6783,6 @@ static void P_ConvertBinaryThingTypes(void)
|
||||||
break;
|
break;
|
||||||
case 1704: //NiGHTS bumper
|
case 1704: //NiGHTS bumper
|
||||||
mapthings[i].pitch = 30 * (((mapthings[i].options & 15) + 9) % 12);
|
mapthings[i].pitch = 30 * (((mapthings[i].options & 15) + 9) % 12);
|
||||||
mapthings[i].options &= ~0xF;
|
|
||||||
break;
|
break;
|
||||||
case 1705: //Hoop
|
case 1705: //Hoop
|
||||||
case 1713: //Hoop (Customizable)
|
case 1713: //Hoop (Customizable)
|
||||||
|
@ -6790,7 +6791,6 @@ static void P_ConvertBinaryThingTypes(void)
|
||||||
mapthings[i].angle = (mapthings[i].extrainfo == 1) ? oldangle - 90 : ((oldangle >> 8)*360)/256;
|
mapthings[i].angle = (mapthings[i].extrainfo == 1) ? oldangle - 90 : ((oldangle >> 8)*360)/256;
|
||||||
mapthings[i].pitch = (mapthings[i].extrainfo == 1) ? oldangle / 360 : ((oldangle & 255)*360)/256;
|
mapthings[i].pitch = (mapthings[i].extrainfo == 1) ? oldangle / 360 : ((oldangle & 255)*360)/256;
|
||||||
mapthings[i].args[0] = (mapthings[i].type == 1705) ? 96 : (mapthings[i].options & 0xF)*16 + 32;
|
mapthings[i].args[0] = (mapthings[i].type == 1705) ? 96 : (mapthings[i].options & 0xF)*16 + 32;
|
||||||
mapthings[i].options &= ~0xF;
|
|
||||||
mapthings[i].type = 1713;
|
mapthings[i].type = 1713;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6818,6 +6818,9 @@ static void P_ConvertBinaryThingTypes(void)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear binary thing height hacks, to prevent interfering with UDMF-only flags
|
||||||
|
mapthings[i].options &= 0xF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue