From 6fcdac494fc27b75503b1f47b9b772d252c5d12f Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 16 May 2015 00:02:01 -0500 Subject: [PATCH] Spawned things spawn relative to slope floor/ceiling heights now This was a headache. :< --- src/p_mobj.c | 108 ++++++++++++++++++++++++++++++++++++++++--------- src/p_setup.c | 14 +++++-- src/p_slopes.c | 34 +++++++++++++--- src/p_spec.c | 13 +----- 4 files changed, 131 insertions(+), 38 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 855e9355c..af832d585 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7306,8 +7306,16 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Make sure scale matches destscale immediately when spawned P_SetScale(mobj, mobj->destscale); - mobj->floorz = mobj->subsector->sector->floorheight; - mobj->ceilingz = mobj->subsector->sector->ceilingheight; + mobj->floorz = +#ifdef ESLOPE + mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) : +#endif + mobj->subsector->sector->floorheight; + mobj->ceilingz = +#ifdef ESLOPE + mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) : +#endif + mobj->subsector->sector->ceilingheight; // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -8364,7 +8372,11 @@ void P_SpawnMapThing(mapthing_t *mthing) return; ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS); - mthing->z = (INT16)((ss->sector->floorheight>>FRACBITS) + (mthing->options >> ZSHIFT)); + 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; @@ -8482,14 +8494,22 @@ void P_SpawnMapThing(mapthing_t *mthing) ss = R_PointInSubsector(x, y); if (i == MT_NIGHTSBUMPER) - z = ss->sector->floorheight + ((mthing->options >> ZSHIFT) << FRACBITS); + 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_SPECIALSPIKEBALL || P_WeaponOrPanel(i) || i == MT_EMERALDSPAWN || i == MT_EMMY) { if (mthing->options & MTF_OBJECTFLIP) { - z = ss->sector->ceilingheight; + 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; @@ -8500,7 +8520,11 @@ void P_SpawnMapThing(mapthing_t *mthing) } else { - z = ss->sector->floorheight; + 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; @@ -8520,9 +8544,17 @@ void P_SpawnMapThing(mapthing_t *mthing) // base positions if (flip) - z = ss->sector->ceilingheight - mobjinfo[i].height; + z = ( +#ifdef ESLOPE + ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : +#endif + ss->sector->ceilingheight) - mobjinfo[i].height; else - z = ss->sector->floorheight; + z = ( +#ifdef ESLOPE + ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : +#endif + ss->sector->floorheight); // offsetting if (mthing->options >> ZSHIFT) @@ -9036,7 +9068,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) // Screw these damn hoops, I need this thinker. //hoopcenter->flags |= MF_NOTHINK; - z += sec->floorheight; + z += +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight; hoopcenter->z = z - hoopcenter->height/2; @@ -9169,7 +9205,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; - z += sec->floorheight; + z += +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight; hoopcenter->z = z - hoopcenter->height/2; P_UnsetThingPosition(hoopcenter); @@ -9281,7 +9321,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) // Wing logo item. else if (mthing->type == mobjinfo[MT_NIGHTSWING].doomednum) { - z = sec->floorheight; + z = +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); @@ -9333,13 +9377,21 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) // Set proper height if (mthing->options & MTF_OBJECTFLIP) { - z = sec->ceilingheight - mobjinfo[ringthing].height; + z = ( +#ifdef ESLOPE + 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); } else { - z = sec->floorheight; + z = +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); } @@ -9393,13 +9445,21 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) { if (mthing->options & MTF_OBJECTFLIP) { - z = sec->ceilingheight - mobjinfo[ringthing].height - dist*r; + z = ( +#ifdef ESLOPE + sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : +#endif + sec->ceilingheight) - mobjinfo[ringthing].height - dist*r; if (mthing->options >> ZSHIFT) z -= ((mthing->options >> ZSHIFT) << FRACBITS); } else { - z = sec->floorheight + dist*r; + z = ( +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight) + dist*r; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); } @@ -9445,13 +9505,21 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) if (mthing->options & MTF_OBJECTFLIP) { - z = sec->ceilingheight - mobjinfo[ringthing].height - 64*FRACUNIT*r; + z = ( +#ifdef ESLOPE + sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : +#endif + sec->ceilingheight) - mobjinfo[ringthing].height - 64*FRACUNIT*r; if (mthing->options >> ZSHIFT) z -= ((mthing->options >> ZSHIFT) << FRACBITS); } else { - z = sec->floorheight + 64*FRACUNIT*r; + z = ( +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight) + 64*FRACUNIT*r; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); } @@ -9482,7 +9550,11 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) size = 192*FRACUNIT; } - z = sec->floorheight; + z = +#ifdef ESLOPE + sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : +#endif + sec->floorheight; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); diff --git a/src/p_setup.c b/src/p_setup.c index a75668b68..c836d601c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -892,9 +892,14 @@ static void P_LoadThings(lumpnum_t lumpnum) 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)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS) - ->sector->floorheight>>FRACBITS); + 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 @@ -2535,6 +2540,10 @@ boolean P_SetupLevel(boolean skipprecip) P_MapStart(); +#ifdef ESLOPE + P_ResetDynamicSlopes(); +#endif + P_LoadThings(lastloadedmaplumpnum + ML_THINGS); P_SpawnSecretItems(loademblems); @@ -2544,7 +2553,6 @@ boolean P_SetupLevel(boolean skipprecip) break; // set up world state - P_ResetDynamicSlopes(); P_SpawnSpecials(fromnetsave); if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) diff --git a/src/p_slopes.c b/src/p_slopes.c index 39eac6db7..e7d05768c 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -42,11 +42,6 @@ static pslope_t *dynslopes = NULL; -// Reset the dynamic slopes pointer -void P_ResetDynamicSlopes(void) { - dynslopes = NULL; -} - // Calculate line normal void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); @@ -722,6 +717,35 @@ void P_SetSlopesFromVertexHeights(lumpnum_t lumpnum) } #endif +// Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes +void P_ResetDynamicSlopes(void) { + size_t i; + + dynslopes = NULL; + + // We'll handle copy slopes later, after all the tag lists have been made. + // Yes, this means copied slopes won't affect things' spawning heights. Too bad for you. + for (i = 0; i < numlines; i++) + { + switch (lines[i].special) + { + case 386: + case 387: + case 388: + case 389: + case 390: + case 391: + case 392: + case 393: + P_SpawnSlope_Line(i); + break; + + default: + break; + } + } +} + diff --git a/src/p_spec.c b/src/p_spec.c index fe3deba30..b276d1c17 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6439,18 +6439,7 @@ void P_SpawnSpecials(INT32 fromnetsave) sectors[s].midmap = lines[i].frontsector->midmap; break; -#ifdef ESLOPE // Slope specials. TODO move these to a different spot, maybe? - case 386: - case 387: - case 388: - case 389: - case 390: - case 391: - case 392: - case 393: - P_SpawnSlope_Line(i); - break; - // SoM: Copy slopes +#ifdef ESLOPE // Slope copy specials. Handled here for sanity. case 394: case 395: case 396: