aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs24
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs273
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs31
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs139
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs6
16 files changed, 346 insertions, 239 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 2365cfe..e88a623 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -484,6 +484,9 @@ namespace OpenSim.Region.Framework.Scenes
484 public delegate void SceneObjectPartUpdated(SceneObjectPart sop); 484 public delegate void SceneObjectPartUpdated(SceneObjectPart sop);
485 public event SceneObjectPartUpdated OnSceneObjectPartUpdated; 485 public event SceneObjectPartUpdated OnSceneObjectPartUpdated;
486 486
487 public delegate void ScenePresenceUpdated(ScenePresence sp);
488 public event ScenePresenceUpdated OnScenePresenceUpdated;
489
487 public delegate void RegionUp(GridRegion region); 490 public delegate void RegionUp(GridRegion region);
488 public event RegionUp OnRegionUp; 491 public event RegionUp OnRegionUp;
489 492
@@ -2367,6 +2370,27 @@ namespace OpenSim.Region.Framework.Scenes
2367 } 2370 }
2368 } 2371 }
2369 2372
2373 public void TriggerScenePresenceUpdated(ScenePresence sp)
2374 {
2375 ScenePresenceUpdated handler = OnScenePresenceUpdated;
2376 if (handler != null)
2377 {
2378 foreach (ScenePresenceUpdated d in handler.GetInvocationList())
2379 {
2380 try
2381 {
2382 d(sp);
2383 }
2384 catch (Exception e)
2385 {
2386 m_log.ErrorFormat(
2387 "[EVENT MANAGER]: Delegate for TriggerScenePresenceUpdated failed - continuing. {0} {1}",
2388 e.Message, e.StackTrace);
2389 }
2390 }
2391 }
2392 }
2393
2370 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, 2394 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args,
2371 int local_id, IClientAPI remote_client) 2395 int local_id, IClientAPI remote_client)
2372 { 2396 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index debb164..00f76e0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -102,8 +102,12 @@ namespace OpenSim.Region.Framework.Scenes
102 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); 102 protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
103 103
104 /// <summary> 104 /// <summary>
105 /// Lock to prevent object group update, linking and delinking operations from running concurrently. 105 /// Lock to prevent object group update, linking, delinking and duplication operations from running concurrently.
106 /// </summary> 106 /// </summary>
107 /// <remarks>
108 /// These operations rely on the parts composition of the object. If allowed to run concurrently then race
109 /// conditions can occur.
110 /// </remarks>
107 private Object m_updateLock = new Object(); 111 private Object m_updateLock = new Object();
108 112
109 #endregion 113 #endregion
@@ -2067,12 +2071,14 @@ namespace OpenSim.Region.Framework.Scenes
2067 /// <param name="AgentID"></param> 2071 /// <param name="AgentID"></param>
2068 /// <param name="GroupID"></param> 2072 /// <param name="GroupID"></param>
2069 /// <param name="rot"></param> 2073 /// <param name="rot"></param>
2074 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2075 /// <summary>
2070 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2076 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
2071 { 2077 {
2072// m_log.DebugFormat( 2078// m_log.DebugFormat(
2073// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2079// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
2074// originalPrimID, offset, AgentID); 2080// originalPrimID, offset, AgentID);
2075 2081
2076 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2082 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2077 if (original != null) 2083 if (original != null)
2078 { 2084 {
@@ -2102,25 +2108,25 @@ namespace OpenSim.Region.Framework.Scenes
2102 2108
2103 // FIXME: This section needs to be refactored so that it just calls AddSceneObject() 2109 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
2104 Entities.Add(copy); 2110 Entities.Add(copy);
2105 2111
2106 lock (SceneObjectGroupsByFullID) 2112 lock (SceneObjectGroupsByFullID)
2107 SceneObjectGroupsByFullID[copy.UUID] = copy; 2113 SceneObjectGroupsByFullID[copy.UUID] = copy;
2108 2114
2109 SceneObjectPart[] children = copy.Parts; 2115 SceneObjectPart[] children = copy.Parts;
2110 2116
2111 lock (SceneObjectGroupsByFullPartID) 2117 lock (SceneObjectGroupsByFullPartID)
2112 { 2118 {
2113 SceneObjectGroupsByFullPartID[copy.UUID] = copy; 2119 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
2114 foreach (SceneObjectPart part in children) 2120 foreach (SceneObjectPart part in children)
2115 SceneObjectGroupsByFullPartID[part.UUID] = copy; 2121 SceneObjectGroupsByFullPartID[part.UUID] = copy;
2116 } 2122 }
2117 2123
2118 lock (SceneObjectGroupsByLocalPartID) 2124 lock (SceneObjectGroupsByLocalPartID)
2119 { 2125 {
2120 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; 2126 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
2121 foreach (SceneObjectPart part in children) 2127 foreach (SceneObjectPart part in children)
2122 SceneObjectGroupsByLocalPartID[part.LocalId] = copy; 2128 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
2123 } 2129 }
2124 // PROBABLE END OF FIXME 2130 // PROBABLE END OF FIXME
2125 2131
2126 // Since we copy from a source group that is in selected 2132 // Since we copy from a source group that is in selected
@@ -2152,11 +2158,10 @@ namespace OpenSim.Region.Framework.Scenes
2152 { 2158 {
2153 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); 2159 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
2154 } 2160 }
2155 2161
2156 return null; 2162 return null;
2157 } 2163 }
2158 2164
2159 /// <summary>
2160 /// Calculates the distance between two Vector3s 2165 /// Calculates the distance between two Vector3s
2161 /// </summary> 2166 /// </summary>
2162 /// <param name="v1"></param> 2167 /// <param name="v1"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 843c426..82bba35 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3835,7 +3835,6 @@ namespace OpenSim.Region.Framework.Scenes
3835 hasProfileCut = hasDimple; // is it the same thing? 3835 hasProfileCut = hasDimple; // is it the same thing?
3836 } 3836 }
3837 3837
3838
3839 public void SetGroup(UUID groupID, IClientAPI client) 3838 public void SetGroup(UUID groupID, IClientAPI client)
3840 { 3839 {
3841 // Scene.AddNewPrims() calls with client == null so can't use this. 3840 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3865,10 +3864,12 @@ namespace OpenSim.Region.Framework.Scenes
3865 3864
3866 public void SetPhysicsAxisRotation() 3865 public void SetPhysicsAxisRotation()
3867 { 3866 {
3868 if (PhysActor != null) 3867 PhysicsActor pa = PhysActor;
3868
3869 if (pa != null)
3869 { 3870 {
3870 PhysActor.LockAngularMotion(RotationAxis); 3871 pa.LockAngularMotion(RotationAxis);
3871 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3872 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3872 } 3873 }
3873 } 3874 }
3874 3875
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5a6fb6c..99ad685 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -77,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes
77// { 77// {
78// m_log.Debug("[SCENE PRESENCE] Destructor called"); 78// m_log.Debug("[SCENE PRESENCE] Destructor called");
79// } 79// }
80 private void TriggerScenePresenceUpdated()
81 {
82 if (m_scene != null)
83 m_scene.EventManager.TriggerScenePresenceUpdated(this);
84 }
80 85
81 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 86 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
82 87
@@ -498,6 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
498 //m_log.DebugFormat( 503 //m_log.DebugFormat(
499 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 504 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
500 // Scene.RegionInfo.RegionName, Name, m_pos); 505 // Scene.RegionInfo.RegionName, Name, m_pos);
506 TriggerScenePresenceUpdated();
501 } 507 }
502 } 508 }
503 509
@@ -517,6 +523,7 @@ namespace OpenSim.Region.Framework.Scenes
517 return; 523 return;
518 524
519 m_pos = value; 525 m_pos = value;
526 TriggerScenePresenceUpdated();
520 } 527 }
521 } 528 }
522 529
@@ -1090,6 +1097,8 @@ namespace OpenSim.Region.Framework.Scenes
1090 1097
1091 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1098 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1092 { 1099 {
1100 if (ParentID != (uint)0)
1101 StandUp();
1093 bool isFlying = Flying; 1102 bool isFlying = Flying;
1094 Vector3 vel = Velocity; 1103 Vector3 vel = Velocity;
1095 RemoveFromPhysicalScene(); 1104 RemoveFromPhysicalScene();
@@ -1662,6 +1671,7 @@ namespace OpenSim.Region.Framework.Scenes
1662 } 1671 }
1663 1672
1664 m_scene.EventManager.TriggerOnClientMovement(this); 1673 m_scene.EventManager.TriggerOnClientMovement(this);
1674 TriggerScenePresenceUpdated();
1665 } 1675 }
1666 1676
1667 /// <summary> 1677 /// <summary>
@@ -2594,6 +2604,7 @@ namespace OpenSim.Region.Framework.Scenes
2594 2604
2595 m_scene.ForEachClient(SendTerseUpdateToClient); 2605 m_scene.ForEachClient(SendTerseUpdateToClient);
2596 } 2606 }
2607 TriggerScenePresenceUpdated();
2597 } 2608 }
2598 2609
2599 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2610 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -3379,6 +3390,7 @@ namespace OpenSim.Region.Framework.Scenes
3379 Velocity = force; 3390 Velocity = force;
3380 3391
3381 m_forceToApply = null; 3392 m_forceToApply = null;
3393 TriggerScenePresenceUpdated();
3382 } 3394 }
3383 } 3395 }
3384 3396
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs
index bb5bacc..2027ca6 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptApi.cs
@@ -27,17 +27,22 @@
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Framework;
30using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
31 32
32
33namespace OpenSim.Region.ScriptEngine.Interfaces 33namespace OpenSim.Region.ScriptEngine.Interfaces
34{ 34{
35 public interface IScriptApi 35 public interface IScriptApi
36 { 36 {
37 // 37 /// <summary>
38 // Each API has an identifier, which is used to load the 38 /// Initialize the API
39 // proper runtime assembly at load time. 39 /// </summary>
40 // 40 /// <remarks>
41 void Initialize(IScriptEngine engine, SceneObjectPart part, uint localID, UUID item); 41 /// Each API has an identifier, which is used to load the
42 /// proper runtime assembly at load time.
43 /// <param name='engine'>/param>
44 /// <param name='part'></param>
45 /// <param name='item'></param>
46 void Initialize(IScriptEngine engine, SceneObjectPart part, TaskInventoryItem item);
42 } 47 }
43} 48} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 489c1c6..b5fa6de 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -59,16 +59,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
59 { 59 {
60 internal IScriptEngine m_ScriptEngine; 60 internal IScriptEngine m_ScriptEngine;
61 internal SceneObjectPart m_host; 61 internal SceneObjectPart m_host;
62 internal uint m_localID; 62 internal TaskInventoryItem m_item;
63 internal UUID m_itemID;
64 internal bool m_CMFunctionsEnabled = false; 63 internal bool m_CMFunctionsEnabled = false;
65 64
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
67 { 66 {
68 m_ScriptEngine = ScriptEngine; 67 m_ScriptEngine = ScriptEngine;
69 m_host = host; 68 m_host = host;
70 m_localID = localID; 69 m_item = item;
71 m_itemID = itemID;
72 70
73 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) 71 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
74 m_CMFunctionsEnabled = true; 72 m_CMFunctionsEnabled = true;
@@ -95,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
95 public string cmDetectedCountry(int number) 93 public string cmDetectedCountry(int number)
96 { 94 {
97 m_host.AddScriptLPS(1); 95 m_host.AddScriptLPS(1);
98 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 96 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
99 if (detectedParams == null) 97 if (detectedParams == null)
100 return String.Empty; 98 return String.Empty;
101 return detectedParams.Country; 99 return detectedParams.Country;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9208034..ca14399 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -88,12 +88,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
88 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 88 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
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;
92 91
93 /// <summary> 92 /// <summary>
94 /// The UUID of the item that hosts this script 93 /// The item that hosts this script
95 /// </summary> 94 /// </summary>
96 protected UUID m_itemID; 95 protected TaskInventoryItem m_item;
97 96
98 protected bool throwErrorOnNotImplemented = true; 97 protected bool throwErrorOnNotImplemented = true;
99 protected AsyncCommandManager AsyncCommands = null; 98 protected AsyncCommandManager AsyncCommands = null;
@@ -116,7 +115,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
116 protected Timer m_ShoutSayTimer; 115 protected Timer m_ShoutSayTimer;
117 protected int m_SayShoutCount = 0; 116 protected int m_SayShoutCount = 0;
118 117
119 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 118 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
120 { 119 {
121 m_ShoutSayTimer = new Timer(1000); 120 m_ShoutSayTimer = new Timer(1000);
122 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; 121 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed;
@@ -125,8 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
125 124
126 m_ScriptEngine = ScriptEngine; 125 m_ScriptEngine = ScriptEngine;
127 m_host = host; 126 m_host = host;
128 m_localID = localID; 127 m_item = item;
129 m_itemID = itemID;
130 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 128 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
131 129
132 m_ScriptDelayFactor = 130 m_ScriptDelayFactor =
@@ -178,7 +176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
178 [DebuggerNonUserCode] 176 [DebuggerNonUserCode]
179 public void state(string newState) 177 public void state(string newState)
180 { 178 {
181 m_ScriptEngine.SetState(m_itemID, newState); 179 m_ScriptEngine.SetState(m_item.ItemID, newState);
182 } 180 }
183 181
184 /// <summary> 182 /// <summary>
@@ -189,7 +187,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
189 public void llResetScript() 187 public void llResetScript()
190 { 188 {
191 m_host.AddScriptLPS(1); 189 m_host.AddScriptLPS(1);
192 m_ScriptEngine.ApiResetScript(m_itemID); 190 m_ScriptEngine.ApiResetScript(m_item.ItemID);
193 } 191 }
194 192
195 public void llResetOtherScript(string name) 193 public void llResetOtherScript(string name)
@@ -341,35 +339,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
341 } 339 }
342 } 340 }
343 341
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()
353 {
354 TaskInventoryItem invItem = null;
355
356 bool unlock = false;
357 if (!m_host.TaskInventory.IsReadLockedByMe())
358 {
359 m_host.TaskInventory.LockItemsForRead(true);
360 unlock = true;
361 }
362
363 invItem = m_host.TaskInventory[m_itemID];
364
365 if (unlock)
366 {
367 m_host.TaskInventory.LockItemsForRead(false);
368 }
369
370 return invItem;
371 }
372
373 protected UUID InventoryKey(string name, int type) 342 protected UUID InventoryKey(string name, int type)
374 { 343 {
375 m_host.AddScriptLPS(1); 344 m_host.AddScriptLPS(1);
@@ -976,7 +945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
976 UUID.TryParse(ID, out keyID); 945 UUID.TryParse(ID, out keyID);
977 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 946 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
978 if (wComm != null) 947 if (wComm != null)
979 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg); 948 return wComm.Listen(m_host.LocalId, m_item.ItemID, m_host.UUID, channelID, name, keyID, msg);
980 else 949 else
981 return -1; 950 return -1;
982 } 951 }
@@ -986,7 +955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
986 m_host.AddScriptLPS(1); 955 m_host.AddScriptLPS(1);
987 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 956 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
988 if (wComm != null) 957 if (wComm != null)
989 wComm.ListenControl(m_itemID, number, active); 958 wComm.ListenControl(m_item.ItemID, number, active);
990 } 959 }
991 960
992 public void llListenRemove(int number) 961 public void llListenRemove(int number)
@@ -994,7 +963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
994 m_host.AddScriptLPS(1); 963 m_host.AddScriptLPS(1);
995 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 964 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
996 if (wComm != null) 965 if (wComm != null)
997 wComm.ListenRemove(m_itemID, number); 966 wComm.ListenRemove(m_item.ItemID, number);
998 } 967 }
999 968
1000 public void llSensor(string name, string id, int type, double range, double arc) 969 public void llSensor(string name, string id, int type, double range, double arc)
@@ -1003,7 +972,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1003 UUID keyID = UUID.Zero; 972 UUID keyID = UUID.Zero;
1004 UUID.TryParse(id, out keyID); 973 UUID.TryParse(id, out keyID);
1005 974
1006 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host); 975 AsyncCommands.SensorRepeatPlugin.SenseOnce(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, m_host);
1007 } 976 }
1008 977
1009 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) 978 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
@@ -1012,13 +981,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1012 UUID keyID = UUID.Zero; 981 UUID keyID = UUID.Zero;
1013 UUID.TryParse(id, out keyID); 982 UUID.TryParse(id, out keyID);
1014 983
1015 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 984 AsyncCommands.SensorRepeatPlugin.SetSenseRepeatEvent(m_host.LocalId, m_item.ItemID, name, keyID, type, range, arc, rate, m_host);
1016 } 985 }
1017 986
1018 public void llSensorRemove() 987 public void llSensorRemove()
1019 { 988 {
1020 m_host.AddScriptLPS(1); 989 m_host.AddScriptLPS(1);
1021 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_localID, m_itemID); 990 AsyncCommands.SensorRepeatPlugin.UnSetSenseRepeaterEvents(m_host.LocalId, m_item.ItemID);
1022 } 991 }
1023 992
1024 public string resolveName(UUID objecUUID) 993 public string resolveName(UUID objecUUID)
@@ -1059,7 +1028,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1059 public LSL_String llDetectedName(int number) 1028 public LSL_String llDetectedName(int number)
1060 { 1029 {
1061 m_host.AddScriptLPS(1); 1030 m_host.AddScriptLPS(1);
1062 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1031 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1063 if (detectedParams == null) 1032 if (detectedParams == null)
1064 return String.Empty; 1033 return String.Empty;
1065 return detectedParams.Name; 1034 return detectedParams.Name;
@@ -1068,7 +1037,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1068 public LSL_String llDetectedKey(int number) 1037 public LSL_String llDetectedKey(int number)
1069 { 1038 {
1070 m_host.AddScriptLPS(1); 1039 m_host.AddScriptLPS(1);
1071 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1040 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1072 if (detectedParams == null) 1041 if (detectedParams == null)
1073 return String.Empty; 1042 return String.Empty;
1074 return detectedParams.Key.ToString(); 1043 return detectedParams.Key.ToString();
@@ -1077,7 +1046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1077 public LSL_String llDetectedOwner(int number) 1046 public LSL_String llDetectedOwner(int number)
1078 { 1047 {
1079 m_host.AddScriptLPS(1); 1048 m_host.AddScriptLPS(1);
1080 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1049 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1081 if (detectedParams == null) 1050 if (detectedParams == null)
1082 return String.Empty; 1051 return String.Empty;
1083 return detectedParams.Owner.ToString(); 1052 return detectedParams.Owner.ToString();
@@ -1086,7 +1055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1086 public LSL_Integer llDetectedType(int number) 1055 public LSL_Integer llDetectedType(int number)
1087 { 1056 {
1088 m_host.AddScriptLPS(1); 1057 m_host.AddScriptLPS(1);
1089 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1058 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1090 if (detectedParams == null) 1059 if (detectedParams == null)
1091 return 0; 1060 return 0;
1092 return new LSL_Integer(detectedParams.Type); 1061 return new LSL_Integer(detectedParams.Type);
@@ -1095,7 +1064,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1095 public LSL_Vector llDetectedPos(int number) 1064 public LSL_Vector llDetectedPos(int number)
1096 { 1065 {
1097 m_host.AddScriptLPS(1); 1066 m_host.AddScriptLPS(1);
1098 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1067 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1099 if (detectedParams == null) 1068 if (detectedParams == null)
1100 return new LSL_Vector(); 1069 return new LSL_Vector();
1101 return detectedParams.Position; 1070 return detectedParams.Position;
@@ -1104,7 +1073,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1104 public LSL_Vector llDetectedVel(int number) 1073 public LSL_Vector llDetectedVel(int number)
1105 { 1074 {
1106 m_host.AddScriptLPS(1); 1075 m_host.AddScriptLPS(1);
1107 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1076 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1108 if (detectedParams == null) 1077 if (detectedParams == null)
1109 return new LSL_Vector(); 1078 return new LSL_Vector();
1110 return detectedParams.Velocity; 1079 return detectedParams.Velocity;
@@ -1113,7 +1082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1113 public LSL_Vector llDetectedGrab(int number) 1082 public LSL_Vector llDetectedGrab(int number)
1114 { 1083 {
1115 m_host.AddScriptLPS(1); 1084 m_host.AddScriptLPS(1);
1116 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1085 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1117 if (parms == null) 1086 if (parms == null)
1118 return new LSL_Vector(0, 0, 0); 1087 return new LSL_Vector(0, 0, 0);
1119 1088
@@ -1123,7 +1092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1123 public LSL_Rotation llDetectedRot(int number) 1092 public LSL_Rotation llDetectedRot(int number)
1124 { 1093 {
1125 m_host.AddScriptLPS(1); 1094 m_host.AddScriptLPS(1);
1126 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1095 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1127 if (detectedParams == null) 1096 if (detectedParams == null)
1128 return new LSL_Rotation(); 1097 return new LSL_Rotation();
1129 return detectedParams.Rotation; 1098 return detectedParams.Rotation;
@@ -1132,7 +1101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1132 public LSL_Integer llDetectedGroup(int number) 1101 public LSL_Integer llDetectedGroup(int number)
1133 { 1102 {
1134 m_host.AddScriptLPS(1); 1103 m_host.AddScriptLPS(1);
1135 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, number); 1104 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1136 if (detectedParams == null) 1105 if (detectedParams == null)
1137 return new LSL_Integer(0); 1106 return new LSL_Integer(0);
1138 if (m_host.GroupID == detectedParams.Group) 1107 if (m_host.GroupID == detectedParams.Group)
@@ -1143,7 +1112,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1143 public LSL_Integer llDetectedLinkNumber(int number) 1112 public LSL_Integer llDetectedLinkNumber(int number)
1144 { 1113 {
1145 m_host.AddScriptLPS(1); 1114 m_host.AddScriptLPS(1);
1146 DetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 1115 DetectParams parms = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);
1147 if (parms == null) 1116 if (parms == null)
1148 return new LSL_Integer(0); 1117 return new LSL_Integer(0);
1149 1118
@@ -1156,7 +1125,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1156 public LSL_Vector llDetectedTouchBinormal(int index) 1125 public LSL_Vector llDetectedTouchBinormal(int index)
1157 { 1126 {
1158 m_host.AddScriptLPS(1); 1127 m_host.AddScriptLPS(1);
1159 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1128 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1160 if (detectedParams == null) 1129 if (detectedParams == null)
1161 return new LSL_Vector(); 1130 return new LSL_Vector();
1162 return detectedParams.TouchBinormal; 1131 return detectedParams.TouchBinormal;
@@ -1168,7 +1137,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1168 public LSL_Integer llDetectedTouchFace(int index) 1137 public LSL_Integer llDetectedTouchFace(int index)
1169 { 1138 {
1170 m_host.AddScriptLPS(1); 1139 m_host.AddScriptLPS(1);
1171 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1140 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1172 if (detectedParams == null) 1141 if (detectedParams == null)
1173 return new LSL_Integer(-1); 1142 return new LSL_Integer(-1);
1174 return new LSL_Integer(detectedParams.TouchFace); 1143 return new LSL_Integer(detectedParams.TouchFace);
@@ -1180,7 +1149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1180 public LSL_Vector llDetectedTouchNormal(int index) 1149 public LSL_Vector llDetectedTouchNormal(int index)
1181 { 1150 {
1182 m_host.AddScriptLPS(1); 1151 m_host.AddScriptLPS(1);
1183 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1152 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1184 if (detectedParams == null) 1153 if (detectedParams == null)
1185 return new LSL_Vector(); 1154 return new LSL_Vector();
1186 return detectedParams.TouchNormal; 1155 return detectedParams.TouchNormal;
@@ -1192,7 +1161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1192 public LSL_Vector llDetectedTouchPos(int index) 1161 public LSL_Vector llDetectedTouchPos(int index)
1193 { 1162 {
1194 m_host.AddScriptLPS(1); 1163 m_host.AddScriptLPS(1);
1195 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1164 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1196 if (detectedParams == null) 1165 if (detectedParams == null)
1197 return new LSL_Vector(); 1166 return new LSL_Vector();
1198 return detectedParams.TouchPos; 1167 return detectedParams.TouchPos;
@@ -1204,7 +1173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1204 public LSL_Vector llDetectedTouchST(int index) 1173 public LSL_Vector llDetectedTouchST(int index)
1205 { 1174 {
1206 m_host.AddScriptLPS(1); 1175 m_host.AddScriptLPS(1);
1207 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1176 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1208 if (detectedParams == null) 1177 if (detectedParams == null)
1209 return new LSL_Vector(-1.0, -1.0, 0.0); 1178 return new LSL_Vector(-1.0, -1.0, 0.0);
1210 return detectedParams.TouchST; 1179 return detectedParams.TouchST;
@@ -1216,7 +1185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1216 public LSL_Vector llDetectedTouchUV(int index) 1185 public LSL_Vector llDetectedTouchUV(int index)
1217 { 1186 {
1218 m_host.AddScriptLPS(1); 1187 m_host.AddScriptLPS(1);
1219 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index); 1188 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, index);
1220 if (detectedParams == null) 1189 if (detectedParams == null)
1221 return new LSL_Vector(-1.0, -1.0, 0.0); 1190 return new LSL_Vector(-1.0, -1.0, 0.0);
1222 return detectedParams.TouchUV; 1191 return detectedParams.TouchUV;
@@ -2963,12 +2932,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2963 { 2932 {
2964 m_host.AddScriptLPS(1); 2933 m_host.AddScriptLPS(1);
2965 2934
2966 TaskInventoryItem item = GetSelfInventoryItem(); 2935 if (m_item.PermsGranter == UUID.Zero)
2967
2968 if (item.PermsGranter == UUID.Zero)
2969 return 0; 2936 return 0;
2970 2937
2971 if ((item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0) 2938 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
2972 { 2939 {
2973 LSLError("No permissions to give money"); 2940 LSLError("No permissions to give money");
2974 return 0; 2941 return 0;
@@ -3155,7 +3122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3155 sec = m_MinTimerInterval; 3122 sec = m_MinTimerInterval;
3156 m_host.AddScriptLPS(1); 3123 m_host.AddScriptLPS(1);
3157 // Setting timer repeat 3124 // Setting timer repeat
3158 AsyncCommands.TimerPlugin.SetTimerEvent(m_localID, m_itemID, sec); 3125 AsyncCommands.TimerPlugin.SetTimerEvent(m_host.LocalId, m_item.ItemID, sec);
3159 } 3126 }
3160 3127
3161 public virtual void llSleep(double sec) 3128 public virtual void llSleep(double sec)
@@ -3217,17 +3184,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3217 3184
3218 public void llTakeControls(int controls, int accept, int pass_on) 3185 public void llTakeControls(int controls, int accept, int pass_on)
3219 { 3186 {
3220 TaskInventoryItem item = GetSelfInventoryItem(); 3187 if (m_item.PermsGranter != UUID.Zero)
3221
3222 if (item.PermsGranter != UUID.Zero)
3223 { 3188 {
3224 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3189 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3225 3190
3226 if (presence != null) 3191 if (presence != null)
3227 { 3192 {
3228 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3193 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3229 { 3194 {
3230 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID); 3195 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_host.LocalId, m_item.ItemID);
3231 } 3196 }
3232 } 3197 }
3233 } 3198 }
@@ -3239,20 +3204,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3239 { 3204 {
3240 m_host.AddScriptLPS(1); 3205 m_host.AddScriptLPS(1);
3241 3206
3242 TaskInventoryItem item = GetSelfInventoryItem(); 3207 if (m_item.PermsGranter != UUID.Zero)
3243
3244 if (item.PermsGranter != UUID.Zero)
3245 { 3208 {
3246 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3209 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3247 3210
3248 if (presence != null) 3211 if (presence != null)
3249 { 3212 {
3250 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) 3213 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
3251 { 3214 {
3252 // Unregister controls from Presence 3215 // Unregister controls from Presence
3253 presence.UnRegisterControlEventsToScript(m_localID, m_itemID); 3216 presence.UnRegisterControlEventsToScript(m_host.LocalId, m_item.ItemID);
3254 // Remove Take Control permission. 3217 // Remove Take Control permission.
3255 item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS; 3218 m_item.PermsMask &= ~ScriptBaseClass.PERMISSION_TAKE_CONTROLS;
3256 } 3219 }
3257 } 3220 }
3258 } 3221 }
@@ -3311,14 +3274,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3311 { 3274 {
3312 m_host.AddScriptLPS(1); 3275 m_host.AddScriptLPS(1);
3313 3276
3314 TaskInventoryItem item = GetSelfInventoryItem(); 3277 if (m_item.PermsGranter != m_host.OwnerID)
3315
3316 m_host.TaskInventory.LockItemsForRead(false);
3317
3318 if (item.PermsGranter != m_host.OwnerID)
3319 return; 3278 return;
3320 3279
3321 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3280 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3322 AttachToAvatar(attachmentPoint); 3281 AttachToAvatar(attachmentPoint);
3323 } 3282 }
3324 3283
@@ -3329,12 +3288,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3329 if (m_host.ParentGroup.AttachmentPoint == 0) 3288 if (m_host.ParentGroup.AttachmentPoint == 0)
3330 return; 3289 return;
3331 3290
3332 TaskInventoryItem item = GetSelfInventoryItem(); 3291 if (m_item.PermsGranter != m_host.OwnerID)
3333
3334 if (item.PermsGranter != m_host.OwnerID)
3335 return; 3292 return;
3336 3293
3337 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3294 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3338 DetachFromAvatar(); 3295 DetachFromAvatar();
3339 } 3296 }
3340 3297
@@ -3545,7 +3502,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3545 m_host.AddScriptLPS(1); 3502 m_host.AddScriptLPS(1);
3546 try 3503 try
3547 { 3504 {
3548 m_ScriptEngine.SetMinEventDelay(m_itemID, delay); 3505 m_ScriptEngine.SetMinEventDelay(m_item.ItemID, delay);
3549 } 3506 }
3550 catch (NotImplementedException) 3507 catch (NotImplementedException)
3551 { 3508 {
@@ -3598,14 +3555,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3598 { 3555 {
3599 m_host.AddScriptLPS(1); 3556 m_host.AddScriptLPS(1);
3600 3557
3601 TaskInventoryItem item = GetSelfInventoryItem(); 3558 if (m_item.PermsGranter == UUID.Zero)
3602
3603 if (item.PermsGranter == UUID.Zero)
3604 return; 3559 return;
3605 3560
3606 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3561 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3607 { 3562 {
3608 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3563 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3609 3564
3610 if (presence != null) 3565 if (presence != null)
3611 { 3566 {
@@ -3623,21 +3578,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3623 { 3578 {
3624 m_host.AddScriptLPS(1); 3579 m_host.AddScriptLPS(1);
3625 3580
3626 TaskInventoryItem item = GetSelfInventoryItem(); 3581 if (m_item.PermsGranter == UUID.Zero)
3627
3628 if (item.PermsGranter == UUID.Zero)
3629 return; 3582 return;
3630 3583
3631 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) 3584 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
3632 { 3585 {
3633 UUID animID = new UUID(); 3586 UUID animID = new UUID();
3634 3587
3635 if (!UUID.TryParse(anim, out animID)) 3588 if (!UUID.TryParse(anim, out animID))
3636 { 3589 {
3637 animID=InventoryKey(anim); 3590 animID = InventoryKey(anim);
3638 } 3591 }
3639 3592
3640 ScenePresence presence = World.GetScenePresence(item.PermsGranter); 3593 ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
3641 3594
3642 if (presence != null) 3595 if (presence != null)
3643 { 3596 {
@@ -3673,7 +3626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3673 public LSL_Integer llGetStartParameter() 3626 public LSL_Integer llGetStartParameter()
3674 { 3627 {
3675 m_host.AddScriptLPS(1); 3628 m_host.AddScriptLPS(1);
3676 return m_ScriptEngine.GetStartParameter(m_itemID); 3629 return m_ScriptEngine.GetStartParameter(m_item.ItemID);
3677 } 3630 }
3678 3631
3679 public void llRequestPermissions(string agent, int perm) 3632 public void llRequestPermissions(string agent, int perm)
@@ -3683,16 +3636,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3683 if (!UUID.TryParse(agent, out agentID)) 3636 if (!UUID.TryParse(agent, out agentID))
3684 return; 3637 return;
3685 3638
3686 TaskInventoryItem item = GetSelfInventoryItem();
3687
3688 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3639 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3689 { 3640 {
3690 llReleaseControls(); 3641 llReleaseControls();
3691 3642
3692 item.PermsGranter = UUID.Zero; 3643 m_item.PermsGranter = UUID.Zero;
3693 item.PermsMask = 0; 3644 m_item.PermsMask = 0;
3694 3645
3695 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3646 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3696 "run_time_permissions", new Object[] { 3647 "run_time_permissions", new Object[] {
3697 new LSL_Integer(0) }, 3648 new LSL_Integer(0) },
3698 new DetectParams[0])); 3649 new DetectParams[0]));
@@ -3700,7 +3651,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3700 return; 3651 return;
3701 } 3652 }
3702 3653
3703 if (item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3654 if (m_item.PermsGranter != agentID || (perm & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3704 llReleaseControls(); 3655 llReleaseControls();
3705 3656
3706 m_host.AddScriptLPS(1); 3657 m_host.AddScriptLPS(1);
@@ -3717,11 +3668,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3717 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3668 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3718 { 3669 {
3719 m_host.TaskInventory.LockItemsForWrite(true); 3670 m_host.TaskInventory.LockItemsForWrite(true);
3720 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3671 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3721 m_host.TaskInventory[m_itemID].PermsMask = perm; 3672 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3722 m_host.TaskInventory.LockItemsForWrite(false); 3673 m_host.TaskInventory.LockItemsForWrite(false);
3723 3674
3724 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3675 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3725 "run_time_permissions", new Object[] { 3676 "run_time_permissions", new Object[] {
3726 new LSL_Integer(perm) }, 3677 new LSL_Integer(perm) },
3727 new DetectParams[0])); 3678 new DetectParams[0]));
@@ -3756,11 +3707,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3756 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3707 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3757 { 3708 {
3758 m_host.TaskInventory.LockItemsForWrite(true); 3709 m_host.TaskInventory.LockItemsForWrite(true);
3759 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3710 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3760 m_host.TaskInventory[m_itemID].PermsMask = perm; 3711 m_host.TaskInventory[m_item.ItemID].PermsMask = perm;
3761 m_host.TaskInventory.LockItemsForWrite(false); 3712 m_host.TaskInventory.LockItemsForWrite(false);
3762 3713
3763 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3714 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3764 "run_time_permissions", new Object[] { 3715 "run_time_permissions", new Object[] {
3765 new LSL_Integer(perm) }, 3716 new LSL_Integer(perm) },
3766 new DetectParams[0])); 3717 new DetectParams[0]));
@@ -3781,8 +3732,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3781 if (!m_waitingForScriptAnswer) 3732 if (!m_waitingForScriptAnswer)
3782 { 3733 {
3783 m_host.TaskInventory.LockItemsForWrite(true); 3734 m_host.TaskInventory.LockItemsForWrite(true);
3784 m_host.TaskInventory[m_itemID].PermsGranter = agentID; 3735 m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID;
3785 m_host.TaskInventory[m_itemID].PermsMask = 0; 3736 m_host.TaskInventory[m_item.ItemID].PermsMask = 0;
3786 m_host.TaskInventory.LockItemsForWrite(false); 3737 m_host.TaskInventory.LockItemsForWrite(false);
3787 3738
3788 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3739 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@@ -3790,13 +3741,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3790 } 3741 }
3791 3742
3792 presence.ControllingClient.SendScriptQuestion( 3743 presence.ControllingClient.SendScriptQuestion(
3793 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); 3744 m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_item.ItemID, perm);
3794 3745
3795 return; 3746 return;
3796 } 3747 }
3797 3748
3798 // Requested agent is not in range, refuse perms 3749 // Requested agent is not in range, refuse perms
3799 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3750 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3800 "run_time_permissions", new Object[] { 3751 "run_time_permissions", new Object[] {
3801 new LSL_Integer(0) }, 3752 new LSL_Integer(0) },
3802 new DetectParams[0])); 3753 new DetectParams[0]));
@@ -3814,10 +3765,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3814 llReleaseControls(); 3765 llReleaseControls();
3815 3766
3816 m_host.TaskInventory.LockItemsForWrite(true); 3767 m_host.TaskInventory.LockItemsForWrite(true);
3817 m_host.TaskInventory[m_itemID].PermsMask = answer; 3768 m_host.TaskInventory[m_item.ItemID].PermsMask = answer;
3818 m_host.TaskInventory.LockItemsForWrite(false); 3769 m_host.TaskInventory.LockItemsForWrite(false);
3819 3770
3820 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3771 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
3821 "run_time_permissions", new Object[] { 3772 "run_time_permissions", new Object[] {
3822 new LSL_Integer(answer) }, 3773 new LSL_Integer(answer) },
3823 new DetectParams[0])); 3774 new DetectParams[0]));
@@ -3827,14 +3778,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3827 { 3778 {
3828 m_host.AddScriptLPS(1); 3779 m_host.AddScriptLPS(1);
3829 3780
3830 return GetSelfInventoryItem().PermsGranter.ToString(); 3781 return m_item.PermsGranter.ToString();
3831 } 3782 }
3832 3783
3833 public LSL_Integer llGetPermissions() 3784 public LSL_Integer llGetPermissions()
3834 { 3785 {
3835 m_host.AddScriptLPS(1); 3786 m_host.AddScriptLPS(1);
3836 3787
3837 int perms = GetSelfInventoryItem().PermsMask; 3788 int perms = m_item.PermsMask;
3838 3789
3839 if (m_automaticLinkPermission) 3790 if (m_automaticLinkPermission)
3840 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3791 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
@@ -3883,9 +3834,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3883 if (!UUID.TryParse(target, out targetID)) 3834 if (!UUID.TryParse(target, out targetID))
3884 return; 3835 return;
3885 3836
3886 TaskInventoryItem item = GetSelfInventoryItem(); 3837 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3887
3888 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3889 && !m_automaticLinkPermission) 3838 && !m_automaticLinkPermission)
3890 { 3839 {
3891 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3840 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -3893,7 +3842,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3893 } 3842 }
3894 3843
3895 IClientAPI client = null; 3844 IClientAPI client = null;
3896 ScenePresence sp = World.GetScenePresence(item.PermsGranter); 3845 ScenePresence sp = World.GetScenePresence(m_item.PermsGranter);
3897 if (sp != null) 3846 if (sp != null)
3898 client = sp.ControllingClient; 3847 client = sp.ControllingClient;
3899 3848
@@ -3940,7 +3889,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3940 { 3889 {
3941 m_host.AddScriptLPS(1); 3890 m_host.AddScriptLPS(1);
3942 3891
3943 if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3892 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3944 && !m_automaticLinkPermission) 3893 && !m_automaticLinkPermission)
3945 { 3894 {
3946 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3895 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
@@ -4045,7 +3994,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4045 { 3994 {
4046 m_host.AddScriptLPS(1); 3995 m_host.AddScriptLPS(1);
4047 3996
4048 TaskInventoryItem item = GetSelfInventoryItem(); 3997 TaskInventoryItem item = m_item;
4049 3998
4050 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3999 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
4051 && !m_automaticLinkPermission) 4000 && !m_automaticLinkPermission)
@@ -4356,7 +4305,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4356 { 4305 {
4357 if (item.Name == name) 4306 if (item.Name == name)
4358 { 4307 {
4359 if (item.ItemID == m_itemID) 4308 if (item.ItemID == m_item.ItemID)
4360 throw new ScriptDeleteException(); 4309 throw new ScriptDeleteException();
4361 else 4310 else
4362 m_host.Inventory.RemoveInventoryItem(item.ItemID); 4311 m_host.Inventory.RemoveInventoryItem(item.ItemID);
@@ -4490,8 +4439,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4490 UUID rq = UUID.Random(); 4439 UUID rq = UUID.Random();
4491 4440
4492 UUID tid = AsyncCommands. 4441 UUID tid = AsyncCommands.
4493 DataserverPlugin.RegisterRequest(m_localID, 4442 DataserverPlugin.RegisterRequest(m_host.LocalId,
4494 m_itemID, rq.ToString()); 4443 m_item.ItemID, rq.ToString());
4495 4444
4496 AsyncCommands. 4445 AsyncCommands.
4497 DataserverPlugin.DataserverReply(rq.ToString(), reply); 4446 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -4518,8 +4467,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4518 if (item.Type == 3 && item.Name == name) 4467 if (item.Type == 3 && item.Name == name)
4519 { 4468 {
4520 UUID tid = AsyncCommands. 4469 UUID tid = AsyncCommands.
4521 DataserverPlugin.RegisterRequest(m_localID, 4470 DataserverPlugin.RegisterRequest(m_host.LocalId,
4522 m_itemID, item.AssetID.ToString()); 4471 m_item.ItemID, item.AssetID.ToString());
4523 4472
4524 Vector3 region = new Vector3( 4473 Vector3 region = new Vector3(
4525 World.RegionInfo.RegionLocX * Constants.RegionSize, 4474 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -4920,9 +4869,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4920 { 4869 {
4921 m_host.AddScriptLPS(1); 4870 m_host.AddScriptLPS(1);
4922 4871
4923 TaskInventoryItem item = GetSelfInventoryItem(); 4872 return m_item.Name != null ? m_item.Name : String.Empty;
4924
4925 return item.Name != null ? item.Name : String.Empty;
4926 } 4873 }
4927 4874
4928 public LSL_Integer llGetLinkNumberOfSides(int link) 4875 public LSL_Integer llGetLinkNumberOfSides(int link)
@@ -7069,14 +7016,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7069 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7016 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7070 if (xmlrpcMod.IsEnabled()) 7017 if (xmlrpcMod.IsEnabled())
7071 { 7018 {
7072 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, UUID.Zero); 7019 UUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_host.LocalId, m_item.ItemID, UUID.Zero);
7073 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>(); 7020 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
7074 if (xmlRpcRouter != null) 7021 if (xmlRpcRouter != null)
7075 { 7022 {
7076 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName; 7023 string ExternalHostName = m_ScriptEngine.World.RegionInfo.ExternalHostName;
7077 7024
7078 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID, 7025 xmlRpcRouter.RegisterNewReceiver(m_ScriptEngine.ScriptModule, channelID, m_host.UUID,
7079 m_itemID, String.Format("http://{0}:{1}/", ExternalHostName, 7026 m_item.ItemID, String.Format("http://{0}:{1}/", ExternalHostName,
7080 xmlrpcMod.Port.ToString())); 7027 xmlrpcMod.Port.ToString()));
7081 } 7028 }
7082 object[] resobj = new object[] 7029 object[] resobj = new object[]
@@ -7088,7 +7035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7088 new LSL_Integer(0), 7035 new LSL_Integer(0),
7089 new LSL_String(String.Empty) 7036 new LSL_String(String.Empty)
7090 }; 7037 };
7091 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams("remote_data", resobj, 7038 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams("remote_data", resobj,
7092 new DetectParams[0])); 7039 new DetectParams[0]));
7093 } 7040 }
7094 ScriptSleep(1000); 7041 ScriptSleep(1000);
@@ -7099,7 +7046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7099 m_host.AddScriptLPS(1); 7046 m_host.AddScriptLPS(1);
7100 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7047 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7101 ScriptSleep(3000); 7048 ScriptSleep(3000);
7102 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString(); 7049 return (xmlrpcMod.SendRemoteData(m_host.LocalId, m_item.ItemID, channel, dest, idata, sdata)).ToString();
7103 } 7050 }
7104 7051
7105 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) 7052 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
@@ -9742,13 +9689,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9742 { 9689 {
9743 m_host.AddScriptLPS(1); 9690 m_host.AddScriptLPS(1);
9744 if (m_UrlModule != null) 9691 if (m_UrlModule != null)
9745 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9692 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
9746 return UUID.Zero.ToString(); 9693 return UUID.Zero.ToString();
9747 } 9694 }
9748 9695
9749 public LSL_String llRequestSimulatorData(string simulator, int data) 9696 public LSL_String llRequestSimulatorData(string simulator, int data)
9750 { 9697 {
9751 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_itemID, "OSSL"); 9698 IOSSL_Api ossl = (IOSSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "OSSL");
9752 9699
9753 try 9700 try
9754 { 9701 {
@@ -9810,7 +9757,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9810 UUID rq = UUID.Random(); 9757 UUID rq = UUID.Random();
9811 9758
9812 UUID tid = AsyncCommands. 9759 UUID tid = AsyncCommands.
9813 DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 9760 DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
9814 9761
9815 AsyncCommands. 9762 AsyncCommands.
9816 DataserverPlugin.DataserverReply(rq.ToString(), reply); 9763 DataserverPlugin.DataserverReply(rq.ToString(), reply);
@@ -9829,7 +9776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9829 m_host.AddScriptLPS(1); 9776 m_host.AddScriptLPS(1);
9830 9777
9831 if (m_UrlModule != null) 9778 if (m_UrlModule != null)
9832 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_itemID).ToString(); 9779 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID).ToString();
9833 return UUID.Zero.ToString(); 9780 return UUID.Zero.ToString();
9834 } 9781 }
9835 9782
@@ -10309,12 +10256,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10309 { 10256 {
10310 m_host.AddScriptLPS(1); 10257 m_host.AddScriptLPS(1);
10311 10258
10312 TaskInventoryItem item = GetSelfInventoryItem(); 10259 if (m_item.PermsGranter == UUID.Zero)
10313
10314 if (item.PermsGranter == UUID.Zero)
10315 return new LSL_Vector(); 10260 return new LSL_Vector();
10316 10261
10317 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10262 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10318 { 10263 {
10319 ShoutError("No permissions to track the camera"); 10264 ShoutError("No permissions to track the camera");
10320 return new LSL_Vector(); 10265 return new LSL_Vector();
@@ -10334,12 +10279,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10334 { 10279 {
10335 m_host.AddScriptLPS(1); 10280 m_host.AddScriptLPS(1);
10336 10281
10337 TaskInventoryItem item = GetSelfInventoryItem(); 10282 if (m_item.PermsGranter == UUID.Zero)
10338
10339 if (item.PermsGranter == UUID.Zero)
10340 return new LSL_Rotation(); 10283 return new LSL_Rotation();
10341 10284
10342 if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 10285 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
10343 { 10286 {
10344 ShoutError("No permissions to track the camera"); 10287 ShoutError("No permissions to track the camera");
10345 return new LSL_Rotation(); 10288 return new LSL_Rotation();
@@ -10405,7 +10348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10405 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt) 10348 public void llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
10406 { 10349 {
10407 m_host.AddScriptLPS(1); 10350 m_host.AddScriptLPS(1);
10408 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); 10351 DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0);
10409 if (detectedParams == null) 10352 if (detectedParams == null)
10410 { 10353 {
10411 if (m_host.ParentGroup.IsAttachment == true) 10354 if (m_host.ParentGroup.IsAttachment == true)
@@ -10534,15 +10477,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10534 if (objectID == UUID.Zero) 10477 if (objectID == UUID.Zero)
10535 return; 10478 return;
10536 10479
10537 TaskInventoryItem item = GetSelfInventoryItem();
10538
10539 // we need the permission first, to know which avatar we want to set the camera for 10480 // we need the permission first, to know which avatar we want to set the camera for
10540 UUID agentID = item.PermsGranter; 10481 UUID agentID = m_item.PermsGranter;
10541 10482
10542 if (agentID == UUID.Zero) 10483 if (agentID == UUID.Zero)
10543 return; 10484 return;
10544 10485
10545 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10486 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10546 return; 10487 return;
10547 10488
10548 ScenePresence presence = World.GetScenePresence(agentID); 10489 ScenePresence presence = World.GetScenePresence(agentID);
@@ -10590,15 +10531,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10590 if (objectID == UUID.Zero) 10531 if (objectID == UUID.Zero)
10591 return; 10532 return;
10592 10533
10593 TaskInventoryItem item = GetSelfInventoryItem();
10594
10595 // we need the permission first, to know which avatar we want to clear the camera for 10534 // we need the permission first, to know which avatar we want to clear the camera for
10596 UUID agentID = item.PermsGranter; 10535 UUID agentID = m_item.PermsGranter;
10597 10536
10598 if (agentID == UUID.Zero) 10537 if (agentID == UUID.Zero)
10599 return; 10538 return;
10600 10539
10601 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) 10540 if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
10602 return; 10541 return;
10603 10542
10604 ScenePresence presence = World.GetScenePresence(agentID); 10543 ScenePresence presence = World.GetScenePresence(agentID);
@@ -10796,8 +10735,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10796 } 10735 }
10797 } 10736 }
10798 10737
10799 UUID reqID = httpScriptMod. 10738 UUID reqID
10800 StartHttpRequest(m_localID, m_itemID, url, param, httpHeaders, body); 10739 = httpScriptMod.StartHttpRequest(m_host.LocalId, m_item.ItemID, url, param, httpHeaders, body);
10801 10740
10802 if (reqID != UUID.Zero) 10741 if (reqID != UUID.Zero)
10803 return reqID.ToString(); 10742 return reqID.ToString();
@@ -11232,7 +11171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11232 } 11171 }
11233 11172
11234 // was: UUID tid = tid = AsyncCommands. 11173 // was: UUID tid = tid = AsyncCommands.
11235 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11174 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
11236 11175
11237 if (NotecardCache.IsCached(assetID)) 11176 if (NotecardCache.IsCached(assetID))
11238 { 11177 {
@@ -11295,7 +11234,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11295 } 11234 }
11296 11235
11297 // was: UUID tid = tid = AsyncCommands. 11236 // was: UUID tid = tid = AsyncCommands.
11298 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, assetID.ToString()); 11237 UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, assetID.ToString());
11299 11238
11300 if (NotecardCache.IsCached(assetID)) 11239 if (NotecardCache.IsCached(assetID))
11301 { 11240 {
@@ -11379,7 +11318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11379 { 11318 {
11380 UUID rq = UUID.Random(); 11319 UUID rq = UUID.Random();
11381 11320
11382 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 11321 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
11383 11322
11384 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id))); 11323 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
11385 11324
@@ -11395,7 +11334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11395 { 11334 {
11396 UUID rq = UUID.Random(); 11335 UUID rq = UUID.Random();
11397 11336
11398 AsyncCommands.DataserverPlugin.RegisterRequest(m_localID, m_itemID, rq.ToString()); 11337 AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
11399 11338
11400 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id)); 11339 AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
11401 11340
@@ -12074,7 +12013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12074 12013
12075 try 12014 try
12076 { 12015 {
12077 TaskInventoryItem item = GetSelfInventoryItem(); 12016 TaskInventoryItem item = m_item;
12078 if (item == null) 12017 if (item == null)
12079 { 12018 {
12080 replydata = "SERVICE_ERROR"; 12019 replydata = "SERVICE_ERROR";
@@ -12124,7 +12063,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12124 } 12063 }
12125 finally 12064 finally
12126 { 12065 {
12127 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 12066 m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams(
12128 "transaction_result", new Object[] { 12067 "transaction_result", new Object[] {
12129 new LSL_String(txn.ToString()), 12068 new LSL_String(txn.ToString()),
12130 new LSL_Integer(replycode), 12069 new LSL_Integer(replycode),
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index df20126..795de80 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -58,17 +58,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
58 { 58 {
59 internal IScriptEngine m_ScriptEngine; 59 internal IScriptEngine m_ScriptEngine;
60 internal SceneObjectPart m_host; 60 internal SceneObjectPart m_host;
61 internal uint m_localID;
62 internal UUID m_itemID;
63 internal bool m_LSFunctionsEnabled = false; 61 internal bool m_LSFunctionsEnabled = false;
64 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
65 63
66 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
67 { 65 {
68 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
69 m_host = host; 67 m_host = host;
70 m_localID = localID;
71 m_itemID = itemID;
72 68
73 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 69 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
74 m_LSFunctionsEnabled = true; 70 m_LSFunctionsEnabled = true;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7c07e15..4bd3dff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -57,17 +57,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
57 { 57 {
58 internal IScriptEngine m_ScriptEngine; 58 internal IScriptEngine m_ScriptEngine;
59 internal SceneObjectPart m_host; 59 internal SceneObjectPart m_host;
60 internal uint m_localID; 60 internal TaskInventoryItem m_item;
61 internal UUID m_itemID;
62 internal bool m_MODFunctionsEnabled = false; 61 internal bool m_MODFunctionsEnabled = false;
63 internal IScriptModuleComms m_comms = null; 62 internal IScriptModuleComms m_comms = null;
64 63
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
66 { 65 {
67 m_ScriptEngine = ScriptEngine; 66 m_ScriptEngine = ScriptEngine;
68 m_host = host; 67 m_host = host;
69 m_localID = localID; 68 m_item = item;
70 m_itemID = itemID;
71 69
72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) 70 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
73 m_MODFunctionsEnabled = true; 71 m_MODFunctionsEnabled = true;
@@ -252,7 +250,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
252 // non-null but don't trust it completely 250 // non-null but don't trust it completely
253 try 251 try
254 { 252 {
255 object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); 253 object result = m_comms.InvokeOperation(m_host.UUID, m_item.ItemID, fname, convertedParms);
256 if (result != null) 254 if (result != null)
257 return result; 255 return result;
258 256
@@ -279,7 +277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
279 277
280 UUID req = UUID.Random(); 278 UUID req = UUID.Random();
281 279
282 m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); 280 m_comms.RaiseEvent(m_item.ItemID, req.ToString(), module, command, k);
283 281
284 return req.ToString(); 282 return req.ToString();
285 } 283 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 321d0d2..51ace1a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -133,8 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
133 internal IScriptEngine m_ScriptEngine; 133 internal IScriptEngine m_ScriptEngine;
134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there 134 internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
135 internal SceneObjectPart m_host; 135 internal SceneObjectPart m_host;
136 internal uint m_localID; 136 internal TaskInventoryItem m_item;
137 internal UUID m_itemID;
138 internal bool m_OSFunctionsEnabled = false; 137 internal bool m_OSFunctionsEnabled = false;
139 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
140 internal float m_ScriptDelayFactor = 1.0f; 139 internal float m_ScriptDelayFactor = 1.0f;
@@ -142,12 +141,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
142 internal bool m_debuggerSafe = false; 141 internal bool m_debuggerSafe = false;
143 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
144 143
145 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
146 { 145 {
147 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
148 m_host = host; 147 m_host = host;
149 m_localID = localID; 148 m_item = item;
150 m_itemID = itemID;
151 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
152 150
153 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
@@ -233,7 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
233 if (m_LSL_Api != null) 231 if (m_LSL_Api != null)
234 return; 232 return;
235 233
236 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_itemID, "LSL"); 234 m_LSL_Api = (ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID, "LSL");
237 } 235 }
238 236
239 // 237 //
@@ -352,22 +350,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
352 return; 350 return;
353 } 351 }
354 352
355 TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID); 353 UUID ownerID = m_item.OwnerID;
356 if (ti == null)
357 {
358 OSSLError(
359 String.Format("{0} permission error. Can't find script in prim inventory.",
360 function));
361 }
362
363 UUID ownerID = ti.OwnerID;
364 354
365 //OSSL only may be used if object is in the same group as the parcel 355 //OSSL only may be used if object is in the same group as the parcel
366 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) 356 if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
367 { 357 {
368 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 358 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
369 359
370 if (land.LandData.GroupID == ti.GroupID && land.LandData.GroupID != UUID.Zero) 360 if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
371 { 361 {
372 return; 362 return;
373 } 363 }
@@ -403,13 +393,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
403 } 393 }
404 } 394 }
405 395
406 if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID)) 396 if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
407 OSSLError( 397 OSSLError(
408 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", 398 String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
409 function)); 399 function));
410 if (ti.CreatorID != ownerID) 400
401 if (m_item.CreatorID != ownerID)
411 { 402 {
412 if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0) 403 if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
413 OSSLError( 404 OSSLError(
414 String.Format("{0} permission denied. Script permissions error.", 405 String.Format("{0} permission denied. Script permissions error.",
415 function)); 406 function));
@@ -1190,7 +1181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1190 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents"); 1181 CheckThreatLevel(ThreatLevel.High, "osSetStateEvents");
1191 m_host.AddScriptLPS(1); 1182 m_host.AddScriptLPS(1);
1192 1183
1193 m_host.SetScriptEvents(m_itemID, events); 1184 m_host.SetScriptEvents(m_item.ItemID, events);
1194 } 1185 }
1195 1186
1196 public void osSetRegionWaterHeight(double height) 1187 public void osSetRegionWaterHeight(double height)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 0f763f1..5cad883 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
232 foreach (string api in am.GetApis()) 232 foreach (string api in am.GetApis())
233 { 233 {
234 m_Apis[api] = am.CreateApi(api); 234 m_Apis[api] = am.CreateApi(api);
235 m_Apis[api].Initialize(engine, part, LocalID, itemID); 235 m_Apis[api].Initialize(engine, part, ScriptTask);
236 } 236 }
237 237
238 try 238 try
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index 49266e9..c73e22f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
91 TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId); 91 TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, userId);
92 92
93 LSL_Api api = new LSL_Api(); 93 LSL_Api api = new LSL_Api();
94 api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); 94 api.Initialize(m_engine, so1.RootPart, null);
95 95
96 // Create a second object 96 // Create a second object
97 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100); 97 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, userId, "so2", 0x100);
@@ -124,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
124 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); 124 SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10);
125 m_scene.AddSceneObject(so1); 125 m_scene.AddSceneObject(so1);
126 LSL_Api api = new LSL_Api(); 126 LSL_Api api = new LSL_Api();
127 api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); 127 api.Initialize(m_engine, so1.RootPart, null);
128 128
129 // Create an object embedded inside the first 129 // Create an object embedded inside the first
130 UUID itemId = TestHelpers.ParseTail(0x20); 130 UUID itemId = TestHelpers.ParseTail(0x20);
@@ -134,7 +134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
134 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); 134 SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100);
135 m_scene.AddSceneObject(so2); 135 m_scene.AddSceneObject(so2);
136 LSL_Api api2 = new LSL_Api(); 136 LSL_Api api2 = new LSL_Api();
137 api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID); 137 api2.Initialize(m_engine, so2.RootPart, null);
138 138
139 // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** 139 // *** Firstly, we test where llAllowInventoryDrop() has not been called. ***
140 api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); 140 api.llGiveInventory(so2.UUID.ToString(), inventoryItemName);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
new file mode 100644
index 0000000..bc3b790
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -0,0 +1,139 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
45using OpenSim.Services.Interfaces;
46using OpenSim.Tests.Common;
47using OpenSim.Tests.Common.Mock;
48
49namespace OpenSim.Region.ScriptEngine.Shared.Tests
50{
51 /// <summary>
52 /// Tests for linking functions in LSL
53 /// </summary>
54 /// <remarks>
55 /// This relates to LSL. Actual linking functionality should be tested in the main
56 /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests.
57 /// </remarks>
58 [TestFixture]
59 public class LSL_ApiLinkingTests
60 {
61 protected Scene m_scene;
62 protected XEngine.XEngine m_engine;
63
64 [SetUp]
65 public void SetUp()
66 {
67 IConfigSource initConfigSource = new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig("XEngine");
69 config.Set("Enabled", "true");
70
71 m_scene = new SceneHelpers().SetupScene();
72 SceneHelpers.SetupSceneModules(m_scene, initConfigSource);
73
74 m_engine = new XEngine.XEngine();
75 m_engine.Initialise(initConfigSource);
76 m_engine.AddRegion(m_scene);
77 }
78
79 [Test]
80 public void TestllCreateLink()
81 {
82 TestHelpers.InMethod();
83
84 UUID ownerId = TestHelpers.ParseTail(0x1);
85
86 SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10);
87 grp1.AbsolutePosition = new Vector3(10, 10, 10);
88 m_scene.AddSceneObject(grp1);
89
90 // FIXME: This should really be a script item (with accompanying script)
91 TaskInventoryItem grp1Item
92 = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart);
93 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
94
95 SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20);
96 grp2.AbsolutePosition = new Vector3(20, 20, 20);
97
98 // <180,0,0>
99 grp2.UpdateGroupRotationR(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0));
100
101 m_scene.AddSceneObject(grp2);
102
103 LSL_Api apiGrp1 = new LSL_Api();
104 apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item);
105
106 apiGrp1.llCreateLink(grp2.UUID.ToString(), ScriptBaseClass.TRUE);
107
108 Assert.That(grp1.Parts.Length, Is.EqualTo(4));
109 Assert.That(grp2.IsDeleted, Is.True);
110 }
111
112 [Test]
113 public void TestllBreakLink()
114 {
115 TestHelpers.InMethod();
116
117 UUID ownerId = TestHelpers.ParseTail(0x1);
118
119 SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10);
120 grp1.AbsolutePosition = new Vector3(10, 10, 10);
121 m_scene.AddSceneObject(grp1);
122
123 // FIXME: This should really be a script item (with accompanying script)
124 TaskInventoryItem grp1Item
125 = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart);
126 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
127
128 LSL_Api apiGrp1 = new LSL_Api();
129 apiGrp1.Initialize(m_engine, grp1.RootPart, grp1Item);
130
131 apiGrp1.llBreakLink(2);
132
133 Assert.That(grp1.Parts.Length, Is.EqualTo(1));
134
135 SceneObjectGroup grp2 = m_scene.GetSceneObjectGroup("grp1-Part1");
136 Assert.That(grp2, Is.Not.Null);
137 }
138 }
139} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index 92a63bf..f96a156 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -66,8 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
66 engine.AddRegion(scene); 66 engine.AddRegion(scene);
67 67
68 m_lslApi = new LSL_Api(); 68 m_lslApi = new LSL_Api();
69 m_lslApi.Initialize(engine, part, part.LocalId, part.UUID); 69 m_lslApi.Initialize(engine, part, null);
70
71 } 70 }
72 71
73 [Test] 72 [Test]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index c51227b..3965734 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
95 m_scene.AddSceneObject(so); 95 m_scene.AddSceneObject(so);
96 96
97 OSSL_Api osslApi = new OSSL_Api(); 97 OSSL_Api osslApi = new OSSL_Api();
98 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 98 osslApi.Initialize(m_engine, part, null);
99 99
100 string notecardName = "appearanceNc"; 100 string notecardName = "appearanceNc";
101 osslApi.osOwnerSaveAppearance(notecardName); 101 osslApi.osOwnerSaveAppearance(notecardName);
@@ -130,7 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
130 m_scene.AddSceneObject(so); 130 m_scene.AddSceneObject(so);
131 131
132 OSSL_Api osslApi = new OSSL_Api(); 132 OSSL_Api osslApi = new OSSL_Api();
133 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 133 osslApi.Initialize(m_engine, part, null);
134 134
135 string notecardName = "appearanceNc"; 135 string notecardName = "appearanceNc";
136 osslApi.osOwnerSaveAppearance(notecardName); 136 osslApi.osOwnerSaveAppearance(notecardName);
@@ -161,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
161 m_scene.AddSceneObject(so); 161 m_scene.AddSceneObject(so);
162 162
163 OSSL_Api osslApi = new OSSL_Api(); 163 OSSL_Api osslApi = new OSSL_Api();
164 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 164 osslApi.Initialize(m_engine, part, null);
165 165
166 string notecardName = "appearanceNc"; 166 string notecardName = "appearanceNc";
167 167
@@ -202,7 +202,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
202 m_scene.AddSceneObject(so); 202 m_scene.AddSceneObject(so);
203 203
204 OSSL_Api osslApi = new OSSL_Api(); 204 OSSL_Api osslApi = new OSSL_Api();
205 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 205 osslApi.Initialize(m_engine, part, null);
206 206
207 string notecardName = "appearanceNc"; 207 string notecardName = "appearanceNc";
208 208
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 9c36108..0ccd889 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -104,10 +104,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
104 m_scene.AddSceneObject(otherSo); 104 m_scene.AddSceneObject(otherSo);
105 105
106 OSSL_Api osslApi = new OSSL_Api(); 106 OSSL_Api osslApi = new OSSL_Api();
107 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 107 osslApi.Initialize(m_engine, part, null);
108 108
109 OSSL_Api otherOsslApi = new OSSL_Api(); 109 OSSL_Api otherOsslApi = new OSSL_Api();
110 otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, otherPart.UUID); 110 otherOsslApi.Initialize(m_engine, otherPart, null);
111 111
112 string notecardName = "appearanceNc"; 112 string notecardName = "appearanceNc";
113 osslApi.osOwnerSaveAppearance(notecardName); 113 osslApi.osOwnerSaveAppearance(notecardName);
@@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
151 m_scene.AddSceneObject(so); 151 m_scene.AddSceneObject(so);
152 152
153 OSSL_Api osslApi = new OSSL_Api(); 153 OSSL_Api osslApi = new OSSL_Api();
154 osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); 154 osslApi.Initialize(m_engine, part, null);
155 155
156 string notecardName = "appearanceNc"; 156 string notecardName = "appearanceNc";
157 osslApi.osOwnerSaveAppearance(notecardName); 157 osslApi.osOwnerSaveAppearance(notecardName);