aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs76
1 files changed, 35 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index f31bbff..f0e0f1a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3824,62 +3824,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3824 public LSL_String llGetLinkName(int linknum) 3824 public LSL_String llGetLinkName(int linknum)
3825 { 3825 {
3826 m_host.AddScriptLPS(1); 3826 m_host.AddScriptLPS(1);
3827 // simplest case, this prims link number
3828 if (linknum == m_host.LinkNum || linknum == ScriptBaseClass.LINK_THIS)
3829 return m_host.Name;
3830 3827
3831 // parse for sitting avatare-names 3828 if (linknum < 0)
3832 List<String> nametable = new List<String>();
3833 World.ForEachRootScenePresence(delegate(ScenePresence presence)
3834 {
3835 SceneObjectPart sitPart = presence.ParentPart;
3836 if (sitPart != null && m_host.ParentGroup.ContainsPart(sitPart.LocalId))
3837 nametable.Add(presence.ControllingClient.Name);
3838 });
3839
3840 int totalprims = m_host.ParentGroup.PrimCount + nametable.Count;
3841 if (totalprims > m_host.ParentGroup.PrimCount)
3842 { 3829 {
3843 // sitting Avatar-Name with negativ linknum / SinglePrim 3830 if (linknum == ScriptBaseClass.LINK_THIS)
3844 if (linknum < 0 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
3845 return nametable[0];
3846 // Prim-Name / SinglePrim Sitting Avatar
3847 if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
3848 return m_host.Name; 3831 return m_host.Name;
3849 // LinkNumber > of Real PrimSet = AvatarName 3832 else
3850 if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) 3833 return ScriptBaseClass.NULL_KEY;
3851 return nametable[totalprims - linknum];
3852 } 3834 }
3853 3835
3854 // Single prim 3836 int actualPrimCount = m_host.ParentGroup.PrimCount;
3855 if (m_host.LinkNum == 0) 3837 List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars();
3838 int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count;
3839
3840 // Special case for a single prim. In this case the linknum is zero. However, this will not match a single
3841 // prim that has any avatars sat upon it (in which case the root prim is link 1).
3842 if (linknum == 0)
3856 { 3843 {
3857 if (linknum == 0 || linknum == ScriptBaseClass.LINK_ROOT) 3844 if (actualPrimCount == 1 && sittingAvatarIds.Count == 0)
3858 return m_host.Name; 3845 return m_host.Name;
3859 else
3860 return UUID.Zero.ToString();
3861 }
3862 3846
3863 // Link set 3847 return ScriptBaseClass.NULL_KEY;
3864 SceneObjectPart part = null; 3848 }
3865 if (m_host.LinkNum == 1) // this is the Root prim 3849 // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but
3850 // here we must match 1 (ScriptBaseClass.LINK_ROOT).
3851 else if (linknum == 1 && actualPrimCount == 1)
3866 { 3852 {
3867 if (linknum < 0) 3853 if (sittingAvatarIds.Count > 0)
3868 part = m_host.ParentGroup.GetLinkNumPart(2); 3854 return m_host.ParentGroup.RootPart.Name;
3869 else 3855 else
3870 part = m_host.ParentGroup.GetLinkNumPart(linknum); 3856 return ScriptBaseClass.NULL_KEY;
3871 } 3857 }
3872 else // this is a child prim 3858 else if (linknum <= adjustedPrimCount)
3873 { 3859 {
3874 if (linknum < 2) 3860 if (linknum <= actualPrimCount)
3875 part = m_host.ParentGroup.GetLinkNumPart(1); 3861 {
3862 return m_host.ParentGroup.GetLinkNumPart(linknum).Name;
3863 }
3876 else 3864 else
3877 part = m_host.ParentGroup.GetLinkNumPart(linknum); 3865 {
3866 ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]);
3867 if (sp != null)
3868 return sp.Name;
3869 else
3870 return ScriptBaseClass.NULL_KEY;
3871 }
3878 } 3872 }
3879 if (part != null)
3880 return part.Name;
3881 else 3873 else
3882 return UUID.Zero.ToString(); 3874 {
3875 return ScriptBaseClass.NULL_KEY;
3876 }
3883 } 3877 }
3884 3878
3885 public LSL_Integer llGetInventoryNumber(int type) 3879 public LSL_Integer llGetInventoryNumber(int type)