diff options
author | Justin Clark-Casey (justincc) | 2014-04-03 01:14:39 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-04-03 01:14:39 +0100 |
commit | 6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3 (patch) | |
tree | af88d18d76d7212252f8c8215dd42e3e0d2b025e /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | minor: Fix warning in AvatarFactoryModule (diff) | |
download | opensim-SC-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.zip opensim-SC-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.gz opensim-SC-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.bz2 opensim-SC-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.xz |
refactor: Use m_sittingAvatars to maintain the list of sitting avatars instead of two independent structures that do exactly the same thing
m_sittingAvatars code also already properly handles locking to avoid races.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 86509aa..e38394a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -335,14 +335,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
335 | } | 335 | } |
336 | 336 | ||
337 | int actualPrimCount = part.ParentGroup.PrimCount; | 337 | int actualPrimCount = part.ParentGroup.PrimCount; |
338 | List<UUID> sittingAvatarIds = part.ParentGroup.GetSittingAvatars(); | 338 | List<ScenePresence> sittingAvatars = part.ParentGroup.GetSittingAvatars(); |
339 | int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count; | 339 | int adjustedPrimCount = actualPrimCount + sittingAvatars.Count; |
340 | 340 | ||
341 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single | 341 | // Special case for a single prim. In this case the linknum is zero. However, this will not match a single |
342 | // prim that has any avatars sat upon it (in which case the root prim is link 1). | 342 | // prim that has any avatars sat upon it (in which case the root prim is link 1). |
343 | if (linknum == 0) | 343 | if (linknum == 0) |
344 | { | 344 | { |
345 | if (actualPrimCount == 1 && sittingAvatarIds.Count == 0) | 345 | if (actualPrimCount == 1 && sittingAvatars.Count == 0) |
346 | return part; | 346 | return part; |
347 | 347 | ||
348 | return null; | 348 | return null; |
@@ -351,7 +351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
351 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). | 351 | // here we must match 1 (ScriptBaseClass.LINK_ROOT). |
352 | else if (linknum == ScriptBaseClass.LINK_ROOT && actualPrimCount == 1) | 352 | else if (linknum == ScriptBaseClass.LINK_ROOT && actualPrimCount == 1) |
353 | { | 353 | { |
354 | if (sittingAvatarIds.Count > 0) | 354 | if (sittingAvatars.Count > 0) |
355 | return part.ParentGroup.RootPart; | 355 | return part.ParentGroup.RootPart; |
356 | else | 356 | else |
357 | return null; | 357 | return null; |
@@ -364,11 +364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]); | 367 | return sittingAvatars[linknum - actualPrimCount - 1]; |
368 | if (sp != null) | ||
369 | return sp; | ||
370 | else | ||
371 | return null; | ||
372 | } | 368 | } |
373 | } | 369 | } |
374 | else | 370 | else |
@@ -3619,7 +3615,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3619 | } | 3615 | } |
3620 | else | 3616 | else |
3621 | { | 3617 | { |
3622 | if (m_host.ParentGroup.GetSittingAvatars().Contains(agentID)) | 3618 | if (m_host.ParentGroup.GetSittingAvatars().SingleOrDefault(sp => sp.UUID == agentID) != null) |
3623 | { | 3619 | { |
3624 | // When agent is sitting, certain permissions are implicit if requested from sitting agent | 3620 | // When agent is sitting, certain permissions are implicit if requested from sitting agent |
3625 | implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | | 3621 | implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | |
@@ -3651,10 +3647,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3651 | } | 3647 | } |
3652 | 3648 | ||
3653 | ScenePresence presence = World.GetScenePresence(agentID); | 3649 | ScenePresence presence = World.GetScenePresence(agentID); |
3650 | |||
3654 | if (presence != null) | 3651 | if (presence != null) |
3655 | { | 3652 | { |
3656 | // If permissions are being requested from an NPC and were not implicitly granted above then | 3653 | // If permissions are being requested from an NPC and were not implicitly granted above then |
3657 | // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner | 3654 | // auto grant all requested permissions if the script is owned by the NPC or the NPCs owner |
3658 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | 3655 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); |
3659 | if (npcModule != null && npcModule.IsNPC(agentID, World)) | 3656 | if (npcModule != null && npcModule.IsNPC(agentID, World)) |
3660 | { | 3657 | { |