From 228cc3ea073eacfb94e522e92d86c928443aa71f Mon Sep 17 00:00:00 2001 From: riperiperi Date: Mon, 17 Feb 2020 12:03:54 +0000 Subject: [PATCH] Add bounds check for Get2DFromTile. --- TSOClient/tso.client/Rendering/City/Terrain.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TSOClient/tso.client/Rendering/City/Terrain.cs b/TSOClient/tso.client/Rendering/City/Terrain.cs index e6b55b98c..771c634a9 100644 --- a/TSOClient/tso.client/Rendering/City/Terrain.cs +++ b/TSOClient/tso.client/Rendering/City/Terrain.cs @@ -736,7 +736,7 @@ private void DrawSpotlights(float HB) public Vector2 Get2DFromTile(int x, int y) { float iScale = (float)(1/(m_LastIsoScale * 2)); - if (x < 0 || y < 0) return new Vector2(); + if (x < 0 || y < 0 || x >= 512 || y >= 512) return new Vector2(); var transform = transformSpr3(new Vector3(x, MapData.ElevationData[(y * 512 + x)] / 12.0f, y)); return (transform.Z > 0)?new Vector2(transform.X, transform.Y):new Vector2(float.MaxValue, 0); } @@ -1914,4 +1914,4 @@ public enum TerrainZoomMode Near, Lot } -} \ No newline at end of file +}