Cleaned up GetMobjSpawnHeight a bit. Ring-likes no longer ignore MF_SPAWNCEILING, because why should they?

This commit is contained in:
MascaraSnake 2019-12-15 00:22:17 +01:00
parent c5d8fe4752
commit bcfd9fe504
1 changed files with 21 additions and 27 deletions

View File

@ -11551,18 +11551,16 @@ mapthing_t *huntemeralds[MAXHUNTEMERALDS];
INT32 numhuntemeralds; INT32 numhuntemeralds;
static fixed_t GetMobjSpawnHeight (const mobjtype_t i, const mapthing_t* mthing, const fixed_t x, const fixed_t y) static fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
{ {
subsector_t *ss = R_PointInSubsector(x, y); const subsector_t *ss = R_PointInSubsector(x, y);
fixed_t extraoffset = 0; fixed_t offset = mthing->z << FRACBITS;
fixed_t heightoffset = 0; boolean flip = (!!(mobjinfo[mobjtype].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
boolean flip;
switch (i) switch (mobjtype)
{ {
// Bumpers never spawn flipped. // Bumpers never spawn flipped.
case MT_NIGHTSBUMPER: case MT_NIGHTSBUMPER:
heightoffset = mthing->z*FRACUNIT;
flip = false; flip = false;
break; break;
@ -11578,38 +11576,34 @@ static fixed_t GetMobjSpawnHeight (const mobjtype_t i, const mapthing_t* mthing,
case MT_JETTBOMBER: case MT_JETTBOMBER:
case MT_JETTGUNNER: case MT_JETTGUNNER:
case MT_EGGMOBILE2: case MT_EGGMOBILE2:
heightoffset = mthing->z ? 0 : 33*FRACUNIT; if (!offset)
goto atend; offset = 33*FRACUNIT;
break;
case MT_EGGMOBILE: case MT_EGGMOBILE:
heightoffset = mthing->z ? 0 : 128*FRACUNIT; if (!offset)
goto atend; offset = 128*FRACUNIT;
break;
case MT_GOLDBUZZ: case MT_GOLDBUZZ:
case MT_REDBUZZ: case MT_REDBUZZ:
heightoffset = mthing->z ? 0 : 288*FRACUNIT; if (!offset)
goto atend; offset = 288*FRACUNIT;
break;
// Ring-like items, may float additional units with MTF_AMBUSH. // Ring-like items, may float additional units with MTF_AMBUSH.
case MT_SPIKEBALL: case MT_SPIKEBALL:
case MT_EMERALDSPAWN: case MT_EMERALDSPAWN:
case MT_TOKEN: case MT_TOKEN:
case MT_EMBLEM: case MT_EMBLEM:
weaponfloat: offset += mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0;
flip = mthing->options & MTF_OBJECTFLIP;
extraoffset = mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0;
heightoffset = mthing->z*FRACUNIT;
break; break;
// Remaining objects. // Remaining objects.
default: default:
if (P_WeaponOrPanel(i)) if (P_WeaponOrPanel(mobjtype))
goto weaponfloat; // Ring-like items don't use MF_SPAWNCEILING to consider flips. offset += mthing->options & MTF_AMBUSH ? 24 * FRACUNIT : 0;
atend:
heightoffset = mthing->z*FRACUNIT;
flip = (!!(mobjinfo[i].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
} }
if (heightoffset + extraoffset == 0) // Snap to the surfaces when there's no offset set. if (!offset) // Snap to the surfaces when there's no offset set.
{ {
if (flip) if (flip)
return ONCEILINGZ; return ONCEILINGZ;
@ -11623,13 +11617,13 @@ static fixed_t GetMobjSpawnHeight (const mobjtype_t i, const mapthing_t* mthing,
#ifdef ESLOPE #ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif #endif
ss->sector->ceilingheight) - extraoffset - heightoffset - mobjinfo[i].height; ss->sector->ceilingheight) - offset - mobjinfo[mobjtype].height;
else else
return ( return (
#ifdef ESLOPE #ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif #endif
ss->sector->floorheight) + extraoffset + heightoffset; ss->sector->floorheight) + offset;
} }
// //
@ -11894,7 +11888,7 @@ You should think about modifying the deathmatch starts to take full advantage of
// spawn it // spawn it
x = mthing->x << FRACBITS; x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS; y = mthing->y << FRACBITS;
z = GetMobjSpawnHeight(i, mthing, x, y); z = P_GetMobjSpawnHeight(i, mthing, x, y);
mobj = P_SpawnMobj(x, y, z, i); mobj = P_SpawnMobj(x, y, z, i);
mobj->spawnpoint = mthing; mobj->spawnpoint = mthing;