From c3a8f452e2607ac502edba59ef45e63f62c6e1c9 Mon Sep 17 00:00:00 2001
From: LJ Sonic <lamr@free.fr>
Date: Wed, 20 Mar 2024 20:30:06 +0100
Subject: [PATCH] Fix equation slopes breaking with slopes farther than 32k FU
 away from the map center

---
 src/p_slopes.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/p_slopes.c b/src/p_slopes.c
index e75d36edef..fd741398b6 100644
--- a/src/p_slopes.c
+++ b/src/p_slopes.c
@@ -810,10 +810,10 @@ void P_InitSlopes(void)
 // Returns the height of the sloped plane at (x, y) as a fixed_t
 fixed_t P_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y)
 {
-	fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) +
-	               FixedMul(y - slope->o.y, slope->d.y);
+	fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) / 2 +
+	               FixedMul(y - slope->o.y, slope->d.y) / 2;
 
-	return slope->o.z + FixedMul(dist, slope->zdelta);
+	return slope->o.z + FixedMul(dist, slope->zdelta) * 2;
 }
 
 // Like P_GetSlopeZAt but falls back to z if slope is NULL
-- 
GitLab