Merge branch 'spawn_z_refactor' into udmf

This commit is contained in:
Nev3r 2019-12-11 11:28:44 +01:00
commit 55f9c74e08
2 changed files with 164 additions and 206 deletions

View file

@ -11550,6 +11550,80 @@ void P_MovePlayerToStarpost(INT32 playernum)
mapthing_t *huntemeralds[MAXHUNTEMERALDS];
INT32 numhuntemeralds;
static fixed_t GetMobjSpawnHeight (const mobjtype_t i, const mapthing_t* mthing, const fixed_t x, const fixed_t y)
{
subsector_t *ss = R_PointInSubsector(x, y);
fixed_t extraoffset = 0;
fixed_t heightoffset = 0;
boolean flip;
switch (i)
{
// Bumpers never spawn flipped.
case MT_NIGHTSBUMPER:
heightoffset = mthing->z*FRACUNIT;
flip = false;
break;
// Axis objects snap to the floor.
case MT_AXIS:
case MT_AXISTRANSFER:
case MT_AXISTRANSFERLINE:
return ONFLOORZ;
// Objects with a non-zero default height.
case MT_CRAWLACOMMANDER:
case MT_DETON:
case MT_JETTBOMBER:
case MT_JETTGUNNER:
case MT_EGGMOBILE2:
heightoffset = mthing->z ? 0 : 33*FRACUNIT;
goto atend;
case MT_EGGMOBILE:
heightoffset = mthing->z ? 0 : 128*FRACUNIT;
goto atend;
case MT_GOLDBUZZ:
case MT_REDBUZZ:
heightoffset = mthing->z ? 0 : 288*FRACUNIT;
goto atend;
// Ring-like items, may float additional units with MTF_AMBUSH.
case MT_SPIKEBALL:
case MT_EMERALDSPAWN:
case MT_TOKEN:
case MT_EMBLEM:
weaponfloat:
flip = mthing->options & MTF_OBJECTFLIP;
extraoffset = mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0;
heightoffset = mthing->z*FRACUNIT;
break;
// Remaining objects.
default:
if (P_WeaponOrPanel(i))
goto weaponfloat; // Ring-like items don't use MF_SPAWNCEILING to consider flips.
atend:
heightoffset = mthing->z*FRACUNIT;
flip = (!!(mobjinfo[i].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
}
// Establish height.
if (flip)
return (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - extraoffset - mobjinfo[i].height;
else
return (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + extraoffset + heightoffset;
}
//
// P_SpawnMapThing
// The fields of the mapthing should
@ -11560,7 +11634,6 @@ void P_SpawnMapThing(mapthing_t *mthing)
mobjtype_t i;
mobj_t *mobj;
fixed_t x, y, z;
subsector_t *ss;
boolean doangle = true;
if (!mthing->type)
@ -11685,13 +11758,6 @@ You should think about modifying the deathmatch starts to take full advantage of
if (gametype != GT_COOP)
return;
ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS);
mthing->z = (INT16)(((
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) :
#endif
ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT));
if (numhuntemeralds < MAXHUNTEMERALDS)
huntemeralds[numhuntemeralds++] = mthing;
return;
@ -11820,102 +11886,7 @@ You should think about modifying the deathmatch starts to take full advantage of
// spawn it
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
ss = R_PointInSubsector(x, y);
if (i == MT_NIGHTSBUMPER)
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight) + ((mthing->options >> ZSHIFT) << FRACBITS);
else if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE)
z = ONFLOORZ;
else if (i == MT_SPIKEBALL || P_WeaponOrPanel(i) || i == MT_EMERALDSPAWN || i == MT_TOKEN || i == MT_EMBLEM)
{
if (mthing->options & MTF_OBJECTFLIP)
{
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight);
if (mthing->options & MTF_AMBUSH) // Special flag for rings
z -= 24*FRACUNIT;
if (mthing->options >> ZSHIFT)
z -= (mthing->options >> ZSHIFT)*FRACUNIT;
z -= mobjinfo[i].height; //Don't forget the height!
}
else
{
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight);
if (mthing->options & MTF_AMBUSH) // Special flag for rings
z += 24*FRACUNIT;
if (mthing->options >> ZSHIFT)
z += (mthing->options >> ZSHIFT)*FRACUNIT;
}
if (z == ONFLOORZ)
mthing->z = 0;
else
mthing->z = (INT16)(z>>FRACBITS);
}
else
{
fixed_t offset = 0;
boolean flip = (!!(mobjinfo[i].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP));
// base positions
if (flip)
z = (
#ifdef ESLOPE
ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) :
#endif
ss->sector->ceilingheight) - mobjinfo[i].height;
else
z = (
#ifdef ESLOPE
ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) :
#endif
ss->sector->floorheight);
// offsetting
if (mthing->options >> ZSHIFT)
offset = ((mthing->options >> ZSHIFT) << FRACBITS);
else if (i == MT_CRAWLACOMMANDER || i == MT_DETON || i == MT_JETTBOMBER || i == MT_JETTGUNNER || i == MT_EGGMOBILE2)
offset = 33*FRACUNIT;
else if (i == MT_EGGMOBILE)
offset = 128*FRACUNIT;
else if (i == MT_GOLDBUZZ || i == MT_REDBUZZ)
offset = 288*FRACUNIT;
// applying offsets! (if any)
if (flip)
{
if (offset)
z -= offset;
else
z = ONCEILINGZ;
}
else
{
if (offset)
z += offset;
else
z = ONFLOORZ;
}
if (z == ONFLOORZ)
mthing->z = 0;
else
mthing->z = (INT16)(z>>FRACBITS);
}
z = GetMobjSpawnHeight(i, mthing, x, y);
mobj = P_SpawnMobj(x, y, z, i);
mobj->spawnpoint = mthing;
@ -12019,7 +11990,7 @@ You should think about modifying the deathmatch starts to take full advantage of
if (mthing->angle)
mobj->health = mthing->angle;
else
mobj->health = FixedMul(ss->sector->ceilingheight-ss->sector->floorheight, 3*(FRACUNIT/4))>>FRACBITS;
mobj->health = FixedMul(mobj->subsector->sector->ceilingheight - mobj->subsector->sector->floorheight, 3*(FRACUNIT/4))>>FRACBITS;
break;
case MT_METALSONIC_RACE:
case MT_METALSONIC_BATTLE:
@ -13105,7 +13076,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
mobj_t *hoopcenter;
INT16 spewangle;
z = mthing->options << FRACBITS;
z = mthing->z << FRACBITS;
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
@ -13245,8 +13216,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
INT32 hoopsize;
INT32 hoopplacement;
// Save our flags!
z = (mthing->options>>ZSHIFT) << FRACBITS;
z = mthing->z << FRACBITS;
hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER);
hoopcenter->spawnpoint = mthing;
@ -13388,8 +13358,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z -= (mthing->z << FRACBITS);
}
else
{
@ -13398,8 +13368,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight);
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z += (mthing->z << FRACBITS);
}
for (r = 1; r <= 5; r++)
@ -13448,8 +13418,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z -= (mthing->z << FRACBITS);
}
else
{
@ -13458,8 +13428,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight);
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z += (mthing->z << FRACBITS);
}
for (r = 1; r <= iterations; r++)
@ -13505,8 +13475,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z += (mthing->z << FRACBITS);
closestangle = FixedAngle(mthing->angle*FRACUNIT);
@ -13610,8 +13580,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->c_slope ? P_GetZAt(sec->c_slope, x, y) :
#endif
sec->ceilingheight) - mobjinfo[ringthing].height;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z -= (mthing->z << FRACBITS);
}
else
{
@ -13620,8 +13590,8 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
sec->f_slope ? P_GetZAt(sec->f_slope, x, y) :
#endif
sec->floorheight;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (mthing->z)
z += (mthing->z << FRACBITS);
}
if (mthing->options & MTF_AMBUSH) // Special flag for rings
@ -13632,8 +13602,6 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing, boolean bonustime)
z += 24*FRACUNIT;
}
mthing->z = (INT16)(z>>FRACBITS);
mobj = P_SpawnMobj(x, y, z, ringthing);
mobj->spawnpoint = mthing;

