From 5edaddce6d1b26869274819cf8a86b4914e7ae3d Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Thu, 25 Sep 2008 03:58:03 +0000 Subject: Mantis#2123. Thank you kindly, Idb for a patch that solves: Under both DotNetEngine and XEngine, if an agent's UUID is passed as the parameter to llGetObjectMass(), it throws an exception. --- .../Shared/Api/Implementation/LSL_Api.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f40b1a5..ced5452 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7167,9 +7167,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); UUID key = new UUID(); - if (UUID.TryParse(id,out key)) + if (UUID.TryParse(id, out key)) { - return (double)World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass(); + try + { + SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); + if (obj != null) + return (double)obj.GetMass(); + // the object is null so the key is for an avatar + ScenePresence avatar = World.GetScenePresence(key); + if (avatar != null) + if (avatar.IsChildAgent) + // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass + // child agents have a mass of 1.0 + return 1; + else + return (double)avatar.PhysicsActor.Mass; + } + catch (KeyNotFoundException) + { + return 0; // The Object/Agent not in the region so just return zero + } } return 0; } -- cgit v1.1