aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs388
1 files changed, 139 insertions, 249 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..d4c872c 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,23 +272,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
267 } 272 }
268 } 273 }
269 274
270 protected UUID InventorySelf() 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()
271 { 284 {
272 UUID invItemID = new UUID();
273
274 lock (m_host.TaskInventory) 285 lock (m_host.TaskInventory)
275 { 286 return m_host.TaskInventory[m_itemID];
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 } 287 }
288 288
289 protected UUID InventoryKey(string name, int type) 289 protected UUID InventoryKey(string name, int type)
@@ -839,13 +839,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
839 839
840 m_host.AddScriptLPS(1); 840 m_host.AddScriptLPS(1);
841 841
842 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
843 {
844 return;
845 }
846
842 UUID TargetID; 847 UUID TargetID;
843 UUID.TryParse(target, out TargetID); 848 UUID.TryParse(target, out TargetID);
844 849
845 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 850 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
846 if (wComm != null) 851 if (wComm != null)
847 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) 852 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
848 LSLError(error);
849 } 853 }
850 854
851 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 855 public LSL_Integer llListen(int channelID, string name, string ID, string msg)
@@ -2697,18 +2701,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2697 2701
2698 public LSL_Integer llGiveMoney(string destination, int amount) 2702 public LSL_Integer llGiveMoney(string destination, int amount)
2699 { 2703 {
2700 UUID invItemID=InventorySelf();
2701 if (invItemID == UUID.Zero)
2702 return 0;
2703
2704 m_host.AddScriptLPS(1); 2704 m_host.AddScriptLPS(1);
2705 2705
2706 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2706 TaskInventoryItem item = GetSelfInventoryItem();
2707
2708 lock (m_host.TaskInventory)
2709 {
2710 item = m_host.TaskInventory[invItemID];
2711 }
2712 2707
2713 if (item.PermsGranter == UUID.Zero) 2708 if (item.PermsGranter == UUID.Zero)
2714 return 0; 2709 return 0;
@@ -2951,15 +2946,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2951 2946
2952 public void llTakeControls(int controls, int accept, int pass_on) 2947 public void llTakeControls(int controls, int accept, int pass_on)
2953 { 2948 {
2954 TaskInventoryItem item; 2949 TaskInventoryItem item = GetSelfInventoryItem();
2955
2956 lock (m_host.TaskInventory)
2957 {
2958 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2959 return;
2960 else
2961 item = m_host.TaskInventory[InventorySelf()];
2962 }
2963 2950
2964 if (item.PermsGranter != UUID.Zero) 2951 if (item.PermsGranter != UUID.Zero)
2965 { 2952 {
@@ -2979,18 +2966,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2979 2966
2980 public void llReleaseControls() 2967 public void llReleaseControls()
2981 { 2968 {
2982 TaskInventoryItem item;
2983
2984 lock (m_host.TaskInventory)
2985 {
2986 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2987 return;
2988 else
2989 item = m_host.TaskInventory[InventorySelf()];
2990 }
2991
2992 m_host.AddScriptLPS(1); 2969 m_host.AddScriptLPS(1);
2993 2970
2971 TaskInventoryItem item = GetSelfInventoryItem();
2972
2994 if (item.PermsGranter != UUID.Zero) 2973 if (item.PermsGranter != UUID.Zero)
2995 { 2974 {
2996 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 2975 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@@ -3015,36 +2994,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3015 m_UrlModule.ReleaseURL(url); 2994 m_UrlModule.ReleaseURL(url);
3016 } 2995 }
3017 2996
3018 public void llAttachToAvatar(int attachment) 2997 /// <summary>
2998 /// Attach the object containing this script to the avatar that owns it.
2999 /// </summary>
3000 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3001 /// <returns>true if the attach suceeded, false if it did not</returns>
3002 public bool AttachToAvatar(int attachmentPoint)
3003 {
3004 SceneObjectGroup grp = m_host.ParentGroup;
3005 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3006
3007 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3008
3009 if (attachmentsModule != null)
3010 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3011 else
3012 return false;
3013 }
3014
3015 /// <summary>
3016 /// Detach the object containing this script from the avatar it is attached to.
3017 /// </summary>
3018 /// <remarks>
3019 /// Nothing happens if the object is not attached.
3020 /// </remarks>
3021 public void DetachFromAvatar()
3022 {
3023 Util.FireAndForget(DetachWrapper, m_host);
3024 }
3025
3026 private void DetachWrapper(object o)
3027 {
3028 SceneObjectPart host = (SceneObjectPart)o;
3029
3030 SceneObjectGroup grp = host.ParentGroup;
3031 UUID itemID = grp.FromItemID;
3032 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3033
3034 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3035 if (attachmentsModule != null)
3036 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3037 }
3038
3039 public void llAttachToAvatar(int attachmentPoint)
3019 { 3040 {
3020 m_host.AddScriptLPS(1); 3041 m_host.AddScriptLPS(1);
3021 3042
3022// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) 3043// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0)
3023// return; 3044// return;
3024 3045
3025 TaskInventoryItem item; 3046 TaskInventoryItem item = GetSelfInventoryItem();
3026
3027 lock (m_host.TaskInventory)
3028 {
3029 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3030 return;
3031 else
3032 item = m_host.TaskInventory[InventorySelf()];
3033 }
3034 3047
3035 if (item.PermsGranter != m_host.OwnerID) 3048 if (item.PermsGranter != m_host.OwnerID)
3036 return; 3049 return;
3037 3050
3038 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3051 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3039 { 3052 AttachToAvatar(attachmentPoint);
3040 SceneObjectGroup grp = m_host.ParentGroup;
3041
3042 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3043
3044 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3045 if (attachmentsModule != null)
3046 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
3047 }
3048 } 3053 }
3049 3054
3050 public void llDetachFromAvatar() 3055 public void llDetachFromAvatar()
@@ -3054,38 +3059,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3054 if (m_host.ParentGroup.AttachmentPoint == 0) 3059 if (m_host.ParentGroup.AttachmentPoint == 0)
3055 return; 3060 return;
3056 3061
3057 TaskInventoryItem item; 3062 TaskInventoryItem item = GetSelfInventoryItem();
3058
3059 lock (m_host.TaskInventory)
3060 {
3061 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3062 return;
3063 else
3064 item = m_host.TaskInventory[InventorySelf()];
3065 }
3066 3063
3067 if (item.PermsGranter != m_host.OwnerID) 3064 if (item.PermsGranter != m_host.OwnerID)
3068 return; 3065 return;
3069 3066
3070 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3067 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3071 { 3068 DetachFromAvatar();
3072 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3073 if (attachmentsModule != null)
3074 Util.FireAndForget(DetachWrapper, m_host);
3075 }
3076 }
3077
3078 private void DetachWrapper(object o)
3079 {
3080 SceneObjectPart host = (SceneObjectPart)o;
3081
3082 SceneObjectGroup grp = host.ParentGroup;
3083 UUID itemID = grp.FromItemID;
3084 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3085
3086 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3087 if (attachmentsModule != null)
3088 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3089 } 3069 }
3090 3070
3091 public void llTakeCamera(string avatar) 3071 public void llTakeCamera(string avatar)
@@ -3313,19 +3293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3313 { 3293 {
3314 m_host.AddScriptLPS(1); 3294 m_host.AddScriptLPS(1);
3315 3295
3316 UUID invItemID = InventorySelf(); 3296 TaskInventoryItem item = GetSelfInventoryItem();
3317 if (invItemID == UUID.Zero)
3318 return;
3319
3320 TaskInventoryItem item;
3321
3322 lock (m_host.TaskInventory)
3323 {
3324 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3325 return;
3326 else
3327 item = m_host.TaskInventory[InventorySelf()];
3328 }
3329 3297
3330 if (item.PermsGranter == UUID.Zero) 3298 if (item.PermsGranter == UUID.Zero)
3331 return; 3299 return;
@@ -3350,19 +3318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3350 { 3318 {
3351 m_host.AddScriptLPS(1); 3319 m_host.AddScriptLPS(1);
3352 3320
3353 UUID invItemID=InventorySelf(); 3321 TaskInventoryItem item = GetSelfInventoryItem();
3354 if (invItemID == UUID.Zero)
3355 return;
3356
3357 TaskInventoryItem item;
3358
3359 lock (m_host.TaskInventory)
3360 {
3361 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3362 return;
3363 else
3364 item = m_host.TaskInventory[InventorySelf()];
3365 }
3366 3322
3367 if (item.PermsGranter == UUID.Zero) 3323 if (item.PermsGranter == UUID.Zero)
3368 return; 3324 return;
@@ -3417,22 +3373,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3417 3373
3418 public void llRequestPermissions(string agent, int perm) 3374 public void llRequestPermissions(string agent, int perm)
3419 { 3375 {
3420 UUID agentID = new UUID(); 3376 UUID agentID;
3421 3377
3422 if (!UUID.TryParse(agent, out agentID)) 3378 if (!UUID.TryParse(agent, out agentID))
3423 return; 3379 return;
3424 3380
3425 UUID invItemID = InventorySelf(); 3381 TaskInventoryItem item = GetSelfInventoryItem();
3426
3427 if (invItemID == UUID.Zero)
3428 return; // Not in a prim? How??
3429
3430 TaskInventoryItem item;
3431
3432 lock (m_host.TaskInventory)
3433 {
3434 item = m_host.TaskInventory[invItemID];
3435 }
3436 3382
3437 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3383 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3438 { 3384 {
@@ -3466,8 +3412,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3466 { 3412 {
3467 lock (m_host.TaskInventory) 3413 lock (m_host.TaskInventory)
3468 { 3414 {
3469 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3415 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3470 m_host.TaskInventory[invItemID].PermsMask = perm; 3416 m_host.TaskInventory[m_itemID].PermsMask = perm;
3471 } 3417 }
3472 3418
3473 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3419 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3490,8 +3436,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3490 { 3436 {
3491 lock (m_host.TaskInventory) 3437 lock (m_host.TaskInventory)
3492 { 3438 {
3493 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3439 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3494 m_host.TaskInventory[invItemID].PermsMask = perm; 3440 m_host.TaskInventory[m_itemID].PermsMask = perm;
3495 } 3441 }
3496 3442
3497 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3443 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3515,8 +3461,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3515 { 3461 {
3516 lock (m_host.TaskInventory) 3462 lock (m_host.TaskInventory)
3517 { 3463 {
3518 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3464 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3519 m_host.TaskInventory[invItemID].PermsMask = 0; 3465 m_host.TaskInventory[m_itemID].PermsMask = 0;
3520 } 3466 }
3521 3467
3522 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3468 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3524,7 +3470,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3524 } 3470 }
3525 3471
3526 presence.ControllingClient.SendScriptQuestion( 3472 presence.ControllingClient.SendScriptQuestion(
3527 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3473 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
3528 3474
3529 return; 3475 return;
3530 } 3476 }
@@ -3541,20 +3487,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3541 if (taskID != m_host.UUID) 3487 if (taskID != m_host.UUID)
3542 return; 3488 return;
3543 3489
3544 UUID invItemID = InventorySelf(); 3490 client.OnScriptAnswer -= handleScriptAnswer;
3545 3491 m_waitingForScriptAnswer = false;
3546 if (invItemID == UUID.Zero)
3547 return;
3548
3549 client.OnScriptAnswer-=handleScriptAnswer;
3550 m_waitingForScriptAnswer=false;
3551 3492
3552 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3493 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3553 llReleaseControls(); 3494 llReleaseControls();
3554 3495
3555 lock (m_host.TaskInventory) 3496 lock (m_host.TaskInventory)
3556 { 3497 {
3557 m_host.TaskInventory[invItemID].PermsMask = answer; 3498 m_host.TaskInventory[m_itemID].PermsMask = answer;
3558 } 3499 }
3559 3500
3560 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3501 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3567,39 +3508,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3567 { 3508 {
3568 m_host.AddScriptLPS(1); 3509 m_host.AddScriptLPS(1);
3569 3510
3570 lock (m_host.TaskInventory) 3511 return GetSelfInventoryItem().PermsGranter.ToString();
3571 {
3572 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3573 {
3574 if (item.Type == 10 && item.ItemID == m_itemID)
3575 {
3576 return item.PermsGranter.ToString();
3577 }
3578 }
3579 }
3580
3581 return UUID.Zero.ToString();
3582 } 3512 }
3583 3513
3584 public LSL_Integer llGetPermissions() 3514 public LSL_Integer llGetPermissions()
3585 { 3515 {
3586 m_host.AddScriptLPS(1); 3516 m_host.AddScriptLPS(1);
3587 3517
3588 lock (m_host.TaskInventory) 3518 int perms = GetSelfInventoryItem().PermsMask;
3589 {
3590 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3591 {
3592 if (item.Type == 10 && item.ItemID == m_itemID)
3593 {
3594 int perms = item.PermsMask;
3595 if (m_automaticLinkPermission)
3596 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3597 return perms;
3598 }
3599 }
3600 }
3601 3519
3602 return 0; 3520 if (m_automaticLinkPermission)
3521 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3522
3523 return perms;
3603 } 3524 }
3604 3525
3605 public LSL_Integer llGetLinkNumber() 3526 public LSL_Integer llGetLinkNumber()
@@ -3627,17 +3548,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3627 public void llCreateLink(string target, int parent) 3548 public void llCreateLink(string target, int parent)
3628 { 3549 {
3629 m_host.AddScriptLPS(1); 3550 m_host.AddScriptLPS(1);
3630 UUID invItemID = InventorySelf(); 3551
3631 UUID targetID; 3552 UUID targetID;
3632 3553
3633 if (!UUID.TryParse(target, out targetID)) 3554 if (!UUID.TryParse(target, out targetID))
3634 return; 3555 return;
3635 3556
3636 TaskInventoryItem item; 3557 TaskInventoryItem item = GetSelfInventoryItem();
3637 lock (m_host.TaskInventory)
3638 {
3639 item = m_host.TaskInventory[invItemID];
3640 }
3641 3558
3642 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3559 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3643 && !m_automaticLinkPermission) 3560 && !m_automaticLinkPermission)
@@ -3688,16 +3605,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3688 public void llBreakLink(int linknum) 3605 public void llBreakLink(int linknum)
3689 { 3606 {
3690 m_host.AddScriptLPS(1); 3607 m_host.AddScriptLPS(1);
3691 UUID invItemID = InventorySelf();
3692 3608
3693 lock (m_host.TaskInventory) 3609 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3610 && !m_automaticLinkPermission)
3694 { 3611 {
3695 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3612 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3696 && !m_automaticLinkPermission) 3613 return;
3697 {
3698 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3699 return;
3700 }
3701 } 3614 }
3702 3615
3703 if (linknum < ScriptBaseClass.LINK_THIS) 3616 if (linknum < ScriptBaseClass.LINK_THIS)
@@ -4574,23 +4487,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4574 4487
4575 public LSL_String llGetScriptName() 4488 public LSL_String llGetScriptName()
4576 { 4489 {
4577 string result = String.Empty;
4578
4579 m_host.AddScriptLPS(1); 4490 m_host.AddScriptLPS(1);
4580 4491
4581 lock (m_host.TaskInventory) 4492 TaskInventoryItem item = GetSelfInventoryItem();
4582 {
4583 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4584 {
4585 if (item.Type == 10 && item.ItemID == m_itemID)
4586 {
4587 result = item.Name != null ? item.Name : String.Empty;
4588 break;
4589 }
4590 }
4591 }
4592 4493
4593 return result; 4494 return item.Name != null ? item.Name : String.Empty;
4594 } 4495 }
4595 4496
4596 public LSL_Integer llGetLinkNumberOfSides(int link) 4497 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -9691,21 +9592,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9691 public LSL_Vector llGetCameraPos() 9592 public LSL_Vector llGetCameraPos()
9692 { 9593 {
9693 m_host.AddScriptLPS(1); 9594 m_host.AddScriptLPS(1);
9694 UUID invItemID = InventorySelf();
9695 9595
9696 if (invItemID == UUID.Zero) 9596 TaskInventoryItem item = GetSelfInventoryItem();
9697 return new LSL_Vector();
9698 9597
9699 lock (m_host.TaskInventory) 9598 if (item.PermsGranter == UUID.Zero)
9700 { 9599 return new LSL_Vector();
9701 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9702 return new LSL_Vector();
9703 9600
9704 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9601 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9705 { 9602 {
9706 ShoutError("No permissions to track the camera"); 9603 ShoutError("No permissions to track the camera");
9707 return new LSL_Vector(); 9604 return new LSL_Vector();
9708 }
9709 } 9605 }
9710 9606
9711 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9607 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9720,20 +9616,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9720 public LSL_Rotation llGetCameraRot() 9616 public LSL_Rotation llGetCameraRot()
9721 { 9617 {
9722 m_host.AddScriptLPS(1); 9618 m_host.AddScriptLPS(1);
9723 UUID invItemID = InventorySelf();
9724 if (invItemID == UUID.Zero)
9725 return new LSL_Rotation();
9726 9619
9727 lock (m_host.TaskInventory) 9620 TaskInventoryItem item = GetSelfInventoryItem();
9728 {
9729 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
9730 return new LSL_Rotation();
9731 9621
9732 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9622 if (item.PermsGranter == UUID.Zero)
9733 { 9623 return new LSL_Rotation();
9734 ShoutError("No permissions to track the camera"); 9624
9735 return new LSL_Rotation(); 9625 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
9736 } 9626 {
9627 ShoutError("No permissions to track the camera");
9628 return new LSL_Rotation();
9737 } 9629 }
9738 9630
9739 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9631 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
@@ -9907,23 +9799,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9907 { 9799 {
9908 m_host.AddScriptLPS(1); 9800 m_host.AddScriptLPS(1);
9909 9801
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 9802 // the object we are in
9915 UUID objectID = m_host.ParentUUID; 9803 UUID objectID = m_host.ParentUUID;
9916 if (objectID == UUID.Zero) return; 9804 if (objectID == UUID.Zero)
9805 return;
9917 9806
9918 UUID agentID; 9807 TaskInventoryItem item = GetSelfInventoryItem();
9919 lock (m_host.TaskInventory)
9920 {
9921 // we need the permission first, to know which avatar we want to set the camera for
9922 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9923 9808
9924 if (agentID == UUID.Zero) return; 9809 // we need the permission first, to know which avatar we want to set the camera for
9925 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9810 UUID agentID = item.PermsGranter;
9926 } 9811
9812 if (agentID == UUID.Zero)
9813 return;
9814
9815 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9816 return;
9927 9817
9928 ScenePresence presence = World.GetScenePresence(agentID); 9818 ScenePresence presence = World.GetScenePresence(agentID);
9929 9819
@@ -9963,27 +9853,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9963 { 9853 {
9964 m_host.AddScriptLPS(1); 9854 m_host.AddScriptLPS(1);
9965 9855
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 9856 // the object we are in
9971 UUID objectID = m_host.ParentUUID; 9857 UUID objectID = m_host.ParentUUID;
9972 if (objectID == UUID.Zero) return; 9858 if (objectID == UUID.Zero)
9859 return;
9860
9861 TaskInventoryItem item = GetSelfInventoryItem();
9973 9862
9974 // we need the permission first, to know which avatar we want to clear the camera for 9863 // we need the permission first, to know which avatar we want to clear the camera for
9975 UUID agentID; 9864 UUID agentID = item.PermsGranter;
9976 lock (m_host.TaskInventory) 9865
9977 { 9866 if (agentID == UUID.Zero)
9978 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9867 return;
9979 if (agentID == UUID.Zero) return; 9868
9980 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9869 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9981 } 9870 return;
9982 9871
9983 ScenePresence presence = World.GetScenePresence(agentID); 9872 ScenePresence presence = World.GetScenePresence(agentID);
9984 9873
9985 // we are not interested in child-agents 9874 // we are not interested in child-agents
9986 if (presence.IsChildAgent) return; 9875 if (presence.IsChildAgent)
9876 return;
9987 9877
9988 presence.ControllingClient.SendClearFollowCamProperties(objectID); 9878 presence.ControllingClient.SendClearFollowCamProperties(objectID);
9989 } 9879 }