From 1ae367ef3b5a3fbfdd5960af03c8ae8204f51860 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Fri, 3 Jul 2020 09:42:46 -0700 Subject: [PATCH] ConvertCoordsToIsometric no longer snaps to nearest tile. --- code/redalert/cell.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/redalert/cell.cpp b/code/redalert/cell.cpp index cc3686c..b5232df 100644 --- a/code/redalert/cell.cpp +++ b/code/redalert/cell.cpp @@ -1001,11 +1001,14 @@ bool CellClass::Get_Template_Info(char *template_name, int &icon, void *&image_d void CellClass::ConvertCoordsToIsometric(int& x, int& y) { int tileWidth = CELL_PIXEL_W; int tileHeight = CELL_PIXEL_H; - int sx = (x / CELL_PIXEL_W) * (tileWidth / 2) - (y / CELL_PIXEL_W) * (tileWidth / 2); - int sy = (x / CELL_PIXEL_W) * (tileHeight / 2) + (y / CELL_PIXEL_W) * (tileHeight / 2); + float x_div = ((float)x / CELL_PIXEL_W); + float y_div = ((float)y / CELL_PIXEL_W); - x = sx;// + (CELL_PIXEL_W / 2); - y = sy;// + (CELL_PIXEL_W / 2); + int sx = x_div * (tileWidth / 2) - y_div * (tileWidth / 2); + int sy = x_div * (tileHeight / 2) + y_div * (tileHeight / 2); + + x = sx;// + (CELL_PIXEL_W * 0.5f); + y = sy;// + (CELL_PIXEL_H * 0.5f); x = x + (ScreenWidth / 2); y = y - (ScreenWidth / 4);