From 31ac81fe93cc390dc67712588f31fd200c29b5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Tue, 23 Sep 2025 22:39:47 +0200 Subject: [PATCH] Fix edge case when checking line in P_PathTraverse Ported from https://codeberg.org/Hanicef/Antimony/commit/31e8ba92383604f2ab4a0135812ddc71c24fb6a9 --- src/p_maputl.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index 1a0ebe7bf..3f318bf2e 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -1802,12 +1802,32 @@ boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, pos_x += hity_x; pos_y += hity_y; } - else + else if (FixedMul(hitx_x, hitx_x) + FixedMul(hitx_y, hitx_y) < FixedMul(hity_x, hity_x) + FixedMul(hity_y, hity_y)) { gridpos_x += dir_x; pos_x += hitx_x; pos_y += hitx_y; } + else + { + // we hit a corner, round down towards south-east + if (dir_x < 0 && dir_y > 0) + { + gridpos_y += dir_y; + } + else if (dir_x > 0 && dir_y < 0) + { + gridpos_x += dir_x; + } + else + { + gridpos_x += dir_x; + gridpos_y += dir_y; + } + + pos_x += hitx_x; + pos_y += hitx_y; + } if (flags & PT_ADDLINES) if (!P_BlockLinesIterator(gridpos_x, gridpos_y, PIT_AddLineIntercepts))