From fdc6dd32637672c5563f85c89cf9e598bb3c79e0 Mon Sep 17 00:00:00 2001
From: pastel <hazepastel@proton.me>
Date: Wed, 11 Dec 2024 16:52:56 -0600
Subject: [PATCH] jank prevention

---
 src/p_mobj.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/p_mobj.c b/src/p_mobj.c
index 3059d45f53..65369934f3 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -3100,9 +3100,6 @@ void P_MobjCheckWater(mobj_t *mobj)
 	// Reset water state.
 	mobj->eflags &= ~(MFE_UNDERWATER|MFE_TOUCHWATER|MFE_GOOWATER|MFE_TOUCHLAVA);
 
-	if (mobj->momz)
-		height += mobj->momz;
-
 	for (rover = sector->ffloors; rover; rover = rover->next)
 	{
 		fixed_t topheight, bottomheight;
@@ -3132,13 +3129,13 @@ void P_MobjCheckWater(mobj_t *mobj)
 		mobj->waterbottom = bottomheight;
 
 		// Just touching the water?
-		if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - height < bottomheight)
-		 || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + height > topheight))
+		if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - (mobj->momz + height) < bottomheight)
+		 || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + (mobj->momz + height) > topheight))
 			mobj->eflags |= MFE_TOUCHWATER;
 
 		// Actually in the water?
-		if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - (height>>1) > bottomheight)
-		 || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + (height>>1) < topheight))
+		if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - ((mobj->momz/2) + (height>>1)) > bottomheight)
+		 || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + ((mobj->momz/2) + (height>>1)) < topheight))
 			mobj->eflags |= MFE_UNDERWATER;
 
 		if (mobj->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER))
-- 
GitLab