From 3f6071ce3a2a8970419186fa7d5715f2af8b53ae Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 11 May 2013 16:16:02 +0200 Subject: [PATCH] Guard against trying to access terrain heights out of bounds. Clamp to sim. --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48ef39..b6e0a97fce 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -131,7 +131,15 @@ namespace OpenSim.Region.Framework.Scenes public double this[int x, int y] { - get { return map[x, y]; } + get + { + if (x < 0) x = 0; + if (y < 0) y = 0; + if (x >= (int)Constants.RegionSize) x = (int)Constants.RegionSize - 1; + if (y >= (int)Constants.RegionSize) y = (int)Constants.RegionSize - 1; + + return map[x, y]; + } set { // Will "fix" terrain hole problems. Although not fantastically.