From 3824a591d5391320a6f5772b7ab5536ad4500598 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Sun, 30 Apr 2023 15:09:34 +0300 Subject: [PATCH] Fix CandidateMouseoverCells not accounting for tile scale --- OpenRA.Game/Graphics/Viewport.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index a28bfbd66f..d59338a8f3 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -282,11 +282,12 @@ namespace OpenRA.Graphics IEnumerable CandidateMouseoverCells(int2 world) { var map = worldRenderer.World.Map; + var tileScale = map.Grid.TileScale / 2; var minPos = worldRenderer.ProjectedPosition(world); - // Find all the cells that could potentially have been clicked - var a = map.CellContaining(minPos - new WVec(1024, 0, 0)).ToMPos(map.Grid.Type); - var b = map.CellContaining(minPos + new WVec(512, 512 * map.Grid.MaximumTerrainHeight, 0)).ToMPos(map.Grid.Type); + // Find all the cells that could potentially have been clicked. + var a = map.CellContaining(minPos - new WVec(tileScale, 0, 0)).ToMPos(map.Grid.Type); + var b = map.CellContaining(minPos + new WVec(tileScale, tileScale * map.Grid.MaximumTerrainHeight, 0)).ToMPos(map.Grid.Type); for (var v = b.V; v >= a.V; v--) for (var u = b.U; u >= a.U; u--)