From 6a863311f77a12526d042b6874b9a5e276d5be38 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 28 Sep 2008 01:12:57 +0000 Subject: Mantis#2287. Thank you kindly, Idb for a patch that solves: The current llGetLinkName returns an empty string if a prim with the given link number is not found in the link set. In SL an empty string is only returned if the prim name is actually blank, a NULL_KEY is returned instead with a couple of exceptions. --- .../Shared/Api/Implementation/LSL_Api.cs | 63 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 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 c91bdb2..34d888d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3039,18 +3039,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + /// + /// The rules governing the returned name are not simple. The only + /// time a blank name is returned is if the target prim has a blank + /// name. If no prim with the given link number can be found then + /// usually NULL_KEY is returned but there are exceptions. + /// + /// In a single unlinked prim, A call with 0 returns the name, all + /// other values for link number return NULL_KEY + /// + /// In link sets it is more complicated. + /// + /// If the script is in the root prim:- + /// A zero link number returns NULL_KEY. + /// Positive link numbers return the name of the prim, or NULL_KEY + /// if a prim does not exist at that position. + /// Negative link numbers return the name of the first child prim. + /// + /// If the script is in a child prim:- + /// Link numbers 0 or 1 return the name of the root prim. + /// Positive link numbers return the name of the prim or NULL_KEY + /// if a prim does not exist at that position. + /// Negative numbers return the name of the root prim. + /// + /// References + /// http://lslwiki.net/lslwiki/wakka.php?wakka=llGetLinkName + /// Mentions NULL_KEY being returned + /// http://wiki.secondlife.com/wiki/LlGetLinkName + /// Mentions using the LINK_* constants, some of which are negative + /// public LSL_String llGetLinkName(int linknum) { m_host.AddScriptLPS(1); - SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); - if (part != null) + + // simplest case, this prims link number + if (m_host.LinkNum == linknum) + return m_host.Name; + + // Single prim + if (m_host.LinkNum == 0) { - return part.Name; + if (linknum == 0) + return m_host.Name; + else + return UUID.Zero.ToString(); } - else + // Link set + SceneObjectPart part = null; + if (m_host.LinkNum == 1) // this is the Root prim { - return ""; + if (linknum < 0) + part = m_host.ParentGroup.GetLinkNumPart(2); + else + part = m_host.ParentGroup.GetLinkNumPart(linknum); + } + else // this is a child prim + { + if (linknum < 2) + part = m_host.ParentGroup.GetLinkNumPart(1); + else + part = m_host.ParentGroup.GetLinkNumPart(linknum); } + if (part != null) + return part.Name; + else + return UUID.Zero.ToString(); } public LSL_Integer llGetInventoryNumber(int type) -- cgit v1.1