From 2f42818a332f33bca3733ba956ef0300dd03e011 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 29 Oct 2022 18:23:53 +0300 Subject: [PATCH] Review square coords math --- src/tile.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/tile.cc b/src/tile.cc index 624cf44..d265281 100644 --- a/src/tile.cc +++ b/src/tile.cc @@ -1149,9 +1149,7 @@ void squareTileScreenToCoord(int screenX, int screenY, int elevation, int* coord *coordX = v6 >= 0 ? (v6 / 192) : ((v6 + 1) / 192 - 1); v8 = 4 * v5 + v4; - *coordY = v8 >= 0 - ? ((v8 - ((v8 >> 31) << 7)) >> 7) - : ((((v8 + 1) - (((v8 + 1) >> 31) << 7)) >> 7) - 1); + *coordY = v8 >= 0 ? (v8 / 128) : ((v8 + 1) / 128 - 1); *coordX += _square_x; *coordY += _square_rect; @@ -1174,9 +1172,7 @@ void squareTileScreenToCoordRoof(int screenX, int screenY, int elevation, int* c *coordX = (v6 >= 0) ? (v6 / 192) : ((v6 + 1) / 192 - 1); v8 = 4 * v5 + v4; - *coordY = (v8 >= 0) - ? ((v8 - ((v8 >> 31) << 7)) >> 7) - : ((((v8 + 1) - (((v8 + 1) >> 31) << 7)) >> 7) - 1); + *coordY = v8 >= 0 ? (v8 / 128) : ((v8 + 1) / 128 - 1); *coordX += _square_x; *coordY += _square_rect;