diff options
author | Justin Clark-Casey (justincc) | 2013-01-04 20:34:39 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-04 20:34:39 +0000 |
commit | 9503383887d6af871e843cbcbb141a50df56f551 (patch) | |
tree | 85caf28a22c20e703aa60572db978dd7c929c4fc /OpenSim/Region/ScriptEngine | |
parent | minor: Add some doc to the extremely unhelpful 'fudge....' comment as to why ... (diff) | |
download | opensim-SC_OLD-9503383887d6af871e843cbcbb141a50df56f551.zip opensim-SC_OLD-9503383887d6af871e843cbcbb141a50df56f551.tar.gz opensim-SC_OLD-9503383887d6af871e843cbcbb141a50df56f551.tar.bz2 opensim-SC_OLD-9503383887d6af871e843cbcbb141a50df56f551.tar.xz |
Fix llGetLinkKey() to return the last sat avatar as the last link number.
As per http://wiki.secondlife.com/wiki/LlGetLinkKey
This is done by keeping a scene-object wide list of sitters.
This also fixes bugs in this function where linknums 0 and 1 weren't treated properly if there were sitting avatars on a single prim.
This also fixes a minor race condition for multiple concurrent sitters on a prim with no current sitters by locking on the object-wide list rather than individual sop lists
Addresses http://opensimulator.org/mantis/view.php?id=6477
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 75749a9..f31bbff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3738,33 +3738,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3738 | public LSL_String llGetLinkKey(int linknum) | 3738 | public LSL_String llGetLinkKey(int linknum) |
3739 | { | 3739 | { |
3740 | m_host.AddScriptLPS(1); | 3740 | m_host.AddScriptLPS(1); |
3741 | List<UUID> keytable = new List<UUID>(); | ||
3742 | // parse for sitting avatare-uuids | ||
3743 | World.ForEachRootScenePresence(delegate(ScenePresence presence) | ||
3744 | { | ||
3745 | if (presence.ParentID != 0 && m_host.ParentGroup.ContainsPart(presence.ParentID)) | ||
3746 | keytable.Add(presence.UUID); | ||
3747 | }); | ||
3748 | 3741 | ||
3749 | int totalprims = m_host.ParentGroup.PrimCount + keytable.Count; | 3742 | if (linknum < 0) |
3750 | if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) | ||
3751 | { | 3743 | { |
3752 | return keytable[totalprims - linknum].ToString(); | 3744 | if (linknum == ScriptBaseClass.LINK_THIS) |
3745 | return m_host.UUID.ToString(); | ||
3746 | else | ||
3747 | return ScriptBaseClass.NULL_KEY; | ||
3753 | } | 3748 | } |
3754 | 3749 | ||
3755 | if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && keytable.Count == 1) | 3750 | int actualPrimCount = m_host.ParentGroup.PrimCount; |
3751 | List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); | ||
3752 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | ||
3753 | |||
3754 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | ||
3755 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | ||
3756 | if (linknum == 0) | ||
3756 | { | 3757 | { |
3757 | return m_host.UUID.ToString(); | 3758 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) |
3758 | } | 3759 | return m_host.UUID.ToString(); |
3759 | 3760 | ||
3760 | SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum); | 3761 | return ScriptBaseClass.NULL_KEY; |
3761 | if (part != null) | 3762 | } |
3763 | // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but | ||
3764 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | ||
3765 | else if (linknum == 1 && actualPrimCount == 1) | ||
3762 | { | 3766 | { |
3763 | return part.UUID.ToString(); | 3767 | if (sittingAvatarIds.Count > 0) |
3768 | return m_host.ParentGroup.RootPart.UUID.ToString(); | ||
3769 | else | ||
3770 | return ScriptBaseClass.NULL_KEY; | ||
3771 | } | ||
3772 | else if (linknum <= adjustedPrimCount) | ||
3773 | { | ||
3774 | if (linknum <= actualPrimCount) | ||
3775 | return m_host.ParentGroup.GetLinkNumPart(linknum).UUID.ToString(); | ||
3776 | else | ||
3777 | return sittingAvatarIds[linknum - actualPrimCount - 1].ToString(); | ||
3764 | } | 3778 | } |
3765 | else | 3779 | else |
3766 | { | 3780 | { |
3767 | return UUID.Zero.ToString(); | 3781 | return ScriptBaseClass.NULL_KEY; |
3768 | } | 3782 | } |
3769 | } | 3783 | } |
3770 | 3784 | ||