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. --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 22 ++++++++++++++++++++-- .../Shared/Api/Implementation/LSL_Api.cs | 22 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 72a4322..795baac 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -7391,9 +7391,27 @@ namespace OpenSim.Region.ScriptEngine.Common { 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) + // ref 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; } 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