Skip to content

Commit

Permalink
Proper clamp VirtualLayer tile coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Oct 18, 2024
1 parent ebb4efa commit a973fff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a973fff

Please sign in to comment.