aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-04-23 22:52:46 +0100
committerJustin Clark-Casey (justincc)2012-04-23 22:52:46 +0100
commit1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b (patch)
tree729a7964c8469e2ea52138b39f734a1bf0968dc8 /OpenSim
parentrefactor: Replace calls to InventorySelf() with existing m_itemID in LSL_Api (diff)
downloadopensim-SC-1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b.zip
opensim-SC-1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b.tar.gz
opensim-SC-1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b.tar.bz2
opensim-SC-1f8d1bcdcf7ae48ad0b3609e532ad87859f6300b.tar.xz
Replace common code to fetch self inventory item (as opposed to uuid) with GetSelfInventoryItem()
However, at some point it would be far more convenient to receive the TaskInventoryItem in the constructor rather than just the item UUID, so we don't have to constantly refetch our self item.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs231
1 files changed, 76 insertions, 155 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6000293..a353b25 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -272,6 +272,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
272 } 272 }
273 } 273 }
274 274
275 /// <summary>
276 /// Get the inventory item that hosts ourselves.
277 /// </summary>
278 /// <remarks>
279 /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
280 /// to keep looking ourselves up.
281 /// </remarks>
282 /// <returns></returns>
283 protected TaskInventoryItem GetSelfInventoryItem()
284 {
285 lock (m_host.TaskInventory)
286 return m_host.TaskInventory[m_itemID];
287 }
288
275 protected UUID InventoryKey(string name, int type) 289 protected UUID InventoryKey(string name, int type)
276 { 290 {
277 m_host.AddScriptLPS(1); 291 m_host.AddScriptLPS(1);
@@ -2685,12 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2685 { 2699 {
2686 m_host.AddScriptLPS(1); 2700 m_host.AddScriptLPS(1);
2687 2701
2688 TaskInventoryItem item; 2702 TaskInventoryItem item = GetSelfInventoryItem();
2689
2690 lock (m_host.TaskInventory)
2691 {
2692 item = m_host.TaskInventory[m_itemID];
2693 }
2694 2703
2695 if (item.PermsGranter == UUID.Zero) 2704 if (item.PermsGranter == UUID.Zero)
2696 return 0; 2705 return 0;
@@ -2933,15 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2933 2942
2934 public void llTakeControls(int controls, int accept, int pass_on) 2943 public void llTakeControls(int controls, int accept, int pass_on)
2935 { 2944 {
2936 TaskInventoryItem item; 2945 TaskInventoryItem item = GetSelfInventoryItem();
2937
2938 lock (m_host.TaskInventory)
2939 {
2940 if (!m_host.TaskInventory.ContainsKey(m_itemID))
2941 return;
2942 else
2943 item = m_host.TaskInventory[m_itemID];
2944 }
2945 2946
2946 if (item.PermsGranter != UUID.Zero) 2947 if (item.PermsGranter != UUID.Zero)
2947 { 2948 {
@@ -2961,18 +2962,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2961 2962
2962 public void llReleaseControls() 2963 public void llReleaseControls()
2963 { 2964 {
2964 TaskInventoryItem item;
2965
2966 lock (m_host.TaskInventory)
2967 {
2968 if (!m_host.TaskInventory.ContainsKey(m_itemID))
2969 return;
2970 else
2971 item = m_host.TaskInventory[m_itemID];
2972 }
2973
2974 m_host.AddScriptLPS(1); 2965 m_host.AddScriptLPS(1);
2975 2966
2967 TaskInventoryItem item = GetSelfInventoryItem();
2968
2976 if (item.PermsGranter != UUID.Zero) 2969 if (item.PermsGranter != UUID.Zero)
2977 { 2970 {
2978 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2971 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@@ -3004,15 +2997,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3004// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) 2997// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3005// return; 2998// return;
3006 2999
3007 TaskInventoryItem item; 3000 TaskInventoryItem item = GetSelfInventoryItem();
3008
3009 lock (m_host.TaskInventory)
3010 {
3011 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3012 return;
3013 else
3014 item = m_host.TaskInventory[m_itemID];
3015 }
3016 3001
3017 if (item.PermsGranter != m_host.OwnerID) 3002 if (item.PermsGranter != m_host.OwnerID)
3018 return; 3003 return;
@@ -3036,15 +3021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3036 if (m_host.ParentGroup.AttachmentPoint == 0) 3021 if (m_host.ParentGroup.AttachmentPoint == 0)
3037 return; 3022 return;
3038 3023
3039 TaskInventoryItem item; 3024 TaskInventoryItem item = GetSelfInventoryItem();
3040
3041 lock (m_host.TaskInventory)
3042 {
3043 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3044 return;
3045 else
3046 item = m_host.TaskInventory[m_itemID];
3047 }
3048 3025
3049 if (item.PermsGranter != m_host.OwnerID) 3026 if (item.PermsGranter != m_host.OwnerID)
3050 return; 3027 return;
@@ -3295,15 +3272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3295 { 3272 {
3296 m_host.AddScriptLPS(1); 3273 m_host.AddScriptLPS(1);
3297 3274
3298 TaskInventoryItem item; 3275 TaskInventoryItem item = GetSelfInventoryItem();
3299
3300 lock (m_host.TaskInventory)
3301 {
3302 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3303 return;
3304 else
3305 item = m_host.TaskInventory[m_itemID];
3306 }
3307 3276
3308 if (item.PermsGranter == UUID.Zero) 3277 if (item.PermsGranter == UUID.Zero)
3309 return; 3278 return;
@@ -3328,15 +3297,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3328 { 3297 {
3329 m_host.AddScriptLPS(1); 3298 m_host.AddScriptLPS(1);
3330 3299
3331 TaskInventoryItem item; 3300 TaskInventoryItem item = GetSelfInventoryItem();
3332
3333 lock (m_host.TaskInventory)
3334 {
3335 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3336 return;
3337 else
3338 item = m_host.TaskInventory[m_itemID];
3339 }
3340 3301
3341 if (item.PermsGranter == UUID.Zero) 3302 if (item.PermsGranter == UUID.Zero)
3342 return; 3303 return;
@@ -3396,12 +3357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3396 if (!UUID.TryParse(agent, out agentID)) 3357 if (!UUID.TryParse(agent, out agentID))
3397 return; 3358 return;
3398 3359
3399 TaskInventoryItem item; 3360 TaskInventoryItem item = GetSelfInventoryItem();
3400
3401 lock (m_host.TaskInventory)
3402 {
3403 item = m_host.TaskInventory[m_itemID];
3404 }
3405 3361
3406 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3362 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3407 { 3363 {
@@ -3531,39 +3487,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3531 { 3487 {
3532 m_host.AddScriptLPS(1); 3488 m_host.AddScriptLPS(1);
3533 3489
3534 lock (m_host.TaskInventory) 3490 return GetSelfInventoryItem().PermsGranter.ToString();
3535 {
3536 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3537 {
3538 if (item.Type == 10 && item.ItemID == m_itemID)
3539 {
3540 return item.PermsGranter.ToString();
3541 }
3542 }
3543 }
3544
3545 return UUID.Zero.ToString();
3546 } 3491 }
3547 3492
3548 public LSL_Integer llGetPermissions() 3493 public LSL_Integer llGetPermissions()
3549 { 3494 {
3550 m_host.AddScriptLPS(1); 3495 m_host.AddScriptLPS(1);
3551 3496
3552 lock (m_host.TaskInventory) 3497 int perms = GetSelfInventoryItem().PermsMask;
3553 {
3554 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3555 {
3556 if (item.Type == 10 && item.ItemID == m_itemID)
3557 {
3558 int perms = item.PermsMask;
3559 if (m_automaticLinkPermission)
3560 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3561 return perms;
3562 }
3563 }
3564 }
3565 3498
3566 return 0; 3499 if (m_automaticLinkPermission)
3500 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3501
3502 return perms;
3567 } 3503 }
3568 3504
3569 public LSL_Integer llGetLinkNumber() 3505 public LSL_Integer llGetLinkNumber()
@@ -3597,11 +3533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3597 if (!UUID.TryParse(target, out targetID)) 3533 if (!UUID.TryParse(target, out targetID))
3598 return; 3534 return;
3599 3535
3600 TaskInventoryItem item; 3536 TaskInventoryItem item = GetSelfInventoryItem();
3601 lock (m_host.TaskInventory)
3602 {
3603 item = m_host.TaskInventory[m_itemID];
3604 }
3605 3537
3606 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3538 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3607 && !m_automaticLinkPermission) 3539 && !m_automaticLinkPermission)
@@ -3653,14 +3585,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3653 { 3585 {
3654 m_host.AddScriptLPS(1); 3586 m_host.AddScriptLPS(1);
3655 3587
3656 lock (m_host.TaskInventory) 3588 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3589 && !m_automaticLinkPermission)
3657 { 3590 {
3658 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3591 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3659 && !m_automaticLinkPermission) 3592 return;
3660 {
3661 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3662 return;
3663 }
3664 } 3593 }
3665 3594
3666 if (linknum < ScriptBaseClass.LINK_THIS) 3595 if (linknum < ScriptBaseClass.LINK_THIS)
@@ -4537,23 +4466,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4537 4466
4538 public LSL_String llGetScriptName() 4467 public LSL_String llGetScriptName()
4539 { 4468 {
4540 string result = String.Empty;
4541
4542 m_host.AddScriptLPS(1); 4469 m_host.AddScriptLPS(1);
4543 4470
4544 lock (m_host.TaskInventory) 4471 TaskInventoryItem item = GetSelfInventoryItem();
4545 {
4546 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4547 {
4548 if (item.Type == 10 && item.ItemID == m_itemID)
4549 {
4550 result = item.Name != null ? item.Name : String.Empty;
4551 break;
4552 }
4553 }
4554 }
4555 4472
4556 return result; 4473 return item.Name != null ? item.Name : String.Empty;
4557 } 4474 }
4558 4475
4559 public LSL_Integer llGetLinkNumberOfSides(int link) 4476 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -9655,16 +9572,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9655 { 9572 {
9656 m_host.AddScriptLPS(1); 9573 m_host.AddScriptLPS(1);
9657 9574
9658 lock (m_host.TaskInventory) 9575 TaskInventoryItem item = GetSelfInventoryItem();
9659 {
9660 if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero)
9661 return new LSL_Vector();
9662 9576
9663 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9577 if (item.PermsGranter == UUID.Zero)
9664 { 9578 return new LSL_Vector();
9665 ShoutError("No permissions to track the camera"); 9579
9666 return new LSL_Vector(); 9580 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9667 } 9581 {
9582 ShoutError("No permissions to track the camera");
9583 return new LSL_Vector();
9668 } 9584 }
9669 9585
9670 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9586 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9680,16 +9596,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9680 { 9596 {
9681 m_host.AddScriptLPS(1); 9597 m_host.AddScriptLPS(1);
9682 9598
9683 lock (m_host.TaskInventory) 9599 TaskInventoryItem item = GetSelfInventoryItem();
9684 {
9685 if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero)
9686 return new LSL_Rotation();
9687 9600
9688 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9601 if (item.PermsGranter == UUID.Zero)
9689 { 9602 return new LSL_Rotation();
9690 ShoutError("No permissions to track the camera"); 9603
9691 return new LSL_Rotation(); 9604 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9692 } 9605 {
9606 ShoutError("No permissions to track the camera");
9607 return new LSL_Rotation();
9693 } 9608 }
9694 9609
9695 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9610 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9865,17 +9780,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9865 9780
9866 // the object we are in 9781 // the object we are in
9867 UUID objectID = m_host.ParentUUID; 9782 UUID objectID = m_host.ParentUUID;
9868 if (objectID == UUID.Zero) return; 9783 if (objectID == UUID.Zero)
9784 return;
9869 9785
9870 UUID agentID; 9786 TaskInventoryItem item = GetSelfInventoryItem();
9871 lock (m_host.TaskInventory)
9872 {
9873 // we need the permission first, to know which avatar we want to set the camera for
9874 agentID = m_host.TaskInventory[m_itemID].PermsGranter;
9875 9787
9876 if (agentID == UUID.Zero) return; 9788 // we need the permission first, to know which avatar we want to set the camera for
9877 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9789 UUID agentID = item.PermsGranter;
9878 } 9790
9791 if (agentID == UUID.Zero)
9792 return;
9793
9794 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9795 return;
9879 9796
9880 ScenePresence presence = World.GetScenePresence(agentID); 9797 ScenePresence presence = World.GetScenePresence(agentID);
9881 9798
@@ -9917,21 +9834,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9917 9834
9918 // the object we are in 9835 // the object we are in
9919 UUID objectID = m_host.ParentUUID; 9836 UUID objectID = m_host.ParentUUID;
9920 if (objectID == UUID.Zero) return; 9837 if (objectID == UUID.Zero)
9838 return;
9839
9840 TaskInventoryItem item = GetSelfInventoryItem();
9921 9841
9922 // we need the permission first, to know which avatar we want to clear the camera for 9842 // we need the permission first, to know which avatar we want to clear the camera for
9923 UUID agentID; 9843 UUID agentID = item.PermsGranter;
9924 lock (m_host.TaskInventory) 9844
9925 { 9845 if (agentID == UUID.Zero)
9926 agentID = m_host.TaskInventory[m_itemID].PermsGranter; 9846 return;
9927 if (agentID == UUID.Zero) return; 9847
9928 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9848 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9929 } 9849 return;
9930 9850
9931 ScenePresence presence = World.GetScenePresence(agentID); 9851 ScenePresence presence = World.GetScenePresence(agentID);
9932 9852
9933 // we are not interested in child-agents 9853 // we are not interested in child-agents
9934 if (presence.IsChildAgent) return; 9854 if (presence.IsChildAgent)
9855 return;
9935 9856
9936 presence.ControllingClient.SendClearFollowCamProperties(objectID); 9857 presence.ControllingClient.SendClearFollowCamProperties(objectID);
9937 } 9858 }