Slope collision fixes

This commit is contained in:
RedEnchilada 2015-04-29 00:29:51 -05:00
parent 10ba850871
commit 776b5254e6
4 changed files with 46 additions and 12 deletions

View file

@ -296,6 +296,8 @@ extern fixed_t tmfloorz;
extern fixed_t tmceilingz; extern fixed_t tmceilingz;
extern mobj_t *tmfloorthing, *tmthing; extern mobj_t *tmfloorthing, *tmthing;
extern camera_t *mapcampointer; extern camera_t *mapcampointer;
extern fixed_t tmx;
extern fixed_t tmy;
/* cphipps 2004/08/30 */ /* cphipps 2004/08/30 */
extern void P_MapStart(void); extern void P_MapStart(void);

View file

@ -38,8 +38,8 @@
fixed_t tmbbox[4]; fixed_t tmbbox[4];
mobj_t *tmthing; mobj_t *tmthing;
static INT32 tmflags; static INT32 tmflags;
static fixed_t tmx; fixed_t tmx;
static fixed_t tmy; fixed_t tmy;
static precipmobj_t *tmprecipthing; static precipmobj_t *tmprecipthing;
static fixed_t preciptmbbox[4]; static fixed_t preciptmbbox[4];
@ -1208,8 +1208,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
// that contains the point. // that contains the point.
// Any contacted lines the step closer together // Any contacted lines the step closer together
// will adjust them. // will adjust them.
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->floorheight; tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->ceilingheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight;
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors) if (newsubsec->sector->ffloors)
@ -1945,13 +1945,23 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
{ {
if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep)
{ {
thing->z = tmceilingz - thing->height; thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (thingtop == thing->ceilingz && tmceilingz , thingtop && thingtop - tmceilingz <= maxstep)
{
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height;
thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->eflags |= MFE_JUSTSTEPPEDDOWN;
} }
} }
else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep)
{ {
thing->z = tmfloorz; thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else if (thing->z == thing->floorz && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->eflags |= MFE_JUSTSTEPPEDDOWN;
} }
} }

View file

@ -560,8 +560,8 @@ void P_LineOpening(line_t *linedef)
{ // Set open and high/low values here { // Set open and high/low values here
fixed_t frontheight, backheight; fixed_t frontheight, backheight;
frontheight = P_GetCeilingZ(tmthing, front, tmthing->x, tmthing->y, linedef); frontheight = P_GetCeilingZ(tmthing, front, tmx, tmy, linedef);
backheight = P_GetCeilingZ(tmthing, back, tmthing->x, tmthing->y, linedef); backheight = P_GetCeilingZ(tmthing, back, tmx, tmy, linedef);
if (frontheight < backheight) if (frontheight < backheight)
{ {
@ -574,8 +574,8 @@ void P_LineOpening(line_t *linedef)
highceiling = frontheight; highceiling = frontheight;
} }
frontheight = P_GetFloorZ(tmthing, front, tmthing->x, tmthing->y, linedef); frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef);
backheight = P_GetFloorZ(tmthing, back, tmthing->x, tmthing->y, linedef); backheight = P_GetFloorZ(tmthing, back, tmx, tmy, linedef);
if (frontheight > backheight) if (frontheight > backheight)
{ {

View file

@ -747,7 +747,7 @@ fixed_t P_GetFloorZ(mobj_t *mobj, sector_t *sector, fixed_t x, fixed_t y, line_t
if (slope->zdelta > 0) { if (slope->zdelta > 0) {
testx = -testx; testx = -testx;
testx = -testy; testy = -testy;
} }
testx += x; testx += x;
@ -775,6 +775,17 @@ fixed_t P_GetFloorZ(mobj_t *mobj, sector_t *sector, fixed_t x, fixed_t y, line_t
v2.x = line->v2->x; v2.x = line->v2->x;
v2.y = line->v2->y; v2.y = line->v2->y;
/*CONS_Printf("BEFORE: v1 = %f %f %f\n",
FIXED_TO_FLOAT(v1.x),
FIXED_TO_FLOAT(v1.y),
FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y))
);
CONS_Printf(" v2 = %f %f %f\n",
FIXED_TO_FLOAT(v2.x),
FIXED_TO_FLOAT(v2.y),
FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y))
);*/
if (abs(v1.x-x) > mobj->radius) { if (abs(v1.x-x) > mobj->radius) {
// v1's x is out of range, so rein it in // v1's x is out of range, so rein it in
fixed_t diff = abs(v1.x-x) - mobj->radius; fixed_t diff = abs(v1.x-x) - mobj->radius;
@ -827,6 +838,17 @@ fixed_t P_GetFloorZ(mobj_t *mobj, sector_t *sector, fixed_t x, fixed_t y, line_t
} }
} }
/*CONS_Printf("AFTER: v1 = %f %f %f\n",
FIXED_TO_FLOAT(v1.x),
FIXED_TO_FLOAT(v1.y),
FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y))
);
CONS_Printf(" v2 = %f %f %f\n",
FIXED_TO_FLOAT(v2.x),
FIXED_TO_FLOAT(v2.y),
FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y))
);*/
// Return the higher of the two points // Return the higher of the two points
return max( return max(
P_GetZAt(slope, v1.x, v1.y), P_GetZAt(slope, v1.x, v1.y),
@ -860,7 +882,7 @@ fixed_t P_GetCeilingZ(mobj_t *mobj, sector_t *sector, fixed_t x, fixed_t y, line
if (slope->zdelta < 0) { if (slope->zdelta < 0) {
testx = -testx; testx = -testx;
testx = -testy; testy = -testy;
} }
testx += x; testx += x;