diff --git a/src/p_mobj.c b/src/p_mobj.c index 7df407db7..b31fb2dfe 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -791,8 +791,16 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) - return P_GetZAt(slope, testx, testy); + if (mobj->player) + { + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + return P_GetZAt(slope, testx, testy); + } + else + { + if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + return P_GetZAt(slope, testx, testy); + } // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) { @@ -867,8 +875,16 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) - return P_GetZAt(slope, testx, testy); + if (mobj->player) + { + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + return P_GetZAt(slope, testx, testy); + } + else + { + if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + return P_GetZAt(slope, testx, testy); + } // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point if (perfect) {