From a973fff529fa66afec3da32bd5aaa3a312440ff2 Mon Sep 17 00:00:00 2001 From: kaczy Date: Fri, 18 Oct 2024 08:44:36 +0200 Subject: [PATCH] Proper clamp VirtualLayer tile coordinates --- CentrED/Map/MapManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CentrED/Map/MapManager.cs b/CentrED/Map/MapManager.cs index dca6083..b5f786a 100644 --- a/CentrED/Map/MapManager.cs +++ b/CentrED/Map/MapManager.cs @@ -812,8 +812,8 @@ public void UpdateLights() if (UseVirtualLayer) { var virtualLayerPos = Unproject(x, y, VirtualLayerZ); - var newX = (ushort)Math.Clamp(virtualLayerPos.X + 1, ushort.MinValue, ushort.MaxValue); - var newY = (ushort)Math.Clamp(virtualLayerPos.Y + 1, ushort.MinValue, ushort.MaxValue); + var newX = (ushort)Math.Clamp(virtualLayerPos.X + 1, 0, Client.Width * 8 - 1); + var newY = (ushort)Math.Clamp(virtualLayerPos.Y + 1, 0, Client.Height * 8 - 1); if (newX != Selected?.Tile.X || newY != Selected.Tile.Y) { return new VirtualLayerTile(newX, newY, (sbyte)VirtualLayerZ);