Skip to content

Commit

Permalink
Add bounds check for Get2DFromTile.
Browse files Browse the repository at this point in the history
  • Loading branch information
riperiperi authored Feb 17, 2020
1 parent b55a9b1 commit 228cc3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TSOClient/tso.client/Rendering/City/Terrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1914,4 +1914,4 @@ public enum TerrainZoomMode
Near,
Lot
}
}
}

0 comments on commit 228cc3e

Please sign in to comment.