From aecb4fb72a92bafc0a33ccfde4cbaa67ec5fb757 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 31 Mar 2009 12:45:34 +0000 Subject: [PATCH] From: Alan M Webb Add sanity check to fly-height calculation so that it does not attempt to retrieve information from non-existent regions. --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index e3ac668c79..9451ad9b2b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -1297,6 +1297,9 @@ namespace OpenSim.Region.Physics.OdePlugin // Recovered for use by fly height. Kitto Flora public float GetTerrainHeightAtXY(float x, float y) { + + int index; + // Teravus: Kitto, this code causes recurring errors that stall physics permenantly unless // the values are checked, so checking below. // Is there any reason that we don't do this in ScenePresence? @@ -1306,7 +1309,12 @@ namespace OpenSim.Region.Physics.OdePlugin (int)x < 0.001f || (int)y < 0.001f) return 0; - return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; + index = (int) ((int)y * Constants.RegionSize + (int)x); + + if (index < _origheightmap.Length) + return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; + else + return 0; } // End recovered. Kitto Flora