Fix crash in K_BananaSlopeZ

This commit is contained in:
Sally Coolatta 2020-08-18 05:26:27 -04:00
parent 5259e57553
commit 1029c01b05

View file

@ -4634,24 +4634,32 @@ static fixed_t K_BananaSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t z,
{ {
fixed_t testx, testy; fixed_t testx, testy;
if (slope->d.x < 0) if (slope == NULL)
testx = radius;
else
testx = -radius;
if (slope->d.y < 0)
testy = radius;
else
testy = -radius;
if ((slope->zdelta > 0) ^ !!(ceiling))
{ {
testx = -testx; testx = x;
testy = -testy; testy = y;
} }
else
{
if (slope->d.x < 0)
testx = radius;
else
testx = -radius;
testx += x; if (slope->d.y < 0)
testy += y; testy = radius;
else
testy = -radius;
if ((slope->zdelta > 0) ^ !!(ceiling))
{
testx = -testx;
testy = -testy;
}
testx += x;
testy += y;
}
return P_GetZAt(slope, testx, testy, z); return P_GetZAt(slope, testx, testy, z);
} }
@ -4666,12 +4674,12 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z
if (flip) if (flip)
{ {
slope = sec->c_slope ? sec->c_slope : NULL; slope = sec->c_slope;
newz = K_BananaSlopeZ(slope, x, y, sec->ceilingheight, radius, true); newz = K_BananaSlopeZ(slope, x, y, sec->ceilingheight, radius, true);
} }
else else
{ {
slope = sec->f_slope ? sec->f_slope : NULL; slope = sec->f_slope;
newz = K_BananaSlopeZ(slope, x, y, sec->floorheight, radius, true); newz = K_BananaSlopeZ(slope, x, y, sec->floorheight, radius, true);
} }
@ -4718,7 +4726,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z
if (bottom < newz && abs(d1) < abs(d2)) if (bottom < newz && abs(d1) < abs(d2))
{ {
newz = bottom; newz = bottom;
slope = *rover->b_slope ? *rover->b_slope : NULL; slope = *rover->b_slope;
} }
} }
else else
@ -4742,7 +4750,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z
if (top > newz && abs(d1) < abs(d2)) if (top > newz && abs(d1) < abs(d2))
{ {
newz = top; newz = top;
slope = *rover->t_slope ? *rover->t_slope : NULL; slope = *rover->t_slope;
} }
} }
} }