From 57a6fff6ce7a3030e1d28235ff4a4fefd3619067 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 28 Mar 2015 17:53:40 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20crash=20if=20the=20click=20loca?= =?UTF-8?q?tion=20is=20outside=20the=20map.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenRA.Game/Graphics/Viewport.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 03c5e87f05..3ab14e4bbe 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -118,9 +118,14 @@ namespace OpenRA.Graphics var s = worldRenderer.ScreenPxPosition(p); if (Math.Abs(s.X - world.X) <= ts.Width && Math.Abs(s.Y - world.Y) <= ts.Height) { - var tile = map.MapTiles.Value[uv]; - var ti = tileSet.GetTileInfo(tile); - var ramp = ti != null ? ti.RampType : 0; + var ramp = 0; + if (map.Contains(uv)) + { + var tile = map.MapTiles.Value[uv]; + var ti = tileSet.GetTileInfo(tile); + if (ti != null) + ramp = ti.RampType; + } var corners = map.CellCorners[ramp]; var pos = map.CenterOfCell(uv.ToCPos(map));