From 83e3510239b73e181e4130d490dba7c33cc8cde5 Mon Sep 17 00:00:00 2001
From: Ashnal <ashnal52@gmail.com>
Date: Sun, 12 Mar 2023 23:30:47 -0400
Subject: [PATCH] Fixed FV2_Magnitude to not overflow as much by just using
 FixedHypot internally

---
 src/m_fixed.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/m_fixed.c b/src/m_fixed.c
index 3724144f7..65235cbcc 100644
--- a/src/m_fixed.c
+++ b/src/m_fixed.c
@@ -223,9 +223,7 @@ fixed_t FV2_Distance(const vector2_t *p1, const vector2_t *p2)
 
 fixed_t FV2_Magnitude(const vector2_t *a_normal)
 {
-	fixed_t xs = FixedMul(a_normal->x, a_normal->x);
-	fixed_t ys = FixedMul(a_normal->y, a_normal->y);
-	return FixedSqrt(xs + ys);
+	return FixedHypot(a_normal->x, a_normal->y); // Much less prone to overflowing
 }
 
 // Also returns the magnitude
-- 
GitLab