aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs136
1 files changed, 42 insertions, 94 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 36c9d5e..6000293 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -85,7 +85,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
85 protected IScriptEngine m_ScriptEngine; 85 protected IScriptEngine m_ScriptEngine;
86 protected SceneObjectPart m_host; 86 protected SceneObjectPart m_host;
87 protected uint m_localID; 87 protected uint m_localID;
88
89 /// <summary>
90 /// The UUID of the item that hosts this script
91 /// </summary>
88 protected UUID m_itemID; 92 protected UUID m_itemID;
93
89 protected bool throwErrorOnNotImplemented = true; 94 protected bool throwErrorOnNotImplemented = true;
90 protected AsyncCommandManager AsyncCommands = null; 95 protected AsyncCommandManager AsyncCommands = null;
91 protected float m_ScriptDelayFactor = 1.0f; 96 protected float m_ScriptDelayFactor = 1.0f;
@@ -267,25 +272,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
267 } 272 }
268 } 273 }
269 274
270 protected UUID InventorySelf()
271 {
272 UUID invItemID = new UUID();
273
274 lock (m_host.TaskInventory)
275 {
276 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
277 {
278 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
279 {
280 invItemID = inv.Key;
281 break;
282 }
283 }
284 }
285
286 return invItemID;
287 }
288
289 protected UUID InventoryKey(string name, int type) 275 protected UUID InventoryKey(string name, int type)
290 { 276 {
291 m_host.AddScriptLPS(1); 277 m_host.AddScriptLPS(1);
@@ -2697,17 +2683,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2697 2683
2698 public LSL_Integer llGiveMoney(string destination, int amount) 2684 public LSL_Integer llGiveMoney(string destination, int amount)
2699 { 2685 {
2700 UUID invItemID=InventorySelf();
2701 if (invItemID == UUID.Zero)
2702 return 0;
2703
2704 m_host.AddScriptLPS(1); 2686 m_host.AddScriptLPS(1);
2705 2687
2706 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2688 TaskInventoryItem item;
2707 2689
2708 lock (m_host.TaskInventory) 2690 lock (m_host.TaskInventory)
2709 { 2691 {
2710 item = m_host.TaskInventory[invItemID]; 2692 item = m_host.TaskInventory[m_itemID];
2711 } 2693 }
2712 2694
2713 if (item.PermsGranter == UUID.Zero) 2695 if (item.PermsGranter == UUID.Zero)
@@ -2955,10 +2937,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2955 2937
2956 lock (m_host.TaskInventory) 2938 lock (m_host.TaskInventory)
2957 { 2939 {
2958 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2940 if (!m_host.TaskInventory.ContainsKey(m_itemID))
2959 return; 2941 return;
2960 else 2942 else
2961 item = m_host.TaskInventory[InventorySelf()]; 2943 item = m_host.TaskInventory[m_itemID];
2962 } 2944 }
2963 2945
2964 if (item.PermsGranter != UUID.Zero) 2946 if (item.PermsGranter != UUID.Zero)
@@ -2983,10 +2965,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2983 2965
2984 lock (m_host.TaskInventory) 2966 lock (m_host.TaskInventory)
2985 { 2967 {
2986 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2968 if (!m_host.TaskInventory.ContainsKey(m_itemID))
2987 return; 2969 return;
2988 else 2970 else
2989 item = m_host.TaskInventory[InventorySelf()]; 2971 item = m_host.TaskInventory[m_itemID];
2990 } 2972 }
2991 2973
2992 m_host.AddScriptLPS(1); 2974 m_host.AddScriptLPS(1);
@@ -3026,10 +3008,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3026 3008
3027 lock (m_host.TaskInventory) 3009 lock (m_host.TaskInventory)
3028 { 3010 {
3029 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3011 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3030 return; 3012 return;
3031 else 3013 else
3032 item = m_host.TaskInventory[InventorySelf()]; 3014 item = m_host.TaskInventory[m_itemID];
3033 } 3015 }
3034 3016
3035 if (item.PermsGranter != m_host.OwnerID) 3017 if (item.PermsGranter != m_host.OwnerID)
@@ -3058,10 +3040,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3058 3040
3059 lock (m_host.TaskInventory) 3041 lock (m_host.TaskInventory)
3060 { 3042 {
3061 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3043 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3062 return; 3044 return;
3063 else 3045 else
3064 item = m_host.TaskInventory[InventorySelf()]; 3046 item = m_host.TaskInventory[m_itemID];
3065 } 3047 }
3066 3048
3067 if (item.PermsGranter != m_host.OwnerID) 3049 if (item.PermsGranter != m_host.OwnerID)
@@ -3313,18 +3295,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3313 { 3295 {
3314 m_host.AddScriptLPS(1); 3296 m_host.AddScriptLPS(1);
3315 3297
3316 UUID invItemID = InventorySelf();
3317 if (invItemID == UUID.Zero)
3318 return;
3319
3320 TaskInventoryItem item; 3298 TaskInventoryItem item;
3321 3299
3322 lock (m_host.TaskInventory) 3300 lock (m_host.TaskInventory)
3323 { 3301 {
3324 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3302 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3325 return; 3303 return;
3326 else 3304 else
3327 item = m_host.TaskInventory[InventorySelf()]; 3305 item = m_host.TaskInventory[m_itemID];
3328 } 3306 }
3329 3307
3330 if (item.PermsGranter == UUID.Zero) 3308 if (item.PermsGranter == UUID.Zero)
@@ -3350,18 +3328,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3350 { 3328 {
3351 m_host.AddScriptLPS(1); 3329 m_host.AddScriptLPS(1);
3352 3330
3353 UUID invItemID=InventorySelf();
3354 if (invItemID == UUID.Zero)
3355 return;
3356
3357 TaskInventoryItem item; 3331 TaskInventoryItem item;
3358 3332
3359 lock (m_host.TaskInventory) 3333 lock (m_host.TaskInventory)
3360 { 3334 {
3361 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3335 if (!m_host.TaskInventory.ContainsKey(m_itemID))
3362 return; 3336 return;
3363 else 3337 else
3364 item = m_host.TaskInventory[InventorySelf()]; 3338 item = m_host.TaskInventory[m_itemID];
3365 } 3339 }
3366 3340
3367 if (item.PermsGranter == UUID.Zero) 3341 if (item.PermsGranter == UUID.Zero)
@@ -3417,21 +3391,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3417 3391
3418 public void llRequestPermissions(string agent, int perm) 3392 public void llRequestPermissions(string agent, int perm)
3419 { 3393 {
3420 UUID agentID = new UUID(); 3394 UUID agentID;
3421 3395
3422 if (!UUID.TryParse(agent, out agentID)) 3396 if (!UUID.TryParse(agent, out agentID))
3423 return; 3397 return;
3424 3398
3425 UUID invItemID = InventorySelf();
3426
3427 if (invItemID == UUID.Zero)
3428 return; // Not in a prim? How??
3429
3430 TaskInventoryItem item; 3399 TaskInventoryItem item;
3431 3400
3432 lock (m_host.TaskInventory) 3401 lock (m_host.TaskInventory)
3433 { 3402 {
3434 item = m_host.TaskInventory[invItemID]; 3403 item = m_host.TaskInventory[m_itemID];
3435 } 3404 }
3436 3405
3437 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3406 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
@@ -3466,8 +3435,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3466 { 3435 {
3467 lock (m_host.TaskInventory) 3436 lock (m_host.TaskInventory)
3468 { 3437 {
3469 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3438 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3470 m_host.TaskInventory[invItemID].PermsMask = perm; 3439 m_host.TaskInventory[m_itemID].PermsMask = perm;
3471 } 3440 }
3472 3441
3473 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3442 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3490,8 +3459,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3490 { 3459 {
3491 lock (m_host.TaskInventory) 3460 lock (m_host.TaskInventory)
3492 { 3461 {
3493 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3462 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3494 m_host.TaskInventory[invItemID].PermsMask = perm; 3463 m_host.TaskInventory[m_itemID].PermsMask = perm;
3495 } 3464 }
3496 3465
3497 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3466 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3515,8 +3484,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3515 { 3484 {
3516 lock (m_host.TaskInventory) 3485 lock (m_host.TaskInventory)
3517 { 3486 {
3518 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3487 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3519 m_host.TaskInventory[invItemID].PermsMask = 0; 3488 m_host.TaskInventory[m_itemID].PermsMask = 0;
3520 } 3489 }
3521 3490
3522 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3491 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3524,7 +3493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3524 } 3493 }
3525 3494
3526 presence.ControllingClient.SendScriptQuestion( 3495 presence.ControllingClient.SendScriptQuestion(
3527 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3496 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
3528 3497
3529 return; 3498 return;
3530 } 3499 }
@@ -3541,20 +3510,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3541 if (taskID != m_host.UUID) 3510 if (taskID != m_host.UUID)
3542 return; 3511 return;
3543 3512
3544 UUID invItemID = InventorySelf(); 3513 client.OnScriptAnswer -= handleScriptAnswer;
3545 3514 m_waitingForScriptAnswer = false;
3546 if (invItemID == UUID.Zero)
3547 return;
3548
3549 client.OnScriptAnswer-=handleScriptAnswer;
3550 m_waitingForScriptAnswer=false;
3551 3515
3552 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3516 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3553 llReleaseControls(); 3517 llReleaseControls();
3554 3518
3555 lock (m_host.TaskInventory) 3519 lock (m_host.TaskInventory)
3556 { 3520 {
3557 m_host.TaskInventory[invItemID].PermsMask = answer; 3521 m_host.TaskInventory[m_itemID].PermsMask = answer;
3558 } 3522 }
3559 3523
3560 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3524 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3627,7 +3591,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3627 public void llCreateLink(string target, int parent) 3591 public void llCreateLink(string target, int parent)
3628 { 3592 {
3629 m_host.AddScriptLPS(1); 3593 m_host.AddScriptLPS(1);
3630 UUID invItemID = InventorySelf(); 3594
3631 UUID targetID; 3595 UUID targetID;
3632 3596
3633 if (!UUID.TryParse(target, out targetID)) 3597 if (!UUID.TryParse(target, out targetID))
@@ -3636,7 +3600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3636 TaskInventoryItem item; 3600 TaskInventoryItem item;
3637 lock (m_host.TaskInventory) 3601 lock (m_host.TaskInventory)
3638 { 3602 {
3639 item = m_host.TaskInventory[invItemID]; 3603 item = m_host.TaskInventory[m_itemID];
3640 } 3604 }
3641 3605
3642 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3606 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
@@ -3688,11 +3652,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3688 public void llBreakLink(int linknum) 3652 public void llBreakLink(int linknum)
3689 { 3653 {
3690 m_host.AddScriptLPS(1); 3654 m_host.AddScriptLPS(1);
3691 UUID invItemID = InventorySelf();
3692 3655
3693 lock (m_host.TaskInventory) 3656 lock (m_host.TaskInventory)
3694 { 3657 {
3695 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3658 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3696 && !m_automaticLinkPermission) 3659 && !m_automaticLinkPermission)
3697 { 3660 {
3698 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3661 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -9691,17 +9654,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9691 public LSL_Vector llGetCameraPos() 9654 public LSL_Vector llGetCameraPos()
9692 { 9655 {
9693 m_host.AddScriptLPS(1); 9656 m_host.AddScriptLPS(1);
9694 UUID invItemID = InventorySelf();
9695
9696 if (invItemID == UUID.Zero)
9697 return new LSL_Vector();
9698 9657
9699 lock (m_host.TaskInventory) 9658 lock (m_host.TaskInventory)
9700 { 9659 {
9701 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9660 if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero)
9702 return new LSL_Vector(); 9661 return new LSL_Vector();
9703 9662
9704 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9663 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9705 { 9664 {
9706 ShoutError("No permissions to track the camera"); 9665 ShoutError("No permissions to track the camera");
9707 return new LSL_Vector(); 9666 return new LSL_Vector();
@@ -9720,16 +9679,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9720 public LSL_Rotation llGetCameraRot() 9679 public LSL_Rotation llGetCameraRot()
9721 { 9680 {
9722 m_host.AddScriptLPS(1); 9681 m_host.AddScriptLPS(1);
9723 UUID invItemID = InventorySelf();
9724 if (invItemID == UUID.Zero)
9725 return new LSL_Rotation();
9726 9682
9727 lock (m_host.TaskInventory) 9683 lock (m_host.TaskInventory)
9728 { 9684 {
9729 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9685 if (m_host.TaskInventory[m_itemID].PermsGranter == UUID.Zero)
9730 return new LSL_Rotation(); 9686 return new LSL_Rotation();
9731 9687
9732 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9688 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9733 { 9689 {
9734 ShoutError("No permissions to track the camera"); 9690 ShoutError("No permissions to track the camera");
9735 return new LSL_Rotation(); 9691 return new LSL_Rotation();
@@ -9907,10 +9863,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9907 { 9863 {
9908 m_host.AddScriptLPS(1); 9864 m_host.AddScriptLPS(1);
9909 9865
9910 // our key in the object we are in
9911 UUID invItemID = InventorySelf();
9912 if (invItemID == UUID.Zero) return;
9913
9914 // the object we are in 9866 // the object we are in
9915 UUID objectID = m_host.ParentUUID; 9867 UUID objectID = m_host.ParentUUID;
9916 if (objectID == UUID.Zero) return; 9868 if (objectID == UUID.Zero) return;
@@ -9919,10 +9871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9919 lock (m_host.TaskInventory) 9871 lock (m_host.TaskInventory)
9920 { 9872 {
9921 // we need the permission first, to know which avatar we want to set the camera for 9873 // we need the permission first, to know which avatar we want to set the camera for
9922 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9874 agentID = m_host.TaskInventory[m_itemID].PermsGranter;
9923 9875
9924 if (agentID == UUID.Zero) return; 9876 if (agentID == UUID.Zero) return;
9925 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9877 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9926 } 9878 }
9927 9879
9928 ScenePresence presence = World.GetScenePresence(agentID); 9880 ScenePresence presence = World.GetScenePresence(agentID);
@@ -9963,10 +9915,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9963 { 9915 {
9964 m_host.AddScriptLPS(1); 9916 m_host.AddScriptLPS(1);
9965 9917
9966 // our key in the object we are in
9967 UUID invItemID=InventorySelf();
9968 if (invItemID == UUID.Zero) return;
9969
9970 // the object we are in 9918 // the object we are in
9971 UUID objectID = m_host.ParentUUID; 9919 UUID objectID = m_host.ParentUUID;
9972 if (objectID == UUID.Zero) return; 9920 if (objectID == UUID.Zero) return;
@@ -9975,9 +9923,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9975 UUID agentID; 9923 UUID agentID;
9976 lock (m_host.TaskInventory) 9924 lock (m_host.TaskInventory)
9977 { 9925 {
9978 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9926 agentID = m_host.TaskInventory[m_itemID].PermsGranter;
9979 if (agentID == UUID.Zero) return; 9927 if (agentID == UUID.Zero) return;
9980 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9928 if ((m_host.TaskInventory[m_itemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9981 } 9929 }
9982 9930
9983 ScenePresence presence = World.GetScenePresence(agentID); 9931 ScenePresence presence = World.GetScenePresence(agentID);