diff --git a/src/p_map.c b/src/p_map.c index 93c885241..c6044c6f9 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -58,6 +58,8 @@ mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) ffloor_t *tmfloorrover, *tmceilingrover; pslope_t *tmfloorslope, *tmceilingslope; +static fixed_t tmfloordiff; +static fixed_t tmceilingdiff; // keep track of the line that lowers the ceiling, // so missiles don't explode against sky hack walls @@ -1704,6 +1706,7 @@ static boolean PIT_CheckLine(line_t *ld) ceilingline = ld; tmceilingrover = openceilingrover; tmceilingslope = opentopslope; + tmceilingdiff = openceilingdiff; } if (openbottom > tmfloorz) @@ -1711,6 +1714,7 @@ static boolean PIT_CheckLine(line_t *ld) tmfloorz = openbottom; tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; + tmfloordiff = openfloordiff; } if (highceiling > tmdrpoffceilz) @@ -1800,6 +1804,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; + tmfloordiff = 0; + tmceilingdiff = 0; + // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. if (newsubsec->sector->ffloors) { @@ -2517,7 +2524,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } - else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) + else if (tmceilingz < thingtop && tmceilingdiff <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; thing->ceilingrover = tmceilingrover; @@ -2530,7 +2537,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } - else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) + else if (tmfloorz > thing->z && tmfloordiff <= maxstep) { thing->z = thing->floorz = tmfloorz; thing->floorrover = tmfloorrover; diff --git a/src/p_maputl.c b/src/p_maputl.c index de6feb143..a0ef680fb 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -279,6 +279,8 @@ fixed_t P_InterceptVector(divline_t *v2, divline_t *v1) fixed_t opentop, openbottom, openrange, lowfloor, highceiling; pslope_t *opentopslope, *openbottomslope; ffloor_t *openfloorrover, *openceilingrover; +fixed_t openfloordiff; +fixed_t openceilingdiff; // P_CameraLineOpening // P_LineOpening, but for camera @@ -424,6 +426,7 @@ void P_CameraLineOpening(line_t *linedef) void P_LineOpening(line_t *linedef, mobj_t *mobj) { sector_t *front, *back; + vertex_t cross; if (linedef->sidenum[1] == 0xffff) { @@ -432,6 +435,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } + P_ClosestPointOnLine(tmx, tmy, linedef, &cross); + // Treat polyobjects kind of like 3D Floors if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) { @@ -456,6 +461,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) highceiling = INT32_MIN; lowfloor = INT32_MAX; opentopslope = openbottomslope = NULL; + openfloordiff = 0; + openceilingdiff = 0; } else { // Set open and high/low values here @@ -492,6 +499,18 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = frontheight; openbottomslope = back->f_slope; } + + openfloordiff = + abs( + P_GetSectorFloorZAt(front, cross.x, cross.y) - + P_GetSectorFloorZAt(back, cross.x, cross.y) + ); + + openceilingdiff = + abs( + P_GetSectorCeilingZAt(front, cross.x, cross.y) - + P_GetSectorCeilingZAt(back, cross.x, cross.y) + ); } if (mobj) @@ -548,10 +567,16 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 > delta2) { // Below if (opentop > texbottom) + { + openceilingdiff = ( opentop - texbottom ); opentop = texbottom; + } } else { // Above if (openbottom < textop) + { + openfloordiff = ( textop - openbottom ); openbottom = textop; + } } } } @@ -579,14 +604,24 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); if (polybottom < opentop && delta1 >= delta2) + { + openceilingdiff = ( opentop - polybottom ); opentop = polybottom; + } else if (polybottom < highceiling && delta1 >= delta2) + { highceiling = polybottom; + } if (polytop > openbottom && delta1 < delta2) + { + openfloordiff = ( polytop - openbottom ); openbottom = polytop; + } else if (polytop > lowfloor && delta1 < delta2) + { lowfloor = polytop; + } } // otherwise don't do anything special, pretend there's nothing else there } diff --git a/src/p_maputl.h b/src/p_maputl.h index 1c071c2cd..1a885c586 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -58,6 +58,8 @@ void P_HitSpecialLines(mobj_t *thing, fixed_t x, fixed_t y, fixed_t momx, fixed_ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; +extern fixed_t openfloordiff; +extern fixed_t openceilingdiff; void P_LineOpening(line_t *plinedef, mobj_t *mobj);