diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 164 |
1 files changed, 80 insertions, 84 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index cf16571..8adf4d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -283,6 +283,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | /// <summary> | ||
287 | /// Get a given link entity from a linkset (linked objects and any sitting avatars). | ||
288 | /// </summary> | ||
289 | /// <remarks> | ||
290 | /// If there are any ScenePresence's in the linkset (i.e. because they are sat upon one of the prims), then | ||
291 | /// these are counted as extra entities that correspond to linknums beyond the number of prims in the linkset. | ||
292 | /// The ScenePresences receive linknums in the order in which they sat. | ||
293 | /// </remarks> | ||
294 | /// <returns> | ||
295 | /// The link entity. null if not found. | ||
296 | /// </returns> | ||
297 | /// <param name='linknum'> | ||
298 | /// Can be either a non-negative integer or ScriptBaseClass.LINK_THIS (-4). | ||
299 | /// If ScriptBaseClass.LINK_THIS then the entity containing the script is returned. | ||
300 | /// If the linkset has one entity and a linknum of zero is given, then the single entity is returned. If any | ||
301 | /// positive integer is given in this case then null is returned. | ||
302 | /// If the linkset has more than one entity and a linknum greater than zero but equal to or less than the number | ||
303 | /// of entities, then the entity which corresponds to that linknum is returned. | ||
304 | /// Otherwise, if a positive linknum is given which is greater than the number of entities in the linkset, then | ||
305 | /// null is returned. | ||
306 | /// </param> | ||
307 | public ISceneEntity GetLinkEntity(int linknum) | ||
308 | { | ||
309 | if (linknum < 0) | ||
310 | { | ||
311 | if (linknum == ScriptBaseClass.LINK_THIS) | ||
312 | return m_host; | ||
313 | else | ||
314 | return null; | ||
315 | } | ||
316 | |||
317 | int actualPrimCount = m_host.ParentGroup.PrimCount; | ||
318 | List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); | ||
319 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | ||
320 | |||
321 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | ||
322 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | ||
323 | if (linknum == 0) | ||
324 | { | ||
325 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) | ||
326 | return m_host; | ||
327 | |||
328 | return null; | ||
329 | } | ||
330 | // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but | ||
331 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | ||
332 | else if (linknum == ScriptBaseClass.LINK_ROOT && actualPrimCount == 1) | ||
333 | { | ||
334 | if (sittingAvatarIds.Count > 0) | ||
335 | return m_host.ParentGroup.RootPart; | ||
336 | else | ||
337 | return null; | ||
338 | } | ||
339 | else if (linknum <= adjustedPrimCount) | ||
340 | { | ||
341 | if (linknum <= actualPrimCount) | ||
342 | { | ||
343 | return m_host.ParentGroup.GetLinkNumPart(linknum); | ||
344 | } | ||
345 | else | ||
346 | { | ||
347 | ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]); | ||
348 | if (sp != null) | ||
349 | return sp; | ||
350 | else | ||
351 | return null; | ||
352 | } | ||
353 | } | ||
354 | else | ||
355 | { | ||
356 | return null; | ||
357 | } | ||
358 | } | ||
359 | |||
286 | public List<SceneObjectPart> GetLinkParts(int linkType) | 360 | public List<SceneObjectPart> GetLinkParts(int linkType) |
287 | { | 361 | { |
288 | return GetLinkParts(m_host, linkType); | 362 | return GetLinkParts(m_host, linkType); |
@@ -3697,47 +3771,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3697 | { | 3771 | { |
3698 | m_host.AddScriptLPS(1); | 3772 | m_host.AddScriptLPS(1); |
3699 | 3773 | ||
3700 | if (linknum < 0) | 3774 | ISceneEntity entity = GetLinkEntity(linknum); |
3701 | { | ||
3702 | if (linknum == ScriptBaseClass.LINK_THIS) | ||
3703 | return m_host.UUID.ToString(); | ||
3704 | else | ||
3705 | return ScriptBaseClass.NULL_KEY; | ||
3706 | } | ||
3707 | |||
3708 | int actualPrimCount = m_host.ParentGroup.PrimCount; | ||
3709 | List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); | ||
3710 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | ||
3711 | 3775 | ||
3712 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | 3776 | if (entity != null) |
3713 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | 3777 | return entity.UUID.ToString(); |
3714 | if (linknum == 0) | ||
3715 | { | ||
3716 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) | ||
3717 | return m_host.UUID.ToString(); | ||
3718 | |||
3719 | return ScriptBaseClass.NULL_KEY; | ||
3720 | } | ||
3721 | // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but | ||
3722 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | ||
3723 | else if (linknum == 1 && actualPrimCount == 1) | ||
3724 | { | ||
3725 | if (sittingAvatarIds.Count > 0) | ||
3726 | return m_host.ParentGroup.RootPart.UUID.ToString(); | ||
3727 | else | ||
3728 | return ScriptBaseClass.NULL_KEY; | ||
3729 | } | ||
3730 | else if (linknum <= adjustedPrimCount) | ||
3731 | { | ||
3732 | if (linknum <= actualPrimCount) | ||
3733 | return m_host.ParentGroup.GetLinkNumPart(linknum).UUID.ToString(); | ||
3734 | else | ||
3735 | return sittingAvatarIds[linknum - actualPrimCount - 1].ToString(); | ||
3736 | } | ||
3737 | else | 3778 | else |
3738 | { | ||
3739 | return ScriptBaseClass.NULL_KEY; | 3779 | return ScriptBaseClass.NULL_KEY; |
3740 | } | ||
3741 | } | 3780 | } |
3742 | 3781 | ||
3743 | /// <summary> | 3782 | /// <summary> |
@@ -3783,55 +3822,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3783 | { | 3822 | { |
3784 | m_host.AddScriptLPS(1); | 3823 | m_host.AddScriptLPS(1); |
3785 | 3824 | ||
3786 | if (linknum < 0) | 3825 | ISceneEntity entity = GetLinkEntity(linknum); |
3787 | { | ||
3788 | if (linknum == ScriptBaseClass.LINK_THIS) | ||
3789 | return m_host.Name; | ||
3790 | else | ||
3791 | return ScriptBaseClass.NULL_KEY; | ||
3792 | } | ||
3793 | |||
3794 | int actualPrimCount = m_host.ParentGroup.PrimCount; | ||
3795 | List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); | ||
3796 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | ||
3797 | |||
3798 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | ||
3799 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | ||
3800 | if (linknum == 0) | ||
3801 | { | ||
3802 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) | ||
3803 | return m_host.Name; | ||
3804 | 3826 | ||
3805 | return ScriptBaseClass.NULL_KEY; | 3827 | if (entity != null) |
3806 | } | 3828 | return entity.Name; |
3807 | // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but | ||
3808 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | ||
3809 | else if (linknum == 1 && actualPrimCount == 1) | ||
3810 | { | ||
3811 | if (sittingAvatarIds.Count > 0) | ||
3812 | return m_host.ParentGroup.RootPart.Name; | ||
3813 | else | ||
3814 | return ScriptBaseClass.NULL_KEY; | ||
3815 | } | ||
3816 | else if (linknum <= adjustedPrimCount) | ||
3817 | { | ||
3818 | if (linknum <= actualPrimCount) | ||
3819 | { | ||
3820 | return m_host.ParentGroup.GetLinkNumPart(linknum).Name; | ||
3821 | } | ||
3822 | else | ||
3823 | { | ||
3824 | ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]); | ||
3825 | if (sp != null) | ||
3826 | return sp.Name; | ||
3827 | else | ||
3828 | return ScriptBaseClass.NULL_KEY; | ||
3829 | } | ||
3830 | } | ||
3831 | else | 3829 | else |
3832 | { | ||
3833 | return ScriptBaseClass.NULL_KEY; | 3830 | return ScriptBaseClass.NULL_KEY; |
3834 | } | ||
3835 | } | 3831 | } |
3836 | 3832 | ||
3837 | public LSL_Integer llGetInventoryNumber(int type) | 3833 | public LSL_Integer llGetInventoryNumber(int type) |