From 0bf00aad359532c6b48c50210b478c9430d34444 Mon Sep 17 00:00:00 2001 From: James R <justsomejames2@gmail.com> Date: Thu, 15 Oct 2020 14:23:02 -0700 Subject: [PATCH] Condense variables, rename 'diff' to 'step' --- src/p_map.c | 16 +++++------ src/p_maputl.c | 74 ++++++++++++++++++++------------------------------ src/p_maputl.h | 6 ++-- 3 files changed, 41 insertions(+), 55 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 4d4a7ea672..be7f093874 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -58,8 +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; +static fixed_t tmfloorstep; +static fixed_t tmceilingstep; // keep track of the line that lowers the ceiling, // so missiles don't explode against sky hack walls @@ -1706,7 +1706,7 @@ static boolean PIT_CheckLine(line_t *ld) ceilingline = ld; tmceilingrover = openceilingrover; tmceilingslope = opentopslope; - tmceilingdiff = openceilingdiff; + tmceilingstep = openceilingstep; tmthing->ceilingdrop = openceilingdrop; } @@ -1715,7 +1715,7 @@ static boolean PIT_CheckLine(line_t *ld) tmfloorz = openbottom; tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; - tmfloordiff = openfloordiff; + tmfloorstep = openfloorstep; tmthing->floordrop = openfloordrop; } @@ -1806,8 +1806,8 @@ 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; + tmfloorstep = 0; + tmceilingstep = 0; // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. if (newsubsec->sector->ffloors) @@ -2542,7 +2542,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->ceilingdrop = 0; } - else if (tmceilingz < thingtop && tmceilingdiff <= maxstep) + else if (tmceilingz < thingtop && tmceilingstep <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; thing->ceilingrover = tmceilingrover; @@ -2556,7 +2556,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->floordrop = 0; } - else if (tmfloorz > thing->z && tmfloordiff <= maxstep) + else if (tmfloorz > thing->z && tmfloorstep <= maxstep) { thing->z = thing->floorz = tmfloorz; thing->floorrover = tmfloorrover; diff --git a/src/p_maputl.c b/src/p_maputl.c index a7e45b0160..733adc6ad3 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -279,10 +279,10 @@ 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; -fixed_t openfloordrop; +fixed_t openceilingstep; fixed_t openceilingdrop; +fixed_t openfloorstep; +fixed_t openfloordrop; // P_CameraLineOpening // P_LineOpening, but for camera @@ -437,6 +437,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) fixed_t topedge[2] = {0}; fixed_t botedge[2] = {0}; + int hi; + int lo; + if (linedef->sidenum[1] == 0xffff) { // single sided line @@ -475,59 +478,53 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) highceiling = INT32_MIN; lowfloor = INT32_MAX; opentopslope = openbottomslope = NULL; - openfloordiff = 0; - openceilingdiff = 0; + openceilingstep = 0; + openceilingdrop = 0; + openfloorstep = 0; + openfloordrop = 0; } else { // Set open and high/low values here fixed_t height[2]; const sector_t * sector[2] = { front, back }; - int high; - -#define low ! high - height[FRONT] = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); height[BACK] = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - high = ( height[0] < height[1] ); + hi = ( height[0] < height[1] ); + lo = ! hi; - opentop = height[low]; - highceiling = height[high]; - opentopslope = sector[low]->c_slope; + opentop = height[lo]; + highceiling = height[hi]; + opentopslope = sector[lo]->c_slope; if (mobj) { - openceilingdiff = ( thingtop - - P_GetSectorCeilingZAt(sector[low], cross.x, cross.y) ); - topedge[FRONT] = P_GetSectorCeilingZAt(front, cross.x, cross.y); topedge[BACK] = P_GetSectorCeilingZAt(back, cross.x, cross.y); - openceilingdrop = ( topedge[high] - topedge[low] ); + openceilingstep = ( thingtop - topedge[lo] ); + openceilingdrop = ( topedge[hi] - topedge[lo] ); } height[FRONT] = P_GetFloorZ(mobj, front, tmx, tmy, linedef); height[BACK] = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - high = ( height[0] < height[1] ); + hi = ( height[0] < height[1] ); + lo = ! hi; - openbottom = height[high]; - lowfloor = height[low]; - openbottomslope = sector[high]->f_slope; + openbottom = height[hi]; + lowfloor = height[lo]; + openbottomslope = sector[hi]->f_slope; if (mobj) { - openfloordiff = - ( P_GetSectorFloorZAt(sector[high], cross.x, cross.y) - mobj->z ); - botedge[FRONT] = P_GetSectorFloorZAt(front, cross.x, cross.y); botedge[BACK] = P_GetSectorFloorZAt(back, cross.x, cross.y); - openfloordrop = ( botedge[high] - botedge[low] ); + openfloorstep = ( botedge[hi] - mobj->z ); + openfloordrop = ( botedge[hi] - botedge[lo] ); } - -#undef low } if (mobj) @@ -583,13 +580,11 @@ 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; } } @@ -620,7 +615,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (polybottom < opentop && delta1 >= delta2) { - openceilingdiff = ( opentop - polybottom ); opentop = polybottom; } else if (polybottom < highceiling && delta1 >= delta2) @@ -630,7 +624,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (polytop > openbottom && delta1 < delta2) { - openfloordiff = ( polytop - openbottom ); openbottom = polytop; } else if (polytop > lowfloor && delta1 < delta2) @@ -660,9 +653,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) { INT32_MAX, INT32_MIN, NULL, NULL }, }; - int lo; - int hi; - const fixed_t oldopentop = opentop; const fixed_t oldopenbottom = openbottom; @@ -754,11 +744,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (open[lo].top <= oldopentop) { - opentop = open[lo].top; - openceilingrover = open[lo].ceilingrover; - openceilingdiff = ( thingtop - - P_GetFFloorBottomZAt(openceilingrover, cross.x, cross.y) ); - hi = ! lo; topedge[lo] = P_GetFFloorBottomZAt(open[lo].ceilingrover, cross.x, cross.y); @@ -768,6 +753,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) topedge[hi] = P_GetFFloorBottomZAt(open[hi].ceilingrover, cross.x, cross.y); } + opentop = open[lo].top; + openceilingrover = open[lo].ceilingrover; + openceilingstep = ( thingtop - topedge[lo] ); openceilingdrop = ( topedge[hi] - topedge[lo] ); } @@ -775,11 +763,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (open[hi].bottom >= oldopenbottom) { - openbottom = open[hi].bottom; - openfloorrover = open[hi].floorrover; - openfloordiff = - ( P_GetFFloorTopZAt(openfloorrover, cross.x, cross.y) - mobj->z ); - lo = ! hi; botedge[hi] = P_GetFFloorTopZAt(open[hi].floorrover, cross.x, cross.y); @@ -789,6 +772,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) botedge[lo] = P_GetFFloorTopZAt(open[lo].floorrover, cross.x, cross.y); } + openbottom = open[hi].bottom; + openfloorrover = open[hi].floorrover; + openfloorstep = ( botedge[hi] - mobj->z ); openfloordrop = ( botedge[hi] - botedge[lo] ); } } diff --git a/src/p_maputl.h b/src/p_maputl.h index 237170bacf..9349d0e53c 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -58,10 +58,10 @@ 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; -extern fixed_t openfloordrop; +extern fixed_t openceilingstep; extern fixed_t openceilingdrop; +extern fixed_t openfloorstep; +extern fixed_t openfloordrop; void P_LineOpening(line_t *plinedef, mobj_t *mobj); -- GitLab