From 867b7767ef78f8553fdb0afa7378601562c18d3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 15 Jan 2016 12:56:27 +0100 Subject: [PATCH] - ignore COMPAT_POINTONSIDE in a few places where the side effects of the old P_PointOn*Side functions are either not needed or problematic: * the sight checking code needs to be as precise as possible and should not depend on some old semi-broken routines. (This is more a precision issue of these routines - P_PointOnDivlineSide removes the lower 8 bits of each value - than having an issue with returning the wrong side in some cases.) * for slope creations it is flat out wrong to use the old routines at all. * also ignore this in the modern (box-shaped) case of FPathTraverse::AddLineIntercepts. This functionality is new to ZDoom and therefore not subject to compatibility concerns. * the line-to-line teleporter. It seems the hideous fudging code was just there to work around the design issues of these functions, so let's better not ever call them here in the first place. * A_PainShootSkull: Its usage here does not depend on these issues. * P_ExplodeMissile: New code exclusive to ZDoom. * FPolyObj::CheckMobjBlocking All occurences in p_map.cpp have been left alone although most of them probably won't need the compatibility option either. --- src/g_doom/a_painelemental.cpp | 2 +- src/p_local.h | 12 ++++++++++++ src/p_maputl.cpp | 6 +++--- src/p_mobj.cpp | 2 +- src/p_sight.cpp | 10 +++++----- src/p_slopes.cpp | 4 ++-- src/p_teleport.cpp | 2 +- src/po_man.cpp | 2 +- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index b52224c0c2..f361fb78d0 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -103,7 +103,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int box.Top() < ld->bbox[BOXBOTTOM] || box.Bottom() > ld->bbox[BOXTOP])) { - if (P_PointOnLineSide(self->x,self->y,ld) != P_PointOnLineSide(x,y,ld)) + if (P_PointOnLineSidePrecise(self->x,self->y,ld) != P_PointOnLineSidePrecise(x,y,ld)) return; // line blocks trajectory // ^ } } diff --git a/src/p_local.h b/src/p_local.h index fd5064f3c3..e8cc5fde03 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -249,6 +249,12 @@ inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line) : DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; } +inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line) +{ + return DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; +} + + //========================================================================== // // P_PointOnDivlineSide @@ -267,6 +273,12 @@ inline int P_PointOnDivlineSide (fixed_t x, fixed_t y, const divline_t *line) : (DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0); } +inline int P_PointOnDivlineSidePrecise (fixed_t x, fixed_t y, const divline_t *line) +{ + return DMulScale32 (y-line->y, line->dx, line->x-x, line->dy) > 0; +} + + //========================================================================== // // P_MakeDivline diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index e6d5a99e6b..1d806d0449 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1056,13 +1056,13 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it break; } // Check if this side is facing the trace origin - if (P_PointOnDivlineSide (trace.x, trace.y, &line) == 0) + if (P_PointOnDivlineSidePrecise (trace.x, trace.y, &line) == 0) { numfronts++; // If it is, see if the trace crosses it - if (P_PointOnDivlineSide (line.x, line.y, &trace) != - P_PointOnDivlineSide (line.x + line.dx, line.y + line.dy, &trace)) + if (P_PointOnDivlineSidePrecise (line.x, line.y, &trace) != + P_PointOnDivlineSidePrecise (line.x + line.dx, line.y + line.dy, &trace)) { // It's a hit fixed_t frac = P_InterceptVector (&trace, &line); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 750cc18fba..bcaa778559 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1284,7 +1284,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (line != NULL && cl_missiledecals) { - int side = P_PointOnLineSide (mo->x, mo->y, line); + int side = P_PointOnLineSidePrecise (mo->x, mo->y, line); if (line->sidedef[side] == NULL) side ^= 1; if (line->sidedef[side] != NULL) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 135698b8bc..2d465aab54 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -132,7 +132,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) { int frontflag; - frontflag = P_PointOnLineSide(sightthing->x, sightthing->y, li); + frontflag = P_PointOnLineSidePrecise(sightthing->x, sightthing->y, li); //Check 3D FLOORS! for(int i=1;i<=2;i++) @@ -241,14 +241,14 @@ bool SightCheck::P_SightCheckLine (line_t *ld) return true; } ld->validcount = validcount; - if (P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace) == - P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace)) + if (P_PointOnDivlineSidePrecise (ld->v1->x, ld->v1->y, &trace) == + P_PointOnDivlineSidePrecise (ld->v2->x, ld->v2->y, &trace)) { return true; // line isn't crossed } P_MakeDivline (ld, &dl); - if (P_PointOnDivlineSide (trace.x, trace.y, &dl) == - P_PointOnDivlineSide (trace.x+trace.dx, trace.y+trace.dy, &dl)) + if (P_PointOnDivlineSidePrecise (trace.x, trace.y, &dl) == + P_PointOnDivlineSidePrecise (trace.x+trace.dx, trace.y+trace.dy, &dl)) { return true; // line isn't crossed } diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index c0b9b5ef0e..a3db265261 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -54,7 +54,7 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo sector_t *sec; secplane_t *plane; - if (P_PointOnLineSide (x, y, line) == 0) + if (P_PointOnLineSidePrecise (x, y, line) == 0) { sec = line->frontsector; } @@ -363,7 +363,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, z3 = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); vt3.Z = FIXED2FLOAT(z3); - if (P_PointOnLineSide(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) + if (P_PointOnLineSidePrecise(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) { vec1 = vt2 - vt3; vec2 = vt1 - vt3; diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 040aca9f48..380f5572d1 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -530,7 +530,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO int fudge = FUDGEFACTOR; // Make sure we are on correct side of exit linedef. - while (P_PointOnLineSide(x, y, l) != side && --fudge >= 0) + while (P_PointOnLineSidePrecise(x, y, l) != side && --fudge >= 0) { if (abs(l->dx) > abs(l->dy)) y -= (l->dx < 0) != side ? -1 : 1; diff --git a/src/po_man.cpp b/src/po_man.cpp index 727591bd51..98fbbcbcb1 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1231,7 +1231,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) // Best use the one facing the player and ignore the back side. if (ld->sidedef[1] != NULL) { - int side = P_PointOnLineSide(mobj->x, mobj->y, ld); + int side = P_PointOnLineSidePrecise(mobj->x, mobj->y, ld); if (ld->sidedef[side] != sd) { continue;