View file

@ -906,10 +906,6 @@ void P_ReloadRings(void)
{
mt->mobj = NULL;
// Z for objects Tails 05-26-2002
mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)
->sector->floorheight>>FRACBITS);
P_SpawnHoopsAndRings(mt, true);
}
}
@ -1013,13 +1009,11 @@ static void P_PrepareRawThings(UINT8 *data, size_t i)
nummapthings = i / (5 * sizeof (INT16));
mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL);
// Spawn axis points first so they are
// at the front of the list for fast searching.
mt = mapthings;
for (i = 0; i < nummapthings; i++, mt++)
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
{
mt->x = READINT16(data);
mt->y = READINT16(data);
mt->angle = READINT16(data);
mt->type = READUINT16(data);
mt->options = READUINT16(data);
@ -1027,17 +1021,10 @@ static void P_PrepareRawThings(UINT8 *data, size_t i)
mt->type &= 4095;
switch (mt->type)
{
case 1700: // MT_AXIS
case 1701: // MT_AXISTRANSFER
case 1702: // MT_AXISTRANSFERLINE
mt->mobj = NULL;
P_SpawnMapThing(mt);
break;
default:
break;
}
if (mt->type == 1705 || (mt->type == 750 && mt->extrainfo))
mt->z = mt->options; // NiGHTS Hoops use the full flags bits to set the height.
else
mt->z = mt->options >> ZSHIFT;
}
}
@ -1048,41 +1035,8 @@ static void P_PrepareThings(lumpnum_t lumpnum)
Z_Free(data);
}
static void P_LoadThings(boolean loademblems)
static void SpawnEmeraldHunt (void)
{
size_t i;
mapthing_t *mt;
// Loading the things lump itself into memory is now handled in P_PrepareThings, above
mt = mapthings;
numhuntemeralds = 0;
for (i = 0; i < nummapthings; i++, mt++)
{
sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector;
// Z for objects
mt->z = (INT16)(
#ifdef ESLOPE
mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) :
#endif
mtsector->floorheight)>>FRACBITS;
if (mt->type == 1700 // MT_AXIS
|| mt->type == 1701 // MT_AXISTRANSFER
|| mt->type == 1702) // MT_AXISTRANSFERLINE
continue; // These were already spawned
if (!loademblems && mt->type == mobjinfo[MT_EMBLEM].doomednum)
continue;
mt->mobj = NULL;
P_SpawnMapThing(mt);
}
// random emeralds for hunt
if (numhuntemeralds)
{
INT32 emer1, emer2, emer3;
INT32 timeout = 0; // keeps from getting stuck
@ -1124,7 +1078,48 @@ static void P_LoadThings(boolean loademblems)
huntemeralds[emer3]->y<<FRACBITS,
huntemeralds[emer3]->z<<FRACBITS, MT_EMERHUNT),
mobjinfo[MT_EMERHUNT].spawnstate+2);
}
static void P_LoadThings(boolean loademblems)
{
size_t i;
mapthing_t *mt;
// Spawn axis points first so they are at the front of the list for fast searching.
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
{
switch (mt->type)
{
case 1700: // MT_AXIS
case 1701: // MT_AXISTRANSFER
case 1702: // MT_AXISTRANSFERLINE
mt->mobj = NULL;
P_SpawnMapThing(mt);
break;
default:
break;
}
}
numhuntemeralds = 0;
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
{
if (mt->type == 1700 // MT_AXIS
|| mt->type == 1701 // MT_AXISTRANSFER
|| mt->type == 1702) // MT_AXISTRANSFERLINE
continue; // These were already spawned
if (!loademblems && mt->type == mobjinfo[MT_EMBLEM].doomednum)
continue;
mt->mobj = NULL;
P_SpawnMapThing(mt);
}
// random emeralds for hunt
if (numhuntemeralds)
SpawnEmeraldHunt();
if (metalrecording) // Metal Sonic gets no rings to distract him.
return;
@ -1140,11 +1135,6 @@ static void P_LoadThings(boolean loademblems)
|| mt->type == 1705 || mt->type == 1713) // hoops
{
mt->mobj = NULL;
// Z for objects Tails 05-26-2002
mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)
->sector->floorheight>>FRACBITS);
P_SpawnHoopsAndRings(mt, false);
}
}