From 8f5ac9b73f1341d3590aa67962a56c4d52d46e2c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 17:44:05 +0200 Subject: [PATCH] - fixed a float/fixed mixup in R_PointOnSideSlow. --- src/p_glnodes.cpp | 2 +- src/p_maputl.cpp | 8 +++++--- src/r_defs.h | 11 ++++------- src/r_utility.h | 4 ++++ src/s_sound.cpp | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index e4993a273..480e76a53 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -1333,7 +1333,7 @@ CCMD(clearnodecache) // //========================================================================== -subsector_t *P_PointInSubsector (fixed_t x, fixed_t y) +subsector_t *P_PointInSubsector (double x, double y) { node_t *node; int side; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 088266656..a7ec7c042 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1791,12 +1791,14 @@ static AActor *RoughBlockCheck (AActor *mo, int index, void *param) // //========================================================================== -static int R_PointOnSideSlow(double x, double y, node_t *node) +static int R_PointOnSideSlow(double xx, double yy, node_t *node) { // [RH] This might have been faster than two multiplies and an // add on a 386/486, but it certainly isn't on anything newer than that. fixed_t dx; fixed_t dy; + fixed_t x = FloatToFixed(xx); + fixed_t y = FloatToFixed(yy); double left; double right; @@ -1815,8 +1817,8 @@ static int R_PointOnSideSlow(double x, double y, node_t *node) return node->dx > 0; } - dx = (FloatToFixed(x) - node->x); - dy = (FloatToFixed(y) - node->y); + dx = (x - node->x); + dy = (y - node->y); // Try to quickly decide by looking at sign bits. if ((node->dy ^ node->dx ^ dx ^ dy) & 0x80000000) diff --git a/src/r_defs.h b/src/r_defs.h index 984a726b4..3df88f195 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1574,20 +1574,17 @@ struct visstyle_t // not the same as R_PointInSubsector // //---------------------------------------------------------------------------------- -subsector_t *P_PointInSubsector(fixed_t x, fixed_t y); -inline sector_t *P_PointInSector(fixed_t x, fixed_t y) -{ - return P_PointInSubsector(x, y)->sector; -} +subsector_t *P_PointInSubsector(double x, double y); +sector_t *P_PointInSector(fixed_t x, fixed_t y) = delete; inline sector_t *P_PointInSector(const DVector2 &pos) { - return P_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y))->sector; + return P_PointInSubsector(pos.X, pos.Y)->sector; } inline sector_t *P_PointInSector(double X, double Y) { - return P_PointInSubsector(FLOAT2FIXED(X), FLOAT2FIXED(Y))->sector; + return P_PointInSubsector(X, Y)->sector; } inline DVector3 AActor::PosRelative(int portalgroup) const diff --git a/src/r_utility.h b/src/r_utility.h index 7df9c3606..f37fc01ee 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -55,6 +55,10 @@ inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node) { return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0; } +inline int R_PointOnSide(double x, double y, const node_t *node) +{ + return DMulScale32(FLOAT2FIXED(y) - node->y, node->dx, node->x - FLOAT2FIXED(x), node->dy) > 0; +} inline int R_PointOnSide(const DVector2 &pos, const node_t *node) { return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 51f4d8adb..f884b4be7 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -763,7 +763,7 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix if (!(i_compatflags & COMPATF_SECTORSOUNDS)) { // Are we inside the sector? If yes, the closest point is the one we're on. - if (P_PointInSector(*x, *y) == sec) + if (P_PointInSector(FIXED2DBL(*x), FIXED2DBL(*y)) == sec) { FVector3 p = players[consoleplayer].camera->SoundPos(); *x = FLOAT2FIXED(p.X);