From c7db3df3442657cda398ff2f90d387bce98c718a Mon Sep 17 00:00:00 2001 From: Pixel Tomsen Date: Thu, 29 Sep 2011 21:57:08 +0200 Subject: llGetLinkKey, llGetLinkName Fix for sitting Avatar when an avatar sits on a prim, we get now his key & name ;-) http://opensimulator.org/mantis/view.php?id=4476 --- .../Shared/Api/Implementation/LSL_Api.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 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 39da563..9a26f4b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3704,6 +3704,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLinkKey(int linknum) { m_host.AddScriptLPS(1); + List keytable = new List(); + // parse for sitting avatare-uuids + World.ForEachScenePresence(delegate(ScenePresence presence) + { + if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + keytable.Add(presence.UUID); + }); + + int totalprims = m_host.ParentGroup.PrimCount + keytable.Count; + if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) + { + return keytable[totalprims - linknum].ToString(); + } + + if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && keytable.Count == 1) + { + return m_host.UUID.ToString(); + } + SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); if (part != null) { @@ -3747,6 +3766,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLinkName(int linknum) { m_host.AddScriptLPS(1); + // parse for sitting avatare-names + List nametable = new List(); + World.ForEachScenePresence(delegate(ScenePresence presence) + { + if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + nametable.Add(presence.ControllingClient.Name); + }); + + int totalprims = m_host.ParentGroup.PrimCount + nametable.Count; + if (totalprims > m_host.ParentGroup.PrimCount) + { + // sitting Avatar-Name with negativ linknum / SinglePrim + if (linknum < 0 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1) + return nametable[0]; + // Prim-Name / SinglePrim Sitting Avatar + if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1) + return m_host.Name; + // LinkNumber > of Real PrimSet = AvatarName + if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) + return nametable[totalprims - linknum]; + } // simplest case, this prims link number if (m_host.LinkNum == linknum) @@ -3760,6 +3800,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else return UUID.Zero.ToString(); } + // Link set SceneObjectPart part = null; if (m_host.LinkNum == 1) // this is the Root prim -- cgit v1.1