From c9bcfff65493ff414914052daf23f813e6273c17 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 10 Oct 2022 19:07:43 +0200 Subject: [PATCH] - gross hack to simulate the original bad precision of Blood's ClipMove. --- source/games/blood/src/gameutil.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/games/blood/src/gameutil.h b/source/games/blood/src/gameutil.h index bb7467abd..a77979758 100644 --- a/source/games/blood/src/gameutil.h +++ b/source/games/blood/src/gameutil.h @@ -72,7 +72,13 @@ inline void ClipMove(DVector3& pos, sectortype** pSector, const DVector2& vect, { // this uses floats only partially. vec3_t ipos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint)}; - ClipMove(ipos, pSector, int(vect.X * worldtoint), int(vect.Y * worldtoint), wd, int(cd * zworldtoint), int(fd * zworldtoint), nMask, hit, tracecount); + // Due to the low precision of original Build coordinates this code is susceptible to shifts from negative values being off by one, + // so we have to replicate the imprecision here. Gross... + DVector2 vel; + vel.X = (FloatToFixed(vect.X) >> 12) / 16.; + vel.Y = (FloatToFixed(vect.Y) >> 12) / 16.; + + ClipMove(ipos, pSector, int(vel.X * worldtoint), int(vel.Y * worldtoint), wd, int(cd * zworldtoint), int(fd * zworldtoint), nMask, hit, tracecount); pos = { ipos.X * inttoworld, ipos.Y * inttoworld, ipos.Z * zinttoworld }; } BitArray GetClosestSpriteSectors(sectortype* pSector, const DVector2& pos, int nDist, TArray* pWalls, bool newSectCheckMethod = false);