From 537cd4708f31196cb71b63fbb3d5d18d6a4c126b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 30 Oct 2008 15:09:43 +0000 Subject: From: Chris Yeoh (yeohc@au1.ibm.com) Here's the patch that clamps llGround to using sane values avoiding runtime errors. --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6fd2544..499273c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -937,6 +937,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = m_host.GetWorldPosition(); int x = (int)(pos.X + offset.x); int y = (int)(pos.Y + offset.y); + + // Clamp to valid position + if (x<0) + x = 0; + else if (x>=World.Heightmap.Width) + x = World.Heightmap.Width-1; + if (y<0) + y = 0; + else if (y>=World.Heightmap.Height) + y = World.Heightmap.Height-1; + + return World.GetLandHeight(x, y); } -- cgit v1.1