From 776b5254e689e362276c815c7daad5d11f979c5c Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Wed, 29 Apr 2015 00:29:51 -0500 Subject: [PATCH] Slope collision fixes --- src/p_local.h | 2 ++ src/p_map.c | 22 ++++++++++++++++------ src/p_maputl.c | 8 ++++---- src/p_mobj.c | 26 ++++++++++++++++++++++++-- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 53e5b18b4..c3e21dbe9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -296,6 +296,8 @@ extern fixed_t tmfloorz; extern fixed_t tmceilingz; extern mobj_t *tmfloorthing, *tmthing; extern camera_t *mapcampointer; +extern fixed_t tmx; +extern fixed_t tmy; /* cphipps 2004/08/30 */ extern void P_MapStart(void); diff --git a/src/p_map.c b/src/p_map.c index 50f172798..31f0acc62 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -38,8 +38,8 @@ fixed_t tmbbox[4]; mobj_t *tmthing; static INT32 tmflags; -static fixed_t tmx; -static fixed_t tmy; +fixed_t tmx; +fixed_t tmy; static precipmobj_t *tmprecipthing; 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. // Any contacted lines the step closer together // will adjust them. - tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->floorheight; - tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, thing->x, thing->y, NULL); //newsubsec->sector->ceilingheight; + tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; + 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. 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) { - 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; } } 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; } } diff --git a/src/p_maputl.c b/src/p_maputl.c index 7641dd1eb..e9e0bb776 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -560,8 +560,8 @@ void P_LineOpening(line_t *linedef) { // Set open and high/low values here fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(tmthing, front, tmthing->x, tmthing->y, linedef); - backheight = P_GetCeilingZ(tmthing, back, tmthing->x, tmthing->y, linedef); + frontheight = P_GetCeilingZ(tmthing, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(tmthing, back, tmx, tmy, linedef); if (frontheight < backheight) { @@ -574,8 +574,8 @@ void P_LineOpening(line_t *linedef) highceiling = frontheight; } - frontheight = P_GetFloorZ(tmthing, front, tmthing->x, tmthing->y, linedef); - backheight = P_GetFloorZ(tmthing, back, tmthing->x, tmthing->y, linedef); + frontheight = P_GetFloorZ(tmthing, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(tmthing, back, tmx, tmy, linedef); if (frontheight > backheight) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 1be713bf4..d57e398ec 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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) { testx = -testx; - testx = -testy; + testy = -testy; } 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.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) { // v1's x is out of range, so rein it in 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 max( 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) { testx = -testx; - testx = -testy; + testy = -testy; } testx += x;