From 8cbdbdaf7085ec3f532e15d1a4a4693f78f350a8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 6 Apr 2016 13:19:09 +0200 Subject: [PATCH] - fixed: The PathTraverse and sight checking code may not assume that ceiling(x) == floor(x)+1. This will fail when a trace starts directly on a block boundary in which case x is a whole number. It should always use 'floor(x)+1' to ensure that the calculated point is at the right or upper edge of a block. --- src/p_maputl.cpp | 5 ++--- src/p_sight.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 97c2af104..1235915c2 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1452,7 +1452,7 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, if (mapex > mapx) { mapxstep = 1; - partialx = xs_CeilToInt(xt1) - xt1; + partialx = 1. - xt1 + xs_FloorToInt(xt1); ystep = (y2 - y1) / fabs(x2 - x1); } else if (mapex < mapx) @@ -1469,11 +1469,10 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, } yintercept = yt1 + partialx * ystep; - if (mapey > mapy) { mapystep = 1; - partialy = xs_CeilToInt(yt1) - yt1; + partialy = 1. - yt1 + xs_FloorToInt(yt1); xstep = (x2 - x1) / fabs(y2 - y1); } else if (mapey < mapy) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 57106b2cf..f8d2043fd 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -651,7 +651,7 @@ bool SightCheck::P_SightPathTraverse () if (mapex > mapx) { mapxstep = 1; - partialx = xs_CeilToInt(xt1) - xt1; + partialx = 1. - xt1 + xs_FloorToInt(xt1); ystep = (y2 - y1) / fabs(x2 - x1); } else if (mapex < mapx) @@ -671,7 +671,7 @@ bool SightCheck::P_SightPathTraverse () if (mapey > mapy) { mapystep = 1; - partialy = xs_CeilToInt(yt1) - yt1; + partialy = 1. - yt1 + xs_FloorToInt(yt1); xstep = (x2 - x1) / fabs(y2 - y1); } else if (mapey < mapy)