From ef6430c23eaadca8a78285d82fa7a53b0e2495a1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 Feb 2016 20:34:53 +0000 Subject: [PATCH 01/23] Fix respawning rings on slopes --- src/p_mobj.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 25ae8815a..f240c40f2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8171,7 +8171,11 @@ void P_RespawnSpecials(void) if (mthing->options & MTF_OBJECTFLIP) { - z = ss->sector->ceilingheight - (mthing->options >> ZSHIFT) * FRACUNIT; + z = ( +#ifdef ESLOPE + ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : +#endif + ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT; if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z -= 24*FRACUNIT; @@ -8179,7 +8183,11 @@ void P_RespawnSpecials(void) } else { - z = ss->sector->floorheight + (mthing->options >> ZSHIFT) * FRACUNIT; + z = ( +#ifdef ESLOPE + ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : +#endif + ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT; if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z += 24*FRACUNIT; From b5673ed101741b44562e4466f1369558c16b5d54 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 Feb 2016 20:46:56 +0000 Subject: [PATCH 02/23] Fix player spawning on slopes --- src/p_mobj.c | 60 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index f240c40f2..30c061d1e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8357,7 +8357,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) fixed_t z; sector_t *sector; - + fixed_t floor, ceiling; player_t *p = &players[playernum]; mobj_t *mobj = p->mo; @@ -8373,19 +8373,31 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) // set Z height sector = R_PointInSubsector(x, y)->sector; + + floor = +#ifdef ESLOPE + sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : +#endif + sector->floorheight; + ceiling = +#ifdef ESLOPE + sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : +#endif + sector->ceilingheight; + if (mthing) { // Flagging a player's ambush will make them start on the ceiling // Objectflip inverts if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) { - z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; + z = ceiling - mobjinfo[MT_PLAYER].height; if (mthing->options >> ZSHIFT) z -= ((mthing->options >> ZSHIFT) << FRACBITS); } else { - z = sector->floorheight; + z = floor; if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); } @@ -8397,15 +8409,15 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) } } else - z = sector->floorheight; + z = floor; - if (z < sector->floorheight) - z = sector->floorheight; - else if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height) - z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; + if (z < floor) + z = floor; + else if (z > ceiling - mobjinfo[MT_PLAYER].height) + z = ceiling - mobjinfo[MT_PLAYER].height; - mobj->floorz = sector->floorheight; - mobj->ceilingz = sector->ceilingheight; + mobj->floorz = floor; + mobj->ceilingz = ceiling; P_UnsetThingPosition(mobj); mobj->x = x; @@ -8413,7 +8425,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) P_SetThingPosition(mobj); mobj->z = z; - if (mobj->z == sector->floorheight) + if (mobj->z == mobj->floorz) mobj->eflags |= MFE_ONGROUND; mobj->angle = angle; @@ -8425,6 +8437,7 @@ void P_MovePlayerToStarpost(INT32 playernum) { fixed_t z; sector_t *sector; + fixed_t floor, ceiling; player_t *p = &players[playernum]; mobj_t *mobj = p->mo; @@ -8436,14 +8449,25 @@ void P_MovePlayerToStarpost(INT32 playernum) P_SetThingPosition(mobj); sector = R_PointInSubsector(mobj->x, mobj->y)->sector; - z = p->starpostz << FRACBITS; - if (z < sector->floorheight) - z = sector->floorheight; - else if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height) - z = sector->ceilingheight - mobjinfo[MT_PLAYER].height; + floor = +#ifdef ESLOPE + sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : +#endif + sector->floorheight; + ceiling = +#ifdef ESLOPE + sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : +#endif + sector->ceilingheight; - mobj->floorz = sector->floorheight; - mobj->ceilingz = sector->ceilingheight; + z = p->starpostz << FRACBITS; + if (z < floor) + z = floor; + else if (z > ceiling - mobjinfo[MT_PLAYER].height) + z = ceiling - mobjinfo[MT_PLAYER].height; + + mobj->floorz = floor; + mobj->ceilingz = ceiling; mobj->z = z; if (mobj->z == mobj->floorz) From fa1bc5a09bb4ea7e69fc602d56b91d2ae685a651 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 Feb 2016 20:55:57 +0000 Subject: [PATCH 03/23] Whoops forgot this for last commit --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 30c061d1e..65b5f9a09 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8451,12 +8451,12 @@ void P_MovePlayerToStarpost(INT32 playernum) floor = #ifdef ESLOPE - sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : + sector->f_slope ? P_GetZAt(sector->f_slope, mobj->x, mobj->y) : #endif sector->floorheight; ceiling = #ifdef ESLOPE - sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : + sector->c_slope ? P_GetZAt(sector->c_slope, mobj->x, mobj->y) : #endif sector->ceilingheight; From 03470118cd8214d75f220e009b14375051a7e4ea Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 Feb 2016 20:57:35 +0000 Subject: [PATCH 04/23] Added missing ESLOPE ifdef from when I first did these fixes for slope compiling --- src/r_segs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index 04873b29c..591242693 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1479,9 +1479,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) maskedtextureheight = NULL; +#ifdef ESLOPE //initialize segleft and segright memset(&segleft, 0x00, sizeof(segleft)); memset(&segright, 0x00, sizeof(segright)); +#endif if (ds_p == drawsegs+maxdrawsegs) { From 3058648fdc1f0ec8723a0e2a273d66b067c575f2 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 16 Feb 2016 17:58:08 +0000 Subject: [PATCH 05/23] Fix elemental flame trails not spawning when going up slopes --- src/p_user.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 96841d7e0..d5ff80f6e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6193,6 +6193,14 @@ void P_ElementalFireTrail(player_t *player) { newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); +#ifdef ESLOPE + if (player->mo->standingslope) + { + ground = P_GetZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) + ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale); + } +#endif flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); P_SetTarget(&flame->target, player->mo); flame->angle = travelangle; From 3802ec33de3738426a48f751205240314de36a51 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 23 Feb 2016 22:53:24 +0000 Subject: [PATCH 06/23] Fixed how dying players who were standing on slopes just jump off to the side --- src/p_map.c | 29 +++++++++++++++++------------ src/p_mobj.c | 14 ++++++++++++-- src/p_slopes.c | 3 +++ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 7ff913a86..dff5c5bef 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2051,21 +2051,26 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->ceilingz = tmceilingz; #ifdef ESLOPE - // Assign thing's standingslope if needed - if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { - if (!startingonground && tmfloorslope) - P_HandleSlopeLanding(thing, tmfloorslope); + if (!(thing->flags & MF_NOCLIPHEIGHT)) + { + // Assign thing's standingslope if needed + if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { + if (!startingonground && tmfloorslope) + P_HandleSlopeLanding(thing, tmfloorslope); - if (thing->momz <= 0) - thing->standingslope = tmfloorslope; - } - else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { - if (!startingonground && tmceilingslope) - P_HandleSlopeLanding(thing, tmceilingslope); + if (thing->momz <= 0) + thing->standingslope = tmfloorslope; + } + else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { + if (!startingonground && tmceilingslope) + P_HandleSlopeLanding(thing, tmceilingslope); - if (thing->momz >= 0) - thing->standingslope = tmceilingslope; + if (thing->momz >= 0) + thing->standingslope = tmceilingslope; + } } + else // don't set standingslope if you're not going to clip against it + thing->standingslope = NULL; #endif thing->x = x; diff --git a/src/p_mobj.c b/src/p_mobj.c index 65b5f9a09..155d985e9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2077,8 +2077,13 @@ static boolean P_ZMovement(mobj_t *mo) I_Assert(!P_MobjWasRemoved(mo)); #ifdef ESLOPE - if (mo->standingslope && !P_IsObjectOnGround(mo)) + if (mo->standingslope) + { + if (mo->flags & MF_NOCLIPHEIGHT) + mo->standingslope = NULL; + else if (!P_IsObjectOnGround(mo)) P_SlopeLaunch(mo); + } #endif // Intercept the stupid 'fall through 3dfloors' bug @@ -2561,8 +2566,13 @@ static void P_PlayerZMovement(mobj_t *mo) return; #ifdef ESLOPE - if (mo->standingslope && !P_IsObjectOnGround(mo)) + if (mo->standingslope) + { + if (mo->flags & MF_NOCLIPHEIGHT) + mo->standingslope = NULL; + else if (!P_IsObjectOnGround(mo)) P_SlopeLaunch(mo); + } #endif // clip movement diff --git a/src/p_slopes.c b/src/p_slopes.c index 2d55cf194..797fe46b4 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1099,6 +1099,9 @@ void P_ButteredSlope(mobj_t *mo) if (!mo->standingslope) return; + if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) + return; // don't slide down slopes if you can't touch them or you're not affected by gravity + if (mo->player) { if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING)) return; // Don't slide on non-steep slopes unless spinning From 98fd5ca63b32f9060bdb3e117edc6297c544aea0 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 1 Mar 2016 19:55:13 +0000 Subject: [PATCH 07/23] Made some FOF-related seg code account for slopes, as requested by some TODOs The funny thing is you really can't see ANY change here unless you have a sloped FOF intersecting a sector floor/ceiling (and a second FOF on the other side), which has other problems anyway lol --- src/r_segs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 591242693..ccf70338e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2121,8 +2121,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (r2 = frontsector->ffloors; r2; r2 = r2->next) { - if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES) - || *r2->topheight < lowcut || *r2->bottomheight > highcut) ///TODO: make these account for slopes -Red + if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; if (r2->norender == leveltime) @@ -2154,9 +2153,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else low2 = lowslope2 = *r2->bottomheight; + if ((high2 < lowcut && highslope2 < lowcutslope) || (low2 > highcut && lowslope2 > highcutslope)) + continue; if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) continue; #else + if (*r2->topheight < lowcut || *r2->bottomheight > highcut) + continue; if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight) continue; #endif @@ -2201,8 +2204,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (r2 = backsector->ffloors; r2; r2 = r2->next) { - if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES) - || *r2->topheight < lowcut || *r2->bottomheight > highcut) ///TODO: make these account for slopes -Red + if (!(r2->flags & FF_EXISTS) || !(r2->flags & FF_RENDERSIDES)) continue; if (r2->norender == leveltime) @@ -2234,9 +2236,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else low2 = lowslope2 = *r2->bottomheight; + if ((high2 < lowcut && highslope2 < lowcutslope) || (low2 > highcut && lowslope2 > highcutslope)) + continue; if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) continue; #else + if (*r2->topheight < lowcut || *r2->bottomheight > highcut) + continue; if (*rover->topheight > *r2->topheight || *rover->bottomheight < *r2->bottomheight) continue; #endif From 2f539a4df98b43c318a7382e8664dc88e1751c9a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 7 Mar 2016 20:42:25 +0000 Subject: [PATCH 08/23] R_RenderThickSideRange now checks for slopes in the front sector's lightlist This appears to fix a few holes that have been known to appear with FOF slopes sometimes, dunno how they actually came about exactly but this apparently sorts them out --- src/r_segs.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index ccf70338e..8222a7268 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -673,7 +673,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t offsetvalue = 0; lightlist_t *light; r_lightlist_t *rlight; +#ifndef ESLOPE fixed_t lheight; +#endif line_t *newline = NULL; #ifdef ESLOPE // Render FOF sides kinda like normal sides, with the frac and step and everything @@ -751,9 +753,49 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) for (i = p = 0; i < dc_numlights; i++) { +#ifdef ESLOPE + fixed_t leftheight, rightheight; + fixed_t pfloorleft, pfloorright; +#endif light = &frontsector->lightlist[i]; rlight = &dc_lightlist[p]; +#ifdef ESLOPE + if (light->slope) { + leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y); + rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y); + } else + leftheight = rightheight = light->height; + if (*pfloor->b_slope) { + pfloorleft = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y); + pfloorright = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y); + } else + pfloorleft = pfloorright = *pfloor->bottomheight; + + if (leftheight < pfloorleft && rightheight < pfloorright) + continue; + + if (*pfloor->t_slope) { + pfloorleft = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y); + pfloorright = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y); + } else + pfloorleft = pfloorright = *pfloor->topheight; + + if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) + { + lightlist_t *nextlight = &frontsector->lightlist[i+1]; + if (nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height > pfloorleft + && nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height > pfloorright) + continue; + } + + leftheight -= viewz; + rightheight -= viewz; + rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); + rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + rlight->heightstep = (rlight->heightstep-rlight->height)/(ds->x2-ds->x1+1); + rlight->height -= rlight->heightstep; +#else if (light->height < *pfloor->bottomheight) continue; @@ -763,13 +805,29 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lheight = light->height;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : light->height; rlight->heightstep = -FixedMul (rw_scalestep, (lheight - viewz)); rlight->height = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->heightstep; +#endif rlight->flags = light->flags; - if (light->flags & FF_CUTLEVEL) { +#ifdef ESLOPE + if (*light->caster->b_slope) { + leftheight = P_GetZAt(*light->caster->b_slope, ds->leftpos.x, ds->leftpos.y); + rightheight = P_GetZAt(*light->caster->b_slope, ds->rightpos.x, ds->rightpos.y); + } else + leftheight = rightheight = light->caster->bottomheight; + + leftheight -= viewz; + rightheight -= viewz; + + rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); + rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(ds->x2-ds->x1+1); + rlight->botheight -= rlight->botheightstep; +#else lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; rlight->botheightstep = -FixedMul (rw_scalestep, (lheight - viewz)); rlight->botheight = (centeryfrac) - FixedMul((lheight - viewz), spryscale) - rlight->botheightstep; +#endif } rlight->lightlevel = *light->lightlevel; From 60ea2ecb77b4bb0926169d7bf879b2dfbf387a50 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 7 Mar 2016 21:02:35 +0000 Subject: [PATCH 09/23] Whoops, forgot these --- src/r_segs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_segs.c b/src/r_segs.c index 8222a7268..e31d570b6 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -814,7 +814,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) leftheight = P_GetZAt(*light->caster->b_slope, ds->leftpos.x, ds->leftpos.y); rightheight = P_GetZAt(*light->caster->b_slope, ds->rightpos.x, ds->rightpos.y); } else - leftheight = rightheight = light->caster->bottomheight; + leftheight = rightheight = *light->caster->bottomheight; leftheight -= viewz; rightheight -= viewz; From 436bcdf19aa9da266e421326e7129a848dd036a6 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Tue, 8 Mar 2016 23:43:43 -0800 Subject: [PATCH 10/23] Objectplace handles slopes. Sorry MI, I'm hijacking your branch for a bit. --- src/m_cheat.c | 85 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/src/m_cheat.c b/src/m_cheat.c index 473fbbf75..51b414df3 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -31,6 +31,7 @@ #include "v_video.h" #include "z_zone.h" +#include "p_slopes.h" #include "lua_script.h" #include "lua_hook.h" @@ -857,9 +858,19 @@ static void OP_CycleThings(INT32 amt) static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) { + sector_t *sec = player->mo->subsector->sector; + if (ceiling) { - if (((player->mo->subsector->sector->ceilingheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT))) +#ifdef ESLOPE + // Truncate position to match where mapthing would be when spawned + // (this applies to every further P_GetZAt call as well) + fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; +#else + fixed_t cheight = sec->ceilingheight; +#endif + + if (((cheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT))) { CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("low"), (1 << (16-ZSHIFT)), M_GetText("below top ceiling")); @@ -868,7 +879,12 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) } else { - if (((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS) >= (1 << (16-ZSHIFT))) +#ifdef ESLOPE + fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; +#else + fixed_t fheight = sec->floorheight; +#endif + if (((player->mo->z - fheight)>>FRACBITS) >= (1 << (16-ZSHIFT))) { CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"), (1 << (16-ZSHIFT)), M_GetText("above bottom floor")); @@ -881,6 +897,7 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean ceiling) { mapthing_t *mt = mapthings; + sector_t *sec = player->mo->subsector->sector; #ifdef HAVE_BLUA LUA_InvalidateMapthings(); @@ -913,9 +930,23 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mt->x = (INT16)(player->mo->x>>FRACBITS); mt->y = (INT16)(player->mo->y>>FRACBITS); if (ceiling) - mt->options = (UINT16)((player->mo->subsector->sector->ceilingheight - player->mo->z - player->mo->height)>>FRACBITS); + { +#ifdef ESLOPE + fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->ceilingheight; +#else + fixed_t cheight = sec->ceilingheight; +#endif + mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS); + } else - mt->options = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS); + { +#ifdef ESLOPE + fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->floorheight; +#else + fixed_t fheight = sec->floorheight; +#endif + mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); + } mt->options <<= ZSHIFT; mt->angle = (INT16)(FixedInt(AngleFixed(player->mo->angle))); @@ -969,6 +1000,13 @@ void OP_NightsObjectplace(player_t *player) { UINT16 angle = (UINT16)(player->anotherflyangle % 360); INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle + sector_t *sec = player->mo->subsector->sector; +#ifdef ESLOPE + fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; +#else + fixed_t fheight = sec->floorheight; +#endif + player->pflags |= PF_ATTACKDOWN; @@ -983,7 +1021,7 @@ void OP_NightsObjectplace(player_t *player) temp += 90; temp %= 360; - mt->options = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS); + mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); mt->angle = (INT16)(mt->angle+(INT16)((FixedInt(FixedDiv(temp*FRACUNIT, 360*(FRACUNIT/256))))<<8)); P_SpawnHoopsAndRings(mt); @@ -1117,6 +1155,33 @@ void OP_ObjectplaceMovement(player_t *player) else player->viewz = player->mo->z + player->viewheight; + // Display flag information + // Moved up so it always updates. + { + sector_t *sec = player->mo->subsector->sector; + + if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP)) + { +#ifdef ESLOPE + fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; +#else + fixed_t cheight = sec->ceilingheight; +#endif + op_displayflags = (UINT16)((cheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS); + } + else + { +#ifdef ESLOPE + fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; +#else + fixed_t fheight = sec->floorheight; +#endif + op_displayflags = (UINT16)((player->mo->z - fheight)>>FRACBITS); + } + op_displayflags <<= ZSHIFT; + op_displayflags |= (UINT16)cv_opflags.value; + } + if (player->pflags & PF_ATTACKDOWN) { // Are ANY objectplace buttons pressed? If no, remove flag. @@ -1182,16 +1247,6 @@ void OP_ObjectplaceMovement(player_t *player) CONS_Printf(M_GetText("Placed object type %d at %d, %d, %d, %d\n"), mt->type, mt->x, mt->y, mt->options>>ZSHIFT, mt->angle); } - - // Display flag information - { - if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP)) - op_displayflags = (UINT16)((player->mo->subsector->sector->ceilingheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS); - else - op_displayflags = (UINT16)((player->mo->z - player->mo->subsector->sector->floorheight)>>FRACBITS); - op_displayflags <<= ZSHIFT; - op_displayflags |= (UINT16)cv_opflags.value; - } } // From c67683eb0af0351396a93120b3f14199964ac983 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 12 Mar 2016 19:59:32 +0000 Subject: [PATCH 11/23] Fixed slope walls displaying sprites through them if they weren't completely above you Sadly this does not fix ALL sprite issues, but just some of them at the least --- src/r_segs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index e31d570b6..fdae62d50 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1859,7 +1859,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) { ds_p->silhouette = SIL_BOTTOM; #ifdef ESLOPE - ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); + if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + ds_p->bsilheight = INT32_MAX; + else + ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); #else ds_p->bsilheight = frontsector->floorheight; #endif @@ -1883,7 +1886,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) { ds_p->silhouette |= SIL_TOP; #ifdef ESLOPE - ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); + if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + ds_p->tsilheight = INT32_MIN; + else + ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); #else ds_p->tsilheight = frontsector->ceilingheight; #endif From accab7da6a05f79f5ea0e3d2db4a76ff4052f8da Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 12 Mar 2016 23:03:56 +0000 Subject: [PATCH 12/23] Fixed precipitation not checking for slopes --- src/p_mobj.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index f074917bf..90a7daa9b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3710,10 +3710,15 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) mobjsecsubsec = mobj->subsector->sector; else return; - mobj->floorz = mobjsecsubsec->floorheight; + mobj->floorz = +#ifdef ESLOPE + mobjsecsubsec->f_slope ? P_GetZAt(mobjsecsubsec->f_slope, mobj->x, mobj->y) : +#endif + mobjsecsubsec->floorheight; if (mobjsecsubsec->ffloors) { ffloor_t *rover; + fixed_t topheight; for (rover = mobjsecsubsec->ffloors; rover; rover = rover->next) { @@ -3724,8 +3729,15 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) if (!(rover->flags & FF_BLOCKOTHERS) && !(rover->flags & FF_SWIMMABLE)) continue; - if (*rover->topheight > mobj->floorz) - mobj->floorz = *rover->topheight; +#ifdef ESLOPE + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); + else +#endif + topheight = *rover->topheight; + + if (topheight > mobj->floorz) + mobj->floorz = topheight; } } } @@ -7768,6 +7780,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype { state_t *st; precipmobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + fixed_t starting_floorz; mobj->x = x; mobj->y = y; @@ -7786,8 +7799,16 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); - mobj->floorz = mobj->subsector->sector->floorheight; - mobj->ceilingz = mobj->subsector->sector->ceilingheight; + mobj->floorz = starting_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; mobj->z = z; mobj->momz = mobjinfo[type].speed; @@ -7797,7 +7818,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype CalculatePrecipFloor(mobj); - if (mobj->floorz != mobj->subsector->sector->floorheight) + if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7 || GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6 From e941687d4c0ebe229415da976c9a830ef0413f70 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 18 Mar 2016 20:33:16 +0000 Subject: [PATCH 13/23] R_RenderMaskedSegRange now checks for slopes in the sector lightlist in other words, midtexture rendering should now correctly account for slopes from FOFs that could affect lighting/colormap --- src/r_segs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index fdae62d50..72315982d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -360,10 +360,30 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) for (i = 0; i < dc_numlights; i++) { +#ifdef ESLOPE + fixed_t leftheight, rightheight; +#endif light = &frontsector->lightlist[i]; rlight = &dc_lightlist[i]; +#ifdef ESLOPE + if (light->slope) { + leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y); + rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y); + } else + leftheight = rightheight = light->height; + + leftheight -= viewz; + rightheight -= viewz; + + rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); + rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); + rlight->heightstep = (rlight->heightstep-rlight->height)/(ds->x2-ds->x1+1); + //if (x1 > ds->x1) + //rlight->height -= (x1 - ds->x1)*rlight->heightstep; +#else rlight->height = (centeryfrac) - FixedMul((light->height - viewz), spryscale); rlight->heightstep = -FixedMul(rw_scalestep, (light->height - viewz)); +#endif rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = light->extra_colormap; rlight->flags = light->flags; From 6623a9148e98ecdbeb6d0abff2ea80b728dd8f07 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 18 Mar 2016 23:58:58 +0000 Subject: [PATCH 14/23] Fix HOMs by actually bothering to check if either side of a seg has slopes for height-checking code --- src/r_bsp.c | 72 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index c87d8baa7..cd32b7863 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -460,26 +460,64 @@ static void R_AddLine(seg_t *line) // Closed door. #ifdef ESLOPE - // Just don't bother checking this if one side is sloped. This is probably inefficient, but it's better than - // random renderer stopping around slopes... - if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope)) -#endif - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) + if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { - goto clipsolid; + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends + fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + if (slope) { \ + end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \ + end2 = P_GetZAt(slope, line->v2->x, line->v2->y); \ + } else \ + end1 = end2 = normalheight; + + SLOPEPARAMS(frontsector->f_slope, frontf1, frontf2, frontsector->floorheight) + SLOPEPARAMS(frontsector->c_slope, frontc1, frontc2, frontsector->ceilingheight) + SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector->floorheight) + SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight) +#undef SLOPEPARAMS + if ((backc1 <= frontf1 && backc2 <= frontf2) + || (backf1 >= frontc1 && backf2 >= frontc2)) + { + goto clipsolid; + } + + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) + && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); + + if (doorclosed) + goto clipsolid; + + // Window. + if (backc1 != frontc1 || backc2 != frontc2 + || backf1 != frontf1 || backf2 != frontf2) + { + goto clippass; + } } - - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = R_DoorClosed(); - if (doorclosed) - goto clipsolid; - - // Window. - if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) + else +#endif { - goto clippass; + if (backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight) + { + goto clipsolid; + } + + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = R_DoorClosed(); + if (doorclosed) + goto clipsolid; + + // Window. + if (backsector->ceilingheight != frontsector->ceilingheight + || backsector->floorheight != frontsector->floorheight) + { + goto clippass; + } } // Reject empty lines used for triggers and special events. From a82c19adb1cb68e78f7eeb12e09e2c58d99f0cb1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 19 Mar 2016 16:19:58 +0000 Subject: [PATCH 15/23] Fix sprites displaying behind "closed doors" when slopes are present. For the record, thok barriers count as "closed doors" in SRB2 level contexts --- src/r_segs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 72315982d..9ecb7708e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1947,21 +1947,25 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->silhouette |= SIL_TOP; } -#ifdef ESLOPE - // This causes issues with slopes. - if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope)) -#endif //SoM: 3/25/2000: This code fixes an automap bug that didn't check // frontsector->ceiling and backsector->floor to see if a door was closed. // Without the following code, sprites get displayed behind closed doors. { +#ifdef ESLOPE + if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)) +#else if (doorclosed || backsector->ceilingheight <= frontsector->floorheight) +#endif { ds_p->sprbottomclip = negonearray; ds_p->bsilheight = INT32_MAX; ds_p->silhouette |= SIL_BOTTOM; } +#ifdef ESLOPE + if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope)) +#else if (doorclosed || backsector->floorheight >= frontsector->ceilingheight) +#endif { // killough 1/17/98, 2/8/98 ds_p->sprtopclip = screenheightarray; ds_p->tsilheight = INT32_MIN; From 28631c30b70f89e337f8bd0a4ca9c0d5e3de59a7 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 19 Mar 2016 22:25:49 +0000 Subject: [PATCH 16/23] Fix maskedtextureheight being set outside of ESLOPE code --- src/r_segs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 9ecb7708e..9689f43df 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1555,9 +1555,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) #endif static size_t maxdrawsegs = 0; - maskedtextureheight = NULL; - #ifdef ESLOPE + maskedtextureheight = NULL; //initialize segleft and segright memset(&segleft, 0x00, sizeof(segleft)); memset(&segright, 0x00, sizeof(segright)); From ec5b272fa6ea8641b7d6d5d32c80f58cea74ea80 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 19 Mar 2016 23:19:05 +0000 Subject: [PATCH 17/23] Unless I'm mistaken, scalesteps/heightsteps should be divided by stop-start, not stop-start+1. Revert this commit if that was intentional. --- src/r_segs.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 9689f43df..02b243d4d 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -288,6 +288,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) line_t *ldef; sector_t *front, *back; INT32 times, repeats; + INT32 range; // Calculate light table. // Use different light tables @@ -334,6 +335,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) colfunc = fuzzcolfunc; } + range = max(ds->x2-ds->x1, 1); rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -377,7 +379,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); - rlight->heightstep = (rlight->heightstep-rlight->height)/(ds->x2-ds->x1+1); + rlight->heightstep = (rlight->heightstep-rlight->height)/(range); //if (x1 > ds->x1) //rlight->height -= (x1 - ds->x1)*rlight->heightstep; #else @@ -693,6 +695,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t offsetvalue = 0; lightlist_t *light; r_lightlist_t *rlight; + INT32 range; #ifndef ESLOPE fixed_t lheight; #endif @@ -757,6 +760,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else if (pfloor->flags & FF_FOG) colfunc = R_DrawFogColumn_8; + range = max(ds->x2-ds->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -813,7 +817,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rightheight -= viewz; rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); - rlight->heightstep = (rlight->heightstep-rlight->height)/(ds->x2-ds->x1+1); + rlight->heightstep = (rlight->heightstep-rlight->height)/(range); rlight->height -= rlight->heightstep; #else if (light->height < *pfloor->bottomheight) @@ -841,7 +845,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); - rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(ds->x2-ds->x1+1); + rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); rlight->botheight -= rlight->botheightstep; #else lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; @@ -951,8 +955,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) top_step = centeryfrac - FixedMul(right_top, ds->scale2); bottom_step = centeryfrac - FixedMul(right_bottom, ds->scale2); - top_step = (top_step-top_frac)/(ds->x2-ds->x1+1); - bottom_step = (bottom_step-bottom_frac)/(ds->x2-ds->x1+1); + top_step = (top_step-top_frac)/(range); + bottom_step = (bottom_step-bottom_frac)/(range); top_frac += top_step * (x1 - ds->x1); bottom_frac += bottom_step * (x1 - ds->x1); @@ -1549,6 +1553,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) INT32 i, p; lightlist_t *light; r_lightlist_t *rlight; + INT32 range; #ifdef ESLOPE vertex_t segleft, segright; fixed_t ceilingfrontslide, floorfrontslide, ceilingbackslide, floorbackslide; @@ -1633,7 +1638,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (stop > start) { ds_p->scale2 = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[stop]); - ds_p->scalestep = rw_scalestep = (ds_p->scale2 - rw_scale) / (stop-start); + range = stop-start; } else { @@ -1654,8 +1659,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) } #endif ds_p->scale2 = ds_p->scale1; + range = 1; } + ds_p->scalestep = rw_scalestep = (ds_p->scale2 - rw_scale) / (range); + // calculate texture boundaries // and decide if floor / ceiling marks are needed #ifdef ESLOPE @@ -2531,11 +2539,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE if (frontsector->c_slope) { fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); - topstep = (topfracend-topfrac)/(stop-start+1); + topstep = (topfracend-topfrac)/(range); } if (frontsector->f_slope) { fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); - bottomstep = (bottomfracend-bottomfrac)/(stop-start+1); + bottomstep = (bottomfracend-bottomfrac)/(range); } #endif @@ -2596,7 +2604,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); - rlight->heightstep = (rlight->heightstep-rlight->height)/(stop-start+1); + rlight->heightstep = (rlight->heightstep-rlight->height)/(range); #else rlight->height = (centeryfrac>>4) - FixedMul((light->height - viewz) >> 4, rw_scale); rlight->heightstep = -FixedMul (rw_scalestep, (light->height - viewz) >> 4); @@ -2623,7 +2631,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rlight->botheight = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); rlight->botheightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); - rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(stop-start+1); + rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); #else rlight->botheight = (centeryfrac >> 4) - FixedMul((*light->caster->bottomheight - viewz) >> 4, rw_scale); @@ -2652,7 +2660,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE ffloor[i].f_pos_slope >>= 4; ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); - ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(stop-start+1); + ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range); #else ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); @@ -2681,7 +2689,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE if (backsector->c_slope) { fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldhighslope, ds_p->scale2); - pixhighstep = (topfracend-pixhigh)/(stop-start+1); + pixhighstep = (topfracend-pixhigh)/(range); } #endif } @@ -2697,7 +2705,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) #ifdef ESLOPE if (backsector->f_slope) { fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); - pixlowstep = (bottomfracend-pixlow)/(stop-start+1); + pixlowstep = (bottomfracend-pixlow)/(range); } #endif } @@ -2739,7 +2747,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); + ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); i++; } @@ -2761,7 +2769,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); + ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); i++; } #else @@ -2824,7 +2832,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); + ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); i++; } @@ -2846,7 +2854,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); ffloor[i].b_step = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos_slope, ds_p->scale2); - ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(stop-start+1); + ffloor[i].b_step = (ffloor[i].b_step-ffloor[i].b_frac)/(range); i++; } #else From 6bda1a57a57f0367a97f13b21d38c4ddc37427a5 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 29 Mar 2016 15:40:01 +0100 Subject: [PATCH 18/23] Fix FOF plane light underside checks --- src/r_bsp.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/r_bsp.c b/src/r_bsp.c index cd32b7863..7f64e0cbd 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1002,7 +1002,7 @@ static void R_Subsector(size_t num) || (viewz > heightcheck && (rover->flags & FF_BOTHPLANES)))) { light = R_GetPlaneLight(frontsector, planecenterz, - viewz < *rover->bottomheight); + viewz < heightcheck); ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, @@ -1020,12 +1020,7 @@ static void R_Subsector(size_t num) frontsector->hasslope = true; #endif - ffloor[numffloors].height = -#ifdef ESLOPE - *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : -#endif - *rover->bottomheight; - + ffloor[numffloors].height = heightcheck; ffloor[numffloors].ffloor = rover; numffloors++; } @@ -1050,7 +1045,7 @@ static void R_Subsector(size_t num) && ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES)) || (viewz < heightcheck && (rover->flags & FF_BOTHPLANES)))) { - light = R_GetPlaneLight(frontsector, planecenterz, viewz < *rover->topheight); + light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck); ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, @@ -1068,12 +1063,7 @@ static void R_Subsector(size_t num) frontsector->hasslope = true; #endif - ffloor[numffloors].height = -#ifdef ESLOPE - *rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : -#endif - *rover->topheight; - + ffloor[numffloors].height = heightcheck; ffloor[numffloors].ffloor = rover; numffloors++; } From ef832dd8b815ec6a8753cf5515f3a72c9ba3a3ac Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 29 Mar 2016 18:59:56 +0100 Subject: [PATCH 19/23] Fixed how two adjacent FOFs can prevent each others' walls from displaying if they're at least partially covered Also some miscellaneous tweaks and changes to account for slopes properly --- src/r_segs.c | 58 ++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 02b243d4d..1f5477ecf 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2248,9 +2248,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else low2 = lowslope2 = *r2->bottomheight; - if ((high2 < lowcut && highslope2 < lowcutslope) || (low2 > highcut && lowslope2 > highcutslope)) + if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; - if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) + if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) continue; #else if (*r2->topheight < lowcut || *r2->bottomheight > highcut) @@ -2331,9 +2331,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) } else low2 = lowslope2 = *r2->bottomheight; - if ((high2 < lowcut && highslope2 < lowcutslope) || (low2 > highcut && lowslope2 > highcutslope)) + if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; - if ((high1 > high2 && highslope1 > highslope2) || (low1 < low2 && lowslope1 < lowslope2)) + if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) continue; #else if (*r2->topheight < lowcut || *r2->bottomheight > highcut) @@ -2679,7 +2679,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldhigh < worldtop #ifdef ESLOPE - || worldhighslope <= worldtopslope + || worldhighslope < worldtopslope #endif ) { @@ -2696,7 +2696,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldlow > worldbottom #ifdef ESLOPE - || worldlowslope >= worldbottomslope + || worldlowslope > worldbottomslope #endif ) { @@ -2713,7 +2713,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { ffloor_t * rover; #ifdef ESLOPE - fixed_t rovertest; + fixed_t roverleft, roverright; fixed_t planevistest; #endif i = 0; @@ -2732,17 +2732,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) backsector->hasslope = true; - rovertest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, backsector->soundorg.x, backsector->soundorg.y) : *rover->bottomheight) - viewz; + roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; + roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); - if (rovertest>>4 <= worldhigh && - rovertest>>4 >= worldlow && + if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) { //ffloor[i].slope = *rover->b_slope; - ffloor[i].b_pos = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - ffloor[i].b_pos_slope = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; + ffloor[i].b_pos = roverleft; + ffloor[i].b_pos_slope = roverright; ffloor[i].b_pos >>= 4; ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); @@ -2754,17 +2755,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - rovertest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, backsector->soundorg.x, backsector->soundorg.y) : *rover->topheight) - viewz; + roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; + roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); - if (rovertest>>4 <= worldhigh && - rovertest>>4 >= worldlow && + if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) { //ffloor[i].slope = *rover->t_slope; - ffloor[i].b_pos = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - ffloor[i].b_pos_slope = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; + ffloor[i].b_pos = roverleft; + ffloor[i].b_pos_slope = roverright; ffloor[i].b_pos >>= 4; ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); @@ -2817,17 +2819,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) frontsector->hasslope = true; - rovertest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->bottomheight) - viewz; + roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; + roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); - if (rovertest>>4 <= worldtop && - rovertest>>4 >= worldbottom && + if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && ((viewz < planevistest && !(rover->flags & FF_INVERTPLANES)) || (viewz > planevistest && (rover->flags & FF_BOTHPLANES)))) { //ffloor[i].slope = *rover->b_slope; - ffloor[i].b_pos = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - ffloor[i].b_pos_slope = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; + ffloor[i].b_pos = roverleft; + ffloor[i].b_pos_slope = roverright; ffloor[i].b_pos >>= 4; ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); @@ -2839,17 +2842,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - rovertest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->topheight) - viewz; + roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; + roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); - if (rovertest>>4 <= worldtop && - rovertest>>4 >= worldbottom && + if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && + (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && ((viewz > planevistest && !(rover->flags & FF_INVERTPLANES)) || (viewz < planevistest && (rover->flags & FF_BOTHPLANES)))) { //ffloor[i].slope = *rover->t_slope; - ffloor[i].b_pos = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - ffloor[i].b_pos_slope = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; + ffloor[i].b_pos = roverleft; + ffloor[i].b_pos_slope = roverright; ffloor[i].b_pos >>= 4; ffloor[i].b_pos_slope >>= 4; ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); From ee00da6a74a62c74a56722b7b70fc50aa45c7f05 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Tue, 29 Mar 2016 22:32:09 +0100 Subject: [PATCH 20/23] Another thing that probably needed to check for slopes --- src/r_segs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/r_segs.c b/src/r_segs.c index 1f5477ecf..66413c588 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2032,8 +2032,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) markceiling = false; } +#ifdef ESLOPE + if ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope) + || (worldlow >= worldtop && worldlowslope >= worldtopslope)) +#else if (backsector->ceilingheight <= frontsector->floorheight || backsector->floorheight >= frontsector->ceilingheight) +#endif { // closed door markceiling = markfloor = true; From e34da95c4c2bbfa8e706e52fc764859405eb49ad Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Thu, 31 Mar 2016 16:32:25 +0100 Subject: [PATCH 21/23] DEVMODE's automap now supports slopes --- src/am_map.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/am_map.c b/src/am_map.c index 97b7c5164..847e517fb 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -15,6 +15,7 @@ #include "am_map.h" #include "g_input.h" #include "p_local.h" +#include "p_slopes.h" #include "v_video.h" #include "i_video.h" #include "r_state.h" @@ -996,6 +997,10 @@ static inline void AM_drawWalls(void) { size_t i; static mline_t l; +#ifdef ESLOPE + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends + fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends +#endif for (i = 0; i < numlines; i++) { @@ -1003,6 +1008,22 @@ static inline void AM_drawWalls(void) l.a.y = lines[i].v1->y; l.b.x = lines[i].v2->x; l.b.y = lines[i].v2->y; +#ifdef ESLOPE +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + if (slope) { \ + end1 = P_GetZAt(slope, l.a.x, l.a.y); \ + end2 = P_GetZAt(slope, l.b.x, l.b.y); \ + } else \ + end1 = end2 = normalheight; + + SLOPEPARAMS(lines[i].frontsector->f_slope, frontf1, frontf2, lines[i].frontsector->floorheight) + SLOPEPARAMS(lines[i].frontsector->c_slope, frontc1, frontc2, lines[i].frontsector->ceilingheight) + if (lines[i].backsector) { + SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight) + SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight) + } +#undef SLOPEPARAMS +#endif // AM_drawMline(&l, GRAYS + 3); // Old, everything-is-gray automap if (!lines[i].backsector) // 1-sided @@ -1016,11 +1037,19 @@ static inline void AM_drawWalls(void) AM_drawMline(&l, WALLCOLORS+lightlev); } } +#ifdef ESLOPE + else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier + || (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier + { + if (backf1 == backc1 && backf2 == backc2 + && frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers +#else else if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight // Back is thok barrier || lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // Front is thok barrier { if (lines[i].backsector->floorheight == lines[i].backsector->ceilingheight && lines[i].frontsector->floorheight == lines[i].frontsector->ceilingheight) // BOTH are thok barriers +#endif { if (lines[i].flags & ML_NOCLIMB) { @@ -1046,12 +1075,20 @@ static inline void AM_drawWalls(void) else { if (lines[i].flags & ML_NOCLIMB) { +#ifdef ESLOPE + if (backf1 != frontf1 || backf2 != frontf2) { +#else if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) { +#endif AM_drawMline(&l, NOCLIMBFDWALLCOLORS + lightlev); // floor level change } +#ifdef ESLOPE + else if (backc1 != frontc1 || backc2 != frontc2) { +#else else if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) { +#endif AM_drawMline(&l, NOCLIMBCDWALLCOLORS+lightlev); // ceiling level change } else { @@ -1060,12 +1097,20 @@ static inline void AM_drawWalls(void) } else { +#ifdef ESLOPE + if (backf1 != frontf1 || backf2 != frontf2) { +#else if (lines[i].backsector->floorheight != lines[i].frontsector->floorheight) { +#endif AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change } +#ifdef ESLOPE + else if (backc1 != frontc1 || backc2 != frontc2) { +#else else if (lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight) { +#endif AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change } else { From b1e736242fceab97c0a868fd67154bd77bb67d87 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Wed, 6 Apr 2016 22:19:39 +0100 Subject: [PATCH 22/23] fixed all compiling errors relating to ESLOPE being undefined --- src/p_map.c | 4 ++++ src/p_maputl.c | 8 ++++++++ src/p_mobj.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/p_saveg.c | 10 ++++++++++ src/p_spec.c | 2 ++ src/r_main.c | 2 ++ src/r_segs.c | 14 +++++++++++++- 7 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 5cd601272..612f15220 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1146,13 +1146,17 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; +#ifdef ESLOPE tmceilingslope = opentopslope; +#endif } if (openbottom > tmfloorz) { tmfloorz = openbottom; +#ifdef ESLOPE tmfloorslope = openbottomslope; +#endif } if (highceiling > tmdrpoffceilz) diff --git a/src/p_maputl.c b/src/p_maputl.c index 82d9bbfe4..6bd94362f 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -527,13 +527,17 @@ void P_LineOpening(line_t *linedef) { opentop = frontheight; highceiling = backheight; +#ifdef ESLOPE opentopslope = front->c_slope; +#endif } else { opentop = backheight; highceiling = frontheight; +#ifdef ESLOPE opentopslope = back->c_slope; +#endif } frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef); @@ -543,13 +547,17 @@ void P_LineOpening(line_t *linedef) { openbottom = frontheight; lowfloor = backheight; +#ifdef ESLOPE openbottomslope = front->f_slope; +#endif } else { openbottom = backheight; lowfloor = frontheight; +#ifdef ESLOPE openbottomslope = back->f_slope; +#endif } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 2bab28bc6..9a33eb65c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -752,6 +752,7 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) return true; } +#ifdef ESLOPE // P_GetFloorZ (and its ceiling counterpart) // Gets the floor height (or ceiling height) of the mobj's contact point in sector, assuming object's center if moved to [x, y] // If line is supplied, it's a divider line on the sector. Set it to NULL if you're not checking for collision with a line @@ -855,10 +856,13 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, P_GetZAt(slope, v2.x, v2.y) ); } +#endif fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { +#ifdef ESLOPE I_Assert(mobj != NULL); +#endif I_Assert(sector != NULL); #ifdef ESLOPE if (sector->f_slope) { @@ -930,13 +934,23 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } else // Well, that makes it easy. Just get the floor height +#else + (void)mobj; + (void)boundsec; + (void)x; + (void)y; + (void)line; + (void)lowest; + (void)perfect; #endif return sector->floorheight; } fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { +#ifdef ESLOPE I_Assert(mobj != NULL); +#endif I_Assert(sector != NULL); #ifdef ESLOPE if (sector->c_slope) { @@ -1008,6 +1022,14 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } else // Well, that makes it easy. Just get the ceiling height +#else + (void)mobj; + (void)boundsec; + (void)x; + (void)y; + (void)line; + (void)lowest; + (void)perfect; #endif return sector->ceilingheight; } @@ -1015,7 +1037,9 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed // Now do the same as all above, but for cameras because apparently cameras are special? fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { +#ifdef ESLOPE I_Assert(mobj != NULL); +#endif I_Assert(sector != NULL); #ifdef ESLOPE if (sector->f_slope) { @@ -1087,13 +1111,23 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } else // Well, that makes it easy. Just get the floor height +#else + (void)mobj; + (void)boundsec; + (void)x; + (void)y; + (void)line; + (void)lowest; + (void)perfect; #endif return sector->floorheight; } fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { +#ifdef ESLOPE I_Assert(mobj != NULL); +#endif I_Assert(sector != NULL); #ifdef ESLOPE if (sector->c_slope) { @@ -1165,6 +1199,14 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f return HighestOnLine(mobj->radius, x, y, line, slope, lowest); } else // Well, that makes it easy. Just get the ceiling height +#else + (void)mobj; + (void)boundsec; + (void)x; + (void)y; + (void)line; + (void)lowest; + (void)perfect; #endif return sector->ceilingheight; } diff --git a/src/p_saveg.c b/src/p_saveg.c index e0112bb79..c38a1ebbe 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -924,8 +924,12 @@ typedef enum MD2_EXTVAL1 = 1<<5, MD2_EXTVAL2 = 1<<6, MD2_HNEXT = 1<<7, +#ifdef ESLOPE MD2_HPREV = 1<<8, MD2_SLOPE = 1<<9 +#else + MD2_HPREV = 1<<8 +#endif } mobj_diff2_t; typedef enum @@ -1115,8 +1119,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_HNEXT; if (mobj->hprev) diff2 |= MD2_HPREV; +#ifdef ESLOPE if (mobj->standingslope) diff2 |= MD2_SLOPE; +#endif if (diff2 != 0) diff |= MD_MORE; @@ -1232,8 +1238,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, mobj->hnext->mobjnum); if (diff2 & MD2_HPREV) WRITEUINT32(save_p, mobj->hprev->mobjnum); +#ifdef ESLOPE if (diff2 & MD2_SLOPE) WRITEUINT16(save_p, mobj->standingslope->id); +#endif WRITEUINT32(save_p, mobj->mobjnum); } @@ -2087,8 +2095,10 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->hnext = (mobj_t *)(size_t)READUINT32(save_p); if (diff2 & MD2_HPREV) mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p); +#ifdef ESLOPE if (diff2 & MD2_SLOPE) mobj->standingslope = P_SlopeById(READUINT16(save_p)); +#endif if (diff & MD_REDFLAG) diff --git a/src/p_spec.c b/src/p_spec.c index 76c3484c6..a903aa5a5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4672,8 +4672,10 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); +#ifdef ESLOPE // Dynamic slopeness P_RunDynamicSlopes(); +#endif // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) diff --git a/src/r_main.c b/src/r_main.c index a6b13302e..39958305d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -517,7 +517,9 @@ static void R_InitTextureMapping(void) focallength = FixedDiv(centerxfrac, FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2)); +#ifdef ESLOPE focallengthf = FIXED_TO_FLOAT(focallength); +#endif for (i = 0; i < FINEANGLES/2; i++) { diff --git a/src/r_segs.c b/src/r_segs.c index 6efac9028..fd0bde33b 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -288,7 +288,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) line_t *ldef; sector_t *front, *back; INT32 times, repeats; +#ifdef ESLOPE INT32 range; +#endif // Calculate light table. // Use different light tables @@ -335,7 +337,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) colfunc = fuzzcolfunc; } +#ifdef ESLOPE range = max(ds->x2-ds->x1, 1); +#endif rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -695,7 +699,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t offsetvalue = 0; lightlist_t *light; r_lightlist_t *rlight; +#ifdef ESLOPE INT32 range; +#endif #ifndef ESLOPE fixed_t lheight; #endif @@ -760,7 +766,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else if (pfloor->flags & FF_FOG) colfunc = R_DrawFogColumn_8; +#ifdef ESLOPE range = max(ds->x2-ds->x1, 1); +#endif //SoM: Moved these up here so they are available for my lightlist calculations rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; @@ -1192,7 +1200,9 @@ static void R_RenderSegLoop (void) INT32 mid; fixed_t texturecolumn = 0; +#ifdef ESLOPE fixed_t oldtexturecolumn = -1; +#endif INT32 top; INT32 bottom; INT32 i; @@ -1548,7 +1558,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) fixed_t hyp; fixed_t sineval; angle_t distangle, offsetangle; - //fixed_t vtop; +#ifndef ESLOPE + fixed_t vtop; +#endif INT32 lightnum; INT32 i, p; lightlist_t *light; From 0a887948eb456540a69a4de6cefdc5bae398311a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Apr 2016 18:48:14 +0100 Subject: [PATCH 23/23] Ensure pixhigh/pixlow is always set whenever the game decides a top/bottom texture should be drawn This fixes the rendering glitches encountered around slopes in Glacier Gear, yes. :) --- src/r_segs.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/r_segs.c b/src/r_segs.c index 574421fb0..3f11bb364 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2696,11 +2696,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldlowslope >>= 4; #endif - if (worldhigh < worldtop -#ifdef ESLOPE - || worldhighslope < worldtopslope -#endif - ) + if (toptexture) { pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); pixhighstep = -FixedMul (rw_scalestep,worldhigh); @@ -2713,11 +2709,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) #endif } - if (worldlow > worldbottom -#ifdef ESLOPE - || worldlowslope > worldbottomslope -#endif - ) + if (bottomtexture) { pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = -FixedMul (rw_scalestep,worldlow);