aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMelanie2012-04-24 21:30:12 +0100
committerMelanie2012-04-24 21:30:12 +0100
commitc5520dc83fbbab83bd341b77f7b137443988b0fc (patch)
tree92596941f74061d88bea7d65b18066994245c44d /OpenSim/Region/ScriptEngine/Shared
parentMerge branch 'master' of ssh://melanie@3dhosting.de/var/git/careminster into ... (diff)
parentFixed problem with MySQL: it was possible for one thread to use an incomplete... (diff)
downloadopensim-SC-c5520dc83fbbab83bd341b77f7b137443988b0fc.zip
opensim-SC-c5520dc83fbbab83bd341b77f7b137443988b0fc.tar.gz
opensim-SC-c5520dc83fbbab83bd341b77f7b137443988b0fc.tar.bz2
opensim-SC-c5520dc83fbbab83bd341b77f7b137443988b0fc.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs433
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs7
6 files changed, 215 insertions, 323 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
index 47ed6ba..684138f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
@@ -29,42 +29,43 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net;
32using OpenSim.Region.ScriptEngine.Interfaces; 33using OpenSim.Region.ScriptEngine.Interfaces;
33 34
34namespace OpenSim.Region.ScriptEngine.Shared.Api 35namespace OpenSim.Region.ScriptEngine.Shared.Api
35{ 36{
36 public class ApiManager 37 public class ApiManager
37 { 38 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
38 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); 41 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
39 42
40 public string[] GetApis() 43 public string[] GetApis()
41 { 44 {
42 if (m_Apis.Count > 0) 45 if (m_Apis.Count <= 0)
43 { 46 {
44 List<string> l = new List<string>(m_Apis.Keys); 47 Assembly a = Assembly.GetExecutingAssembly();
45 return l.ToArray();
46 }
47 48
48 Assembly a = Assembly.GetExecutingAssembly(); 49 Type[] types = a.GetExportedTypes();
49 50
50 Type[] types = a.GetExportedTypes(); 51 foreach (Type t in types)
51
52 foreach (Type t in types)
53 {
54 string name = t.ToString();
55 int idx = name.LastIndexOf('.');
56 if (idx != -1)
57 name = name.Substring(idx+1);
58
59 if (name.EndsWith("_Api"))
60 { 52 {
61 name = name.Substring(0, name.Length - 4); 53 string name = t.ToString();
62 m_Apis[name] = t; 54 int idx = name.LastIndexOf('.');
55 if (idx != -1)
56 name = name.Substring(idx+1);
57
58 if (name.EndsWith("_Api"))
59 {
60 name = name.Substring(0, name.Length - 4);
61 m_Apis[name] = t;
62 }
63 } 63 }
64 } 64 }
65 65
66 List<string> ret = new List<string>(m_Apis.Keys); 66// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
67 return ret.ToArray(); 67
68 return new List<string>(m_Apis.Keys).ToArray();
68 } 69 }
69 70
70 public IScriptApi CreateApi(string api) 71 public IScriptApi CreateApi(string api)
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
76 return ret; 77 return ret;
77 } 78 }
78 } 79 }
79} 80} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 425d2c5..8637df7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -89,7 +89,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
89 protected IScriptEngine m_ScriptEngine; 89 protected IScriptEngine m_ScriptEngine;
90 protected SceneObjectPart m_host; 90 protected SceneObjectPart m_host;
91 protected uint m_localID; 91 protected uint m_localID;
92
93 /// <summary>
94 /// The UUID of the item that hosts this script
95 /// </summary>
92 protected UUID m_itemID; 96 protected UUID m_itemID;
97
93 protected bool throwErrorOnNotImplemented = true; 98 protected bool throwErrorOnNotImplemented = true;
94 protected AsyncCommandManager AsyncCommands = null; 99 protected AsyncCommandManager AsyncCommands = null;
95 protected float m_ScriptDelayFactor = 1.0f; 100 protected float m_ScriptDelayFactor = 1.0f;
@@ -336,28 +341,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
336 } 341 }
337 } 342 }
338 343
339 protected UUID InventorySelf() 344 /// <summary>
345 /// Get the inventory item that hosts ourselves.
346 /// </summary>
347 /// <remarks>
348 /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
349 /// to keep looking ourselves up.
350 /// </remarks>
351 /// <returns></returns>
352 protected TaskInventoryItem GetSelfInventoryItem()
340 { 353 {
341 UUID invItemID = new UUID(); 354 TaskInventoryItem invItem = null;
355
342 bool unlock = false; 356 bool unlock = false;
343 if (!m_host.TaskInventory.IsReadLockedByMe()) 357 if (!m_host.TaskInventory.IsReadLockedByMe())
344 { 358 {
345 m_host.TaskInventory.LockItemsForRead(true); 359 m_host.TaskInventory.LockItemsForRead(true);
346 unlock = true; 360 unlock = true;
347 } 361 }
348 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 362
349 { 363 invItem = m_host.TaskInventory[m_itemID];
350 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 364
351 {
352 invItemID = inv.Key;
353 break;
354 }
355 }
356 if (unlock) 365 if (unlock)
357 { 366 {
358 m_host.TaskInventory.LockItemsForRead(false); 367 m_host.TaskInventory.LockItemsForRead(false);
359 } 368 }
360 return invItemID; 369
370 return invItem;
361 } 371 }
362 372
363 protected UUID InventoryKey(string name, int type) 373 protected UUID InventoryKey(string name, int type)
@@ -941,8 +951,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
941 951
942 public void llRegionSayTo(string target, int channel, string msg) 952 public void llRegionSayTo(string target, int channel, string msg)
943 { 953 {
944 string error = String.Empty;
945
946 if (msg.Length > 1023) 954 if (msg.Length > 1023)
947 msg = msg.Substring(0, 1023); 955 msg = msg.Substring(0, 1023);
948 956
@@ -2952,15 +2960,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2952 2960
2953 public LSL_Integer llGiveMoney(string destination, int amount) 2961 public LSL_Integer llGiveMoney(string destination, int amount)
2954 { 2962 {
2955 UUID invItemID=InventorySelf();
2956 if (invItemID == UUID.Zero)
2957 return 0;
2958
2959 m_host.AddScriptLPS(1); 2963 m_host.AddScriptLPS(1);
2960 2964
2961 m_host.TaskInventory.LockItemsForRead(true); 2965 TaskInventoryItem item = GetSelfInventoryItem();
2962 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2963 m_host.TaskInventory.LockItemsForRead(false);
2964 2966
2965 if (item.PermsGranter == UUID.Zero) 2967 if (item.PermsGranter == UUID.Zero)
2966 return 0; 2968 return 0;
@@ -3214,19 +3216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3214 3216
3215 public void llTakeControls(int controls, int accept, int pass_on) 3217 public void llTakeControls(int controls, int accept, int pass_on)
3216 { 3218 {
3217 TaskInventoryItem item; 3219 TaskInventoryItem item = GetSelfInventoryItem();
3218
3219 m_host.TaskInventory.LockItemsForRead(true);
3220 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3221 {
3222 m_host.TaskInventory.LockItemsForRead(false);
3223 return;
3224 }
3225 else
3226 {
3227 item = m_host.TaskInventory[InventorySelf()];
3228 }
3229 m_host.TaskInventory.LockItemsForRead(false);
3230 3220
3231 if (item.PermsGranter != UUID.Zero) 3221 if (item.PermsGranter != UUID.Zero)
3232 { 3222 {
@@ -3246,26 +3236,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3246 3236
3247 public void llReleaseControls() 3237 public void llReleaseControls()
3248 { 3238 {
3249 TaskInventoryItem item;
3250
3251 m_host.TaskInventory.LockItemsForRead(true);
3252 lock (m_host.TaskInventory)
3253 {
3254
3255 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3256 {
3257 m_host.TaskInventory.LockItemsForRead(false);
3258 return;
3259 }
3260 else
3261 {
3262 item = m_host.TaskInventory[InventorySelf()];
3263 }
3264 }
3265 m_host.TaskInventory.LockItemsForRead(false);
3266
3267 m_host.AddScriptLPS(1); 3239 m_host.AddScriptLPS(1);
3268 3240
3241 TaskInventoryItem item = GetSelfInventoryItem();
3242
3269 if (item.PermsGranter != UUID.Zero) 3243 if (item.PermsGranter != UUID.Zero)
3270 { 3244 {
3271 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3245 ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@@ -3290,86 +3264,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3290 m_UrlModule.ReleaseURL(url); 3264 m_UrlModule.ReleaseURL(url);
3291 } 3265 }
3292 3266
3293 public void llAttachToAvatar(int attachment) 3267 /// <summary>
3268 /// Attach the object containing this script to the avatar that owns it.
3269 /// </summary>
3270 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3271 /// <returns>true if the attach suceeded, false if it did not</returns>
3272 public bool AttachToAvatar(int attachmentPoint)
3294 { 3273 {
3295 m_host.AddScriptLPS(1); 3274 SceneObjectGroup grp = m_host.ParentGroup;
3296 3275 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3297 TaskInventoryItem item;
3298 3276
3299 m_host.TaskInventory.LockItemsForRead(true); 3277 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3300 3278
3301 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3279 if (attachmentsModule != null)
3302 { 3280 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3303 m_host.TaskInventory.LockItemsForRead(false);
3304 return;
3305 }
3306 else 3281 else
3307 { 3282 return false;
3308 item = m_host.TaskInventory[InventorySelf()]; 3283 }
3309 }
3310
3311 m_host.TaskInventory.LockItemsForRead(false);
3312 3284
3313 if (item.PermsGranter != m_host.OwnerID) 3285 /// <summary>
3314 return; 3286 /// Detach the object containing this script from the avatar it is attached to.
3287 /// </summary>
3288 /// <remarks>
3289 /// Nothing happens if the object is not attached.
3290 /// </remarks>
3291 public void DetachFromAvatar()
3292 {
3293 Util.FireAndForget(DetachWrapper, m_host);
3294 }
3315 3295
3316 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3296 private void DetachWrapper(object o)
3317 { 3297 {
3318 SceneObjectGroup grp = m_host.ParentGroup; 3298 SceneObjectPart host = (SceneObjectPart)o;
3319 3299
3320 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 3300 SceneObjectGroup grp = host.ParentGroup;
3301 UUID itemID = grp.FromItemID;
3302 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3321 3303
3322 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3304 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3323 if (attachmentsModule != null) 3305 if (attachmentsModule != null)
3324 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); 3306 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3325 }
3326 } 3307 }
3327 3308
3328 public void llDetachFromAvatar() 3309 public void llAttachToAvatar(int attachmentPoint)
3329 { 3310 {
3330 m_host.AddScriptLPS(1); 3311 m_host.AddScriptLPS(1);
3331 3312
3332 if (m_host.ParentGroup.AttachmentPoint == 0) 3313 TaskInventoryItem item = GetSelfInventoryItem();
3333 return;
3334
3335 TaskInventoryItem item;
3336 3314
3337 m_host.TaskInventory.LockItemsForRead(true);
3338
3339 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3340 {
3341 m_host.TaskInventory.LockItemsForRead(false);
3342 return;
3343 }
3344 else
3345 {
3346 item = m_host.TaskInventory[InventorySelf()];
3347 }
3348 m_host.TaskInventory.LockItemsForRead(false); 3315 m_host.TaskInventory.LockItemsForRead(false);
3349 3316
3350
3351 if (item.PermsGranter != m_host.OwnerID) 3317 if (item.PermsGranter != m_host.OwnerID)
3352 return; 3318 return;
3353 3319
3354 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3320 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3355 { 3321 AttachToAvatar(attachmentPoint);
3356 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3357 if (attachmentsModule != null)
3358 Util.FireAndForget(DetachWrapper, m_host);
3359 }
3360 } 3322 }
3361 3323
3362 private void DetachWrapper(object o) 3324 public void llDetachFromAvatar()
3363 { 3325 {
3364 SceneObjectPart host = (SceneObjectPart)o; 3326 m_host.AddScriptLPS(1);
3365 3327
3366 SceneObjectGroup grp = host.ParentGroup; 3328 if (m_host.ParentGroup.AttachmentPoint == 0)
3367 UUID itemID = grp.FromItemID; 3329 return;
3368 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3369 3330
3370 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3331 TaskInventoryItem item = GetSelfInventoryItem();
3371 if (attachmentsModule != null) 3332
3372 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); 3333 if (item.PermsGranter != m_host.OwnerID)
3334 return;
3335
3336 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3337 DetachFromAvatar();
3373 } 3338 }
3374 3339
3375 public void llTakeCamera(string avatar) 3340 public void llTakeCamera(string avatar)
@@ -3626,23 +3591,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3626 { 3591 {
3627 m_host.AddScriptLPS(1); 3592 m_host.AddScriptLPS(1);
3628 3593
3629 UUID invItemID = InventorySelf(); 3594 TaskInventoryItem item = GetSelfInventoryItem();
3630 if (invItemID == UUID.Zero)
3631 return;
3632
3633 TaskInventoryItem item;
3634 3595
3635 m_host.TaskInventory.LockItemsForRead(true);
3636 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3637 {
3638 m_host.TaskInventory.LockItemsForRead(false);
3639 return;
3640 }
3641 else
3642 {
3643 item = m_host.TaskInventory[InventorySelf()];
3644 }
3645 m_host.TaskInventory.LockItemsForRead(false);
3646 if (item.PermsGranter == UUID.Zero) 3596 if (item.PermsGranter == UUID.Zero)
3647 return; 3597 return;
3648 3598
@@ -3666,24 +3616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3666 { 3616 {
3667 m_host.AddScriptLPS(1); 3617 m_host.AddScriptLPS(1);
3668 3618
3669 UUID invItemID=InventorySelf(); 3619 TaskInventoryItem item = GetSelfInventoryItem();
3670 if (invItemID == UUID.Zero)
3671 return;
3672
3673 TaskInventoryItem item;
3674
3675 m_host.TaskInventory.LockItemsForRead(true);
3676 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3677 {
3678 m_host.TaskInventory.LockItemsForRead(false);
3679 return;
3680 }
3681 else
3682 {
3683 item = m_host.TaskInventory[InventorySelf()];
3684 }
3685 m_host.TaskInventory.LockItemsForRead(false);
3686
3687 3620
3688 if (item.PermsGranter == UUID.Zero) 3621 if (item.PermsGranter == UUID.Zero)
3689 return; 3622 return;
@@ -3738,30 +3671,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3738 3671
3739 public void llRequestPermissions(string agent, int perm) 3672 public void llRequestPermissions(string agent, int perm)
3740 { 3673 {
3741 UUID agentID = new UUID(); 3674 UUID agentID;
3742 3675
3743 if (!UUID.TryParse(agent, out agentID)) 3676 if (!UUID.TryParse(agent, out agentID))
3744 return; 3677 return;
3745 3678
3746 UUID invItemID = InventorySelf(); 3679 TaskInventoryItem item = GetSelfInventoryItem();
3747
3748 if (invItemID == UUID.Zero)
3749 return; // Not in a prim? How??
3750
3751 TaskInventoryItem item;
3752
3753
3754 m_host.TaskInventory.LockItemsForRead(true);
3755 if (!m_host.TaskInventory.ContainsKey(invItemID))
3756 {
3757 m_host.TaskInventory.LockItemsForRead(false);
3758 return;
3759 }
3760 else
3761 {
3762 item = m_host.TaskInventory[invItemID];
3763 }
3764 m_host.TaskInventory.LockItemsForRead(false);
3765 3680
3766 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3681 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3767 { 3682 {
@@ -3795,8 +3710,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3795 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3710 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3796 { 3711 {
3797 m_host.TaskInventory.LockItemsForWrite(true); 3712 m_host.TaskInventory.LockItemsForWrite(true);
3798 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3713 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3799 m_host.TaskInventory[invItemID].PermsMask = perm; 3714 m_host.TaskInventory[m_itemID].PermsMask = perm;
3800 m_host.TaskInventory.LockItemsForWrite(false); 3715 m_host.TaskInventory.LockItemsForWrite(false);
3801 3716
3802 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3717 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3834,8 +3749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3834 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3749 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3835 { 3750 {
3836 m_host.TaskInventory.LockItemsForWrite(true); 3751 m_host.TaskInventory.LockItemsForWrite(true);
3837 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3752 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3838 m_host.TaskInventory[invItemID].PermsMask = perm; 3753 m_host.TaskInventory[m_itemID].PermsMask = perm;
3839 m_host.TaskInventory.LockItemsForWrite(false); 3754 m_host.TaskInventory.LockItemsForWrite(false);
3840 3755
3841 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3756 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@@ -3859,8 +3774,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3859 if (!m_waitingForScriptAnswer) 3774 if (!m_waitingForScriptAnswer)
3860 { 3775 {
3861 m_host.TaskInventory.LockItemsForWrite(true); 3776 m_host.TaskInventory.LockItemsForWrite(true);
3862 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3777 m_host.TaskInventory[m_itemID].PermsGranter = agentID;
3863 m_host.TaskInventory[invItemID].PermsMask = 0; 3778 m_host.TaskInventory[m_itemID].PermsMask = 0;
3864 m_host.TaskInventory.LockItemsForWrite(false); 3779 m_host.TaskInventory.LockItemsForWrite(false);
3865 3780
3866 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3781 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3868,7 +3783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3868 } 3783 }
3869 3784
3870 presence.ControllingClient.SendScriptQuestion( 3785 presence.ControllingClient.SendScriptQuestion(
3871 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); 3786 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
3872 3787
3873 return; 3788 return;
3874 } 3789 }
@@ -3885,23 +3800,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3885 if (taskID != m_host.UUID) 3800 if (taskID != m_host.UUID)
3886 return; 3801 return;
3887 3802
3888 UUID invItemID = InventorySelf(); 3803 client.OnScriptAnswer -= handleScriptAnswer;
3889 3804 m_waitingForScriptAnswer = false;
3890 if (invItemID == UUID.Zero)
3891 return;
3892
3893 client.OnScriptAnswer-=handleScriptAnswer;
3894 m_waitingForScriptAnswer=false;
3895 3805
3896 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3806 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3897 llReleaseControls(); 3807 llReleaseControls();
3898 3808
3899
3900 m_host.TaskInventory.LockItemsForWrite(true); 3809 m_host.TaskInventory.LockItemsForWrite(true);
3901 m_host.TaskInventory[invItemID].PermsMask = answer; 3810 m_host.TaskInventory[m_itemID].PermsMask = answer;
3902 m_host.TaskInventory.LockItemsForWrite(false); 3811 m_host.TaskInventory.LockItemsForWrite(false);
3903 3812
3904
3905 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3813 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3906 "run_time_permissions", new Object[] { 3814 "run_time_permissions", new Object[] {
3907 new LSL_Integer(answer) }, 3815 new LSL_Integer(answer) },
@@ -3912,41 +3820,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3912 { 3820 {
3913 m_host.AddScriptLPS(1); 3821 m_host.AddScriptLPS(1);
3914 3822
3915 m_host.TaskInventory.LockItemsForRead(true); 3823 return GetSelfInventoryItem().PermsGranter.ToString();
3916
3917 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3918 {
3919 if (item.Type == 10 && item.ItemID == m_itemID)
3920 {
3921 m_host.TaskInventory.LockItemsForRead(false);
3922 return item.PermsGranter.ToString();
3923 }
3924 }
3925 m_host.TaskInventory.LockItemsForRead(false);
3926
3927 return UUID.Zero.ToString();
3928 } 3824 }
3929 3825
3930 public LSL_Integer llGetPermissions() 3826 public LSL_Integer llGetPermissions()
3931 { 3827 {
3932 m_host.AddScriptLPS(1); 3828 m_host.AddScriptLPS(1);
3933 3829
3934 m_host.TaskInventory.LockItemsForRead(true); 3830 int perms = GetSelfInventoryItem().PermsMask;
3935 3831
3936 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3832 if (m_automaticLinkPermission)
3937 { 3833 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3938 if (item.Type == 10 && item.ItemID == m_itemID)
3939 {
3940 int perms = item.PermsMask;
3941 if (m_automaticLinkPermission)
3942 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3943 m_host.TaskInventory.LockItemsForRead(false);
3944 return perms;
3945 }
3946 }
3947 m_host.TaskInventory.LockItemsForRead(false);
3948 3834
3949 return 0; 3835 return perms;
3950 } 3836 }
3951 3837
3952 public LSL_Integer llGetLinkNumber() 3838 public LSL_Integer llGetLinkNumber()
@@ -3984,17 +3870,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3984 public void llCreateLink(string target, int parent) 3870 public void llCreateLink(string target, int parent)
3985 { 3871 {
3986 m_host.AddScriptLPS(1); 3872 m_host.AddScriptLPS(1);
3987 UUID invItemID = InventorySelf(); 3873
3988 UUID targetID; 3874 UUID targetID;
3989 3875
3990 if (!UUID.TryParse(target, out targetID)) 3876 if (!UUID.TryParse(target, out targetID))
3991 return; 3877 return;
3992 3878
3993 TaskInventoryItem item; 3879 TaskInventoryItem item = GetSelfInventoryItem();
3994 m_host.TaskInventory.LockItemsForRead(true); 3880
3995 item = m_host.TaskInventory[invItemID];
3996 m_host.TaskInventory.LockItemsForRead(false);
3997
3998 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3881 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3999 && !m_automaticLinkPermission) 3882 && !m_automaticLinkPermission)
4000 { 3883 {
@@ -4049,18 +3932,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4049 public void llBreakLink(int linknum) 3932 public void llBreakLink(int linknum)
4050 { 3933 {
4051 m_host.AddScriptLPS(1); 3934 m_host.AddScriptLPS(1);
4052 UUID invItemID = InventorySelf();
4053 3935
4054 m_host.TaskInventory.LockItemsForRead(true); 3936 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4055 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3937 && !m_automaticLinkPermission)
4056 && !m_automaticLinkPermission) 3938 {
4057 { 3939 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
4058 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3940 return;
4059 m_host.TaskInventory.LockItemsForRead(false); 3941 }
4060 return; 3942
4061 }
4062 m_host.TaskInventory.LockItemsForRead(false);
4063
4064 if (linknum < ScriptBaseClass.LINK_THIS) 3943 if (linknum < ScriptBaseClass.LINK_THIS)
4065 return; 3944 return;
4066 3945
@@ -4159,12 +4038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4159 { 4038 {
4160 m_host.AddScriptLPS(1); 4039 m_host.AddScriptLPS(1);
4161 4040
4162 UUID invItemID = InventorySelf(); 4041 TaskInventoryItem item = GetSelfInventoryItem();
4163
4164 TaskInventoryItem item;
4165 m_host.TaskInventory.LockItemsForRead(true);
4166 item = m_host.TaskInventory[invItemID];
4167 m_host.TaskInventory.LockItemsForRead(false);
4168 4042
4169 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 4043 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4170 && !m_automaticLinkPermission) 4044 && !m_automaticLinkPermission)
@@ -5037,22 +4911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5037 4911
5038 public LSL_String llGetScriptName() 4912 public LSL_String llGetScriptName()
5039 { 4913 {
5040 string result = String.Empty;
5041
5042 m_host.AddScriptLPS(1); 4914 m_host.AddScriptLPS(1);
5043 4915
5044 m_host.TaskInventory.LockItemsForRead(true); 4916 TaskInventoryItem item = GetSelfInventoryItem();
5045 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
5046 {
5047 if (item.Type == 10 && item.ItemID == m_itemID)
5048 {
5049 result = item.Name!=null?item.Name:String.Empty;
5050 break;
5051 }
5052 }
5053 m_host.TaskInventory.LockItemsForRead(false);
5054 4917
5055 return result; 4918 return item.Name != null ? item.Name : String.Empty;
5056 } 4919 }
5057 4920
5058 public LSL_Integer llGetLinkNumberOfSides(int link) 4921 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -10437,22 +10300,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10437 public LSL_Vector llGetCameraPos() 10300 public LSL_Vector llGetCameraPos()
10438 { 10301 {
10439 m_host.AddScriptLPS(1); 10302 m_host.AddScriptLPS(1);
10440 UUID invItemID = InventorySelf();
10441 10303
10442 if (invItemID == UUID.Zero) 10304 TaskInventoryItem item = GetSelfInventoryItem();
10443 return new LSL_Vector();
10444 10305
10445 m_host.TaskInventory.LockItemsForRead(true); 10306 if (item.PermsGranter == UUID.Zero)
10446 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10307 return new LSL_Vector();
10447 {
10448 m_host.TaskInventory.LockItemsForRead(false);
10449 return new LSL_Vector();
10450 }
10451 10308
10452 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10309 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10453 { 10310 {
10454 ShoutError("No permissions to track the camera"); 10311 ShoutError("No permissions to track the camera");
10455 m_host.TaskInventory.LockItemsForRead(false);
10456 return new LSL_Vector(); 10312 return new LSL_Vector();
10457 } 10313 }
10458 m_host.TaskInventory.LockItemsForRead(false); 10314 m_host.TaskInventory.LockItemsForRead(false);
@@ -10469,20 +10325,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10469 public LSL_Rotation llGetCameraRot() 10325 public LSL_Rotation llGetCameraRot()
10470 { 10326 {
10471 m_host.AddScriptLPS(1); 10327 m_host.AddScriptLPS(1);
10472 UUID invItemID = InventorySelf();
10473 if (invItemID == UUID.Zero)
10474 return new LSL_Rotation();
10475 10328
10476 m_host.TaskInventory.LockItemsForRead(true); 10329 TaskInventoryItem item = GetSelfInventoryItem();
10477 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 10330
10478 { 10331 if (item.PermsGranter == UUID.Zero)
10479 m_host.TaskInventory.LockItemsForRead(false); 10332 return new LSL_Rotation();
10480 return new LSL_Rotation(); 10333
10481 } 10334 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10482 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10483 { 10335 {
10484 ShoutError("No permissions to track the camera"); 10336 ShoutError("No permissions to track the camera");
10485 m_host.TaskInventory.LockItemsForRead(false);
10486 return new LSL_Rotation(); 10337 return new LSL_Rotation();
10487 } 10338 }
10488 m_host.TaskInventory.LockItemsForRead(false); 10339 m_host.TaskInventory.LockItemsForRead(false);
@@ -10670,30 +10521,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10670 { 10521 {
10671 m_host.AddScriptLPS(1); 10522 m_host.AddScriptLPS(1);
10672 10523
10673 // our key in the object we are in
10674 UUID invItemID = InventorySelf();
10675 if (invItemID == UUID.Zero) return;
10676
10677 // the object we are in 10524 // the object we are in
10678 UUID objectID = m_host.ParentUUID; 10525 UUID objectID = m_host.ParentUUID;
10679 if (objectID == UUID.Zero) return; 10526 if (objectID == UUID.Zero)
10527 return;
10528
10529 TaskInventoryItem item = GetSelfInventoryItem();
10680 10530
10681 UUID agentID;
10682 m_host.TaskInventory.LockItemsForRead(true);
10683 // we need the permission first, to know which avatar we want to set the camera for 10531 // we need the permission first, to know which avatar we want to set the camera for
10684 agentID = m_host.TaskInventory[invItemID].PermsGranter; 10532 UUID agentID = item.PermsGranter;
10685 10533
10686 if (agentID == UUID.Zero) 10534 if (agentID == UUID.Zero)
10687 {
10688 m_host.TaskInventory.LockItemsForRead(false);
10689 return; 10535 return;
10690 } 10536
10691 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10537 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10692 {
10693 m_host.TaskInventory.LockItemsForRead(false);
10694 return; 10538 return;
10695 }
10696 m_host.TaskInventory.LockItemsForRead(false);
10697 10539
10698 ScenePresence presence = World.GetScenePresence(agentID); 10540 ScenePresence presence = World.GetScenePresence(agentID);
10699 10541
@@ -10735,34 +10577,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10735 { 10577 {
10736 m_host.AddScriptLPS(1); 10578 m_host.AddScriptLPS(1);
10737 10579
10738 // our key in the object we are in
10739 UUID invItemID=InventorySelf();
10740 if (invItemID == UUID.Zero) return;
10741
10742 // the object we are in 10580 // the object we are in
10743 UUID objectID = m_host.ParentUUID; 10581 UUID objectID = m_host.ParentUUID;
10744 if (objectID == UUID.Zero) return; 10582 if (objectID == UUID.Zero)
10583 return;
10584
10585 TaskInventoryItem item = GetSelfInventoryItem();
10745 10586
10746 // we need the permission first, to know which avatar we want to clear the camera for 10587 // we need the permission first, to know which avatar we want to clear the camera for
10747 UUID agentID; 10588 UUID agentID = item.PermsGranter;
10748 m_host.TaskInventory.LockItemsForRead(true); 10589
10749 agentID = m_host.TaskInventory[invItemID].PermsGranter;
10750 if (agentID == UUID.Zero) 10590 if (agentID == UUID.Zero)
10751 {
10752 m_host.TaskInventory.LockItemsForRead(false);
10753 return; 10591 return;
10754 } 10592
10755 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10593 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10756 {
10757 m_host.TaskInventory.LockItemsForRead(false);
10758 return; 10594 return;
10759 }
10760 m_host.TaskInventory.LockItemsForRead(false);
10761 10595
10762 ScenePresence presence = World.GetScenePresence(agentID); 10596 ScenePresence presence = World.GetScenePresence(agentID);
10763 10597
10764 // we are not interested in child-agents 10598 // we are not interested in child-agents
10765 if (presence.IsChildAgent) return; 10599 if (presence.IsChildAgent)
10600 return;
10766 10601
10767 presence.ControllingClient.SendClearFollowCamProperties(objectID); 10602 presence.ControllingClient.SendClearFollowCamProperties(objectID);
10768 } 10603 }
@@ -12231,8 +12066,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12231 12066
12232 try 12067 try
12233 { 12068 {
12234 UUID invItemID=InventorySelf(); 12069 TaskInventoryItem item = GetSelfInventoryItem();
12235 if (invItemID == UUID.Zero) 12070 if (item == null)
12236 { 12071 {
12237 replydata = "SERVICE_ERROR"; 12072 replydata = "SERVICE_ERROR";
12238 return; 12073 return;
@@ -12240,10 +12075,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12240 12075
12241 m_host.AddScriptLPS(1); 12076 m_host.AddScriptLPS(1);
12242 12077
12243 m_host.TaskInventory.LockItemsForRead(true);
12244 TaskInventoryItem item = m_host.TaskInventory[invItemID];
12245 m_host.TaskInventory.LockItemsForRead(false);
12246
12247 if (item.PermsGranter == UUID.Zero) 12078 if (item.PermsGranter == UUID.Zero)
12248 { 12079 {
12249 replydata = "MISSING_PERMISSION_DEBIT"; 12080 replydata = "MISSING_PERMISSION_DEBIT";
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 89e85a0..3f77f38 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -218,6 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
218 } 218 }
219 } 219 }
220 220
221 /// <summary>
222 /// Initialize the LSL interface.
223 /// </summary>
224 /// <remarks>
225 /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
226 /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
227 /// ScriptInstance.
228 /// </remarks>
221 private void InitLSL() 229 private void InitLSL()
222 { 230 {
223 if (m_LSL_Api != null) 231 if (m_LSL_Api != null)
@@ -1616,7 +1624,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1616 1624
1617 public Object osParseJSONNew(string JSON) 1625 public Object osParseJSONNew(string JSON)
1618 { 1626 {
1619 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1627 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1620 1628
1621 m_host.AddScriptLPS(1); 1629 m_host.AddScriptLPS(1);
1622 1630
@@ -3139,5 +3147,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3139 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); 3147 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3140 } 3148 }
3141 } 3149 }
3150
3151 public void osForceAttachToAvatar(int attachmentPoint)
3152 {
3153 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3154
3155 m_host.AddScriptLPS(1);
3156
3157 InitLSL();
3158 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3159 }
3160
3161 public void osForceDetachFromAvatar()
3162 {
3163 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3164
3165 m_host.AddScriptLPS(1);
3166
3167 InitLSL();
3168 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3169 }
3142 } 3170 }
3143} 3171}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2fcc443..fc77d05 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 98 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 99 void osAvatarStopAnimation(string avatar, string animation);
100 100
101 // Attachment commands
102
103 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
105 /// </summary>
106 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
107 void osForceAttachToAvatar(int attachment);
108
109 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks>
113 void osForceDetachFromAvatar();
114
101 //texture draw functions 115 //texture draw functions
102 string osMovePen(string drawList, int x, int y); 116 string osMovePen(string drawList, int x, int y);
103 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 117 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index b94b9bf..36ac0e3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions
292 293
293 //Texture Draw functions 294 public void osForceAttachToAvatar(int attachmentPoint)
295 {
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 }
298
299 public void osForceDetachFromAvatar()
300 {
301 m_OSSL_Functions.osForceDetachFromAvatar();
302 }
303
304 // Texture Draw functions
294 305
295 public string osMovePen(string drawList, int x, int y) 306 public string osMovePen(string drawList, int x, int y)
296 { 307 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index ff1f277..0f763f1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
964 public IScriptApi GetApi(string name) 964 public IScriptApi GetApi(string name)
965 { 965 {
966 if (m_Apis.ContainsKey(name)) 966 if (m_Apis.ContainsKey(name))
967 {
968// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName);
969
967 return m_Apis[name]; 970 return m_Apis[name];
971 }
972
973// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName);
974
968 return null; 975 return null;
969 } 976 }
970 977