aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs473
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs676
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs21
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs76
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs76
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs2
10 files changed, 1083 insertions, 283 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..d4250c1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,473 @@
1using System;
2using System.Reflection;
3using System.Collections;
4using System.Collections.Generic;
5using System.Runtime.Remoting.Lifetime;
6using OpenMetaverse;
7using Nini.Config;
8using OpenSim;
9using OpenSim.Framework;
10using OpenSim.Region.CoreModules.World.Meta7Windlight;
11using OpenSim.Region.Framework.Interfaces;
12using OpenSim.Region.Framework.Scenes;
13using OpenSim.Region.ScriptEngine.Shared;
14using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
15using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
16using OpenSim.Region.ScriptEngine.Interfaces;
17using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
18
19using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
20using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
21using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
22using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
23using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
24using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
25using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
26
27namespace OpenSim.Region.ScriptEngine.Shared.Api
28{
29 [Serializable]
30 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
31 {
32 internal IScriptEngine m_ScriptEngine;
33 internal SceneObjectPart m_host;
34 internal uint m_localID;
35 internal UUID m_itemID;
36 internal bool m_CMFunctionsEnabled = false;
37 internal IScriptModuleComms m_comms = null;
38
39 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
40 {
41 m_ScriptEngine = ScriptEngine;
42 m_host = host;
43 m_localID = localID;
44 m_itemID = itemID;
45
46 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
47 m_CMFunctionsEnabled = true;
48
49 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
50 if (m_comms == null)
51 m_CMFunctionsEnabled = false;
52 }
53
54 public override Object InitializeLifetimeService()
55 {
56 ILease lease = (ILease)base.InitializeLifetimeService();
57
58 if (lease.CurrentState == LeaseState.Initial)
59 {
60 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
61 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
62 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
63 }
64 return lease;
65 }
66
67 public Scene World
68 {
69 get { return m_ScriptEngine.World; }
70 }
71
72 //
73 //Dumps an error message on the debug console.
74 //
75
76 internal void CMShoutError(string message)
77 {
78 if (message.Length > 1023)
79 message = message.Substring(0, 1023);
80
81 World.SimChat(Utils.StringToBytes(message),
82 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
83
84 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
85 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
86 }
87
88 /// <summary>
89 /// Get the current Windlight scene
90 /// </summary>
91 /// <returns>List of windlight parameters</returns>
92 public LSL_List cmGetWindlightScene(LSL_List rules)
93 {
94 if (!m_CMFunctionsEnabled)
95 {
96 CMShoutError("Careminster functions are not enabled.");
97 return new LSL_List();
98 }
99 m_host.AddScriptLPS(1);
100 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
101
102 LSL_List values = new LSL_List();
103 int idx = 0;
104 while (idx < rules.Length)
105 {
106 uint rule = (uint)rules.GetLSLIntegerItem(idx);
107 LSL_List toadd = new LSL_List();
108
109 switch (rule)
110 {
111 case (int)ScriptBaseClass.WL_AMBIENT:
112 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
113 break;
114 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
115 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
116 break;
117 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
118 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
119 break;
120 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
121 toadd.Add(new LSL_Float(wl.blurMultiplier));
122 break;
123 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
124 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
125 break;
126 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
127 toadd.Add(new LSL_Float(wl.cloudCoverage));
128 break;
129 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
130 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
131 break;
132 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
133 toadd.Add(new LSL_Float(wl.cloudScale));
134 break;
135 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
136 toadd.Add(new LSL_Float(wl.cloudScrollX));
137 break;
138 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
139 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
140 break;
141 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
142 toadd.Add(new LSL_Float(wl.cloudScrollY));
143 break;
144 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
145 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
146 break;
147 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
148 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
149 break;
150 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
151 toadd.Add(new LSL_Float(wl.densityMultiplier));
152 break;
153 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
154 toadd.Add(new LSL_Float(wl.distanceMultiplier));
155 break;
156 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
157 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
158 break;
159 case (int)ScriptBaseClass.WL_EAST_ANGLE:
160 toadd.Add(new LSL_Float(wl.eastAngle));
161 break;
162 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
163 toadd.Add(new LSL_Float(wl.fresnelOffset));
164 break;
165 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
166 toadd.Add(new LSL_Float(wl.fresnelScale));
167 break;
168 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
169 toadd.Add(new LSL_Float(wl.hazeDensity));
170 break;
171 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
172 toadd.Add(new LSL_Float(wl.hazeHorizon));
173 break;
174 case (int)ScriptBaseClass.WL_HORIZON:
175 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
176 break;
177 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
178 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
179 break;
180 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
181 toadd.Add(new LSL_Integer(wl.maxAltitude));
182 break;
183 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
184 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
185 break;
186 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
187 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
188 break;
189 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
190 toadd.Add(new LSL_Float(wl.refractScaleAbove));
191 break;
192 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
193 toadd.Add(new LSL_Float(wl.refractScaleBelow));
194 break;
195 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
196 toadd.Add(new LSL_Float(wl.sceneGamma));
197 break;
198 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
199 toadd.Add(new LSL_Float(wl.starBrightness));
200 break;
201 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
202 toadd.Add(new LSL_Float(wl.sunGlowFocus));
203 break;
204 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
205 toadd.Add(new LSL_Float(wl.sunGlowSize));
206 break;
207 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
208 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
209 break;
210 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
211 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
212 break;
213 case (int)ScriptBaseClass.WL_WATER_COLOR:
214 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
215 break;
216 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
217 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
218 break;
219 }
220
221 if (toadd.Length > 0)
222 {
223 values.Add(rule);
224 values.Add(toadd.Data[0]);
225 }
226 idx++;
227 }
228
229
230 return values;
231
232 }
233
234 private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
235 {
236 RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
237
238 LSL_List values = new LSL_List();
239 int idx = 0;
240 while (idx < rules.Length)
241 {
242 uint rule = (uint)rules.GetLSLIntegerItem(idx);
243 LSL_Types.Quaternion iQ;
244 LSL_Types.Vector3 iV;
245 switch (rule)
246 {
247 case (int)ScriptBaseClass.WL_AMBIENT:
248 idx++;
249 iQ = rules.GetQuaternionItem(idx);
250 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
251 break;
252 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
253 idx++;
254 iV = rules.GetVector3Item(idx);
255 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
256 break;
257 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
258 idx++;
259 iQ = rules.GetQuaternionItem(idx);
260 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
261 break;
262 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
263 idx++;
264 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
265 break;
266 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
267 idx++;
268 iQ = rules.GetQuaternionItem(idx);
269 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
270 break;
271 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
272 idx++;
273 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
274 break;
275 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
276 idx++;
277 iV = rules.GetVector3Item(idx);
278 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
279 break;
280 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
281 idx++;
282 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
283 break;
284 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
285 idx++;
286 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
287 break;
288 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
289 idx++;
290 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
291 break;
292 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
293 idx++;
294 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
295 break;
296 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
297 idx++;
298 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
299 break;
300 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
301 idx++;
302 iV = rules.GetVector3Item(idx);
303 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
304 break;
305 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
306 idx++;
307 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
308 break;
309 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
310 idx++;
311 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
312 break;
313 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
314 idx++;
315 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
316 break;
317 case (int)ScriptBaseClass.WL_EAST_ANGLE:
318 idx++;
319 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
320 break;
321 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
322 idx++;
323 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
324 break;
325 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
326 idx++;
327 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
328 break;
329 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
330 idx++;
331 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
332 break;
333 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
334 idx++;
335 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
336 break;
337 case (int)ScriptBaseClass.WL_HORIZON:
338 idx++;
339 iQ = rules.GetQuaternionItem(idx);
340 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
341 break;
342 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
343 idx++;
344 iV = rules.GetVector3Item(idx);
345 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
346 break;
347 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
348 idx++;
349 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
350 break;
351 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
352 idx++;
353 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
354 break;
355 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
356 idx++;
357 iV = rules.GetVector3Item(idx);
358 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
359 break;
360 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
361 idx++;
362 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
363 break;
364 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
365 idx++;
366 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
367 break;
368 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
369 idx++;
370 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
371 break;
372 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
373 idx++;
374 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
375 break;
376 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
377 idx++;
378 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
379 break;
380 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
381 idx++;
382 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
383 break;
384 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
385 idx++;
386 iQ = rules.GetQuaternionItem(idx);
387 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
388 break;
389 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
390 idx++;
391 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
392 break;
393 case (int)ScriptBaseClass.WL_WATER_COLOR:
394 idx++;
395 iV = rules.GetVector3Item(idx);
396 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
397 break;
398 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
399 idx++;
400 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
401 break;
402 }
403 idx++;
404 }
405 return wl;
406 }
407 /// <summary>
408 /// Set the current Windlight scene
409 /// </summary>
410 /// <param name="rules"></param>
411 /// <returns>success: true or false</returns>
412 public int cmSetWindlightScene(LSL_List rules)
413 {
414 if (!m_CMFunctionsEnabled)
415 {
416 CMShoutError("Careminster functions are not enabled.");
417 return 0;
418 }
419 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
420 {
421 CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
422 return 0;
423 }
424 int success = 0;
425 m_host.AddScriptLPS(1);
426 if (Meta7WindlightModule.EnableWindlight)
427 {
428 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
429 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
430 success = 1;
431 }
432 else
433 {
434 CMShoutError("Windlight module is disabled");
435 return 0;
436 }
437 return success;
438 }
439 /// <summary>
440 /// Set the current Windlight scene to a target avatar
441 /// </summary>
442 /// <param name="rules"></param>
443 /// <returns>success: true or false</returns>
444 public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
445 {
446 if (!m_CMFunctionsEnabled)
447 {
448 CMShoutError("Careminster functions are not enabled.");
449 return 0;
450 }
451 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
452 {
453 CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
454 return 0;
455 }
456 int success = 0;
457 m_host.AddScriptLPS(1);
458 if (Meta7WindlightModule.EnableWindlight)
459 {
460 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
461 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
462 success = 1;
463 }
464 else
465 {
466 CMShoutError("Windlight module is disabled");
467 return 0;
468 }
469 return success;
470 }
471
472 }
473}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index cf3a1a0..cc903e0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; //for [DebuggerNonUserCode]
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
151 get { return m_ScriptEngine.World; } 152 get { return m_ScriptEngine.World; }
152 } 153 }
153 154
155 [DebuggerNonUserCode]
154 public void state(string newState) 156 public void state(string newState)
155 { 157 {
156 m_ScriptEngine.SetState(m_itemID, newState); 158 m_ScriptEngine.SetState(m_itemID, newState);
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
160 /// Reset the named script. The script must be present 162 /// Reset the named script. The script must be present
161 /// in the same prim. 163 /// in the same prim.
162 /// </summary> 164 /// </summary>
165 [DebuggerNonUserCode]
163 public void llResetScript() 166 public void llResetScript()
164 { 167 {
165 m_host.AddScriptLPS(1); 168 m_host.AddScriptLPS(1);
@@ -218,7 +221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
218 221
219 public List<SceneObjectPart> GetLinkParts(int linkType) 222 public List<SceneObjectPart> GetLinkParts(int linkType)
220 { 223 {
221 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 224 List<SceneObjectPart> ret = new List<SceneObjectPart>();
225 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
226 return ret;
222 ret.Add(m_host); 227 ret.Add(m_host);
223 228
224 switch (linkType) 229 switch (linkType)
@@ -272,40 +277,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
272 protected UUID InventorySelf() 277 protected UUID InventorySelf()
273 { 278 {
274 UUID invItemID = new UUID(); 279 UUID invItemID = new UUID();
275 280 bool unlock = false;
276 lock (m_host.TaskInventory) 281 if (!m_host.TaskInventory.IsReadLockedByMe())
282 {
283 m_host.TaskInventory.LockItemsForRead(true);
284 unlock = true;
285 }
286 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
277 { 287 {
278 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 288 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
279 { 289 {
280 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 290 invItemID = inv.Key;
281 { 291 break;
282 invItemID = inv.Key;
283 break;
284 }
285 } 292 }
286 } 293 }
287 294 if (unlock)
295 {
296 m_host.TaskInventory.LockItemsForRead(false);
297 }
288 return invItemID; 298 return invItemID;
289 } 299 }
290 300
291 protected UUID InventoryKey(string name, int type) 301 protected UUID InventoryKey(string name, int type)
292 { 302 {
293 m_host.AddScriptLPS(1); 303 m_host.AddScriptLPS(1);
294 304 m_host.TaskInventory.LockItemsForRead(true);
295 lock (m_host.TaskInventory) 305
306 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
296 { 307 {
297 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 308 if (inv.Value.Name == name)
298 { 309 {
299 if (inv.Value.Name == name) 310 m_host.TaskInventory.LockItemsForRead(false);
311
312 if (inv.Value.Type != type)
300 { 313 {
301 if (inv.Value.Type != type) 314 return UUID.Zero;
302 return UUID.Zero;
303
304 return inv.Value.AssetID;
305 } 315 }
316
317 return inv.Value.AssetID;
306 } 318 }
307 } 319 }
308 320
321 m_host.TaskInventory.LockItemsForRead(false);
309 return UUID.Zero; 322 return UUID.Zero;
310 } 323 }
311 324
@@ -313,17 +326,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
313 { 326 {
314 m_host.AddScriptLPS(1); 327 m_host.AddScriptLPS(1);
315 328
316 lock (m_host.TaskInventory) 329
330 m_host.TaskInventory.LockItemsForRead(true);
331
332 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
317 { 333 {
318 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 334 if (inv.Value.Name == name)
319 { 335 {
320 if (inv.Value.Name == name) 336 m_host.TaskInventory.LockItemsForRead(false);
321 { 337 return inv.Value.AssetID;
322 return inv.Value.AssetID;
323 }
324 } 338 }
325 } 339 }
326 340
341 m_host.TaskInventory.LockItemsForRead(false);
342
343
327 return UUID.Zero; 344 return UUID.Zero;
328 } 345 }
329 346
@@ -1121,7 +1138,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1121 } 1138 }
1122 1139
1123 public void llSetStatus(int status, int value) 1140 public void llSetStatus(int status, int value)
1124 { 1141 {
1142 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1143 return;
1125 m_host.AddScriptLPS(1); 1144 m_host.AddScriptLPS(1);
1126 1145
1127 int statusrotationaxis = 0; 1146 int statusrotationaxis = 0;
@@ -1275,7 +1294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1275 } 1294 }
1276 1295
1277 protected void SetScale(SceneObjectPart part, LSL_Vector scale) 1296 protected void SetScale(SceneObjectPart part, LSL_Vector scale)
1278 { 1297 {
1279 // TODO: this needs to trigger a persistance save as well 1298 // TODO: this needs to trigger a persistance save as well
1280 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1299 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1281 return; 1300 return;
@@ -1334,7 +1353,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1334 } 1353 }
1335 1354
1336 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) 1355 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1337 { 1356 {
1357 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1358 return;
1359
1338 Primitive.TextureEntry tex = part.Shape.Textures; 1360 Primitive.TextureEntry tex = part.Shape.Textures;
1339 Color4 texcolor; 1361 Color4 texcolor;
1340 if (face >= 0 && face < GetNumberOfSides(part)) 1362 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1371,7 +1393,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1371 } 1393 }
1372 1394
1373 public void SetTexGen(SceneObjectPart part, int face,int style) 1395 public void SetTexGen(SceneObjectPart part, int face,int style)
1374 { 1396 {
1397 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1398 return;
1399
1375 Primitive.TextureEntry tex = part.Shape.Textures; 1400 Primitive.TextureEntry tex = part.Shape.Textures;
1376 MappingType textype; 1401 MappingType textype;
1377 textype = MappingType.Default; 1402 textype = MappingType.Default;
@@ -1401,7 +1426,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1401 } 1426 }
1402 1427
1403 public void SetGlow(SceneObjectPart part, int face, float glow) 1428 public void SetGlow(SceneObjectPart part, int face, float glow)
1404 { 1429 {
1430 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1431 return;
1432
1405 Primitive.TextureEntry tex = part.Shape.Textures; 1433 Primitive.TextureEntry tex = part.Shape.Textures;
1406 if (face >= 0 && face < GetNumberOfSides(part)) 1434 if (face >= 0 && face < GetNumberOfSides(part))
1407 { 1435 {
@@ -1426,7 +1454,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1426 } 1454 }
1427 1455
1428 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1456 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1429 { 1457 {
1458 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1459 return;
1430 1460
1431 Shininess sval = new Shininess(); 1461 Shininess sval = new Shininess();
1432 1462
@@ -1476,7 +1506,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1476 } 1506 }
1477 1507
1478 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1508 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1479 { 1509 {
1510 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1511 return;
1512
1480 Primitive.TextureEntry tex = part.Shape.Textures; 1513 Primitive.TextureEntry tex = part.Shape.Textures;
1481 if (face >= 0 && face < GetNumberOfSides(part)) 1514 if (face >= 0 && face < GetNumberOfSides(part))
1482 { 1515 {
@@ -1543,7 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1543 } 1576 }
1544 1577
1545 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1578 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1546 { 1579 {
1580 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1581 return;
1582
1547 Primitive.TextureEntry tex = part.Shape.Textures; 1583 Primitive.TextureEntry tex = part.Shape.Textures;
1548 Color4 texcolor; 1584 Color4 texcolor;
1549 if (face >= 0 && face < GetNumberOfSides(part)) 1585 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1588,8 +1624,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1588 /// <param name="Force"></param> 1624 /// <param name="Force"></param>
1589 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1625 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1590 float wind, float tension, LSL_Vector Force) 1626 float wind, float tension, LSL_Vector Force)
1591 { 1627 {
1592 if (part == null) 1628 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1593 return; 1629 return;
1594 1630
1595 if (flexi) 1631 if (flexi)
@@ -1623,8 +1659,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1623 /// <param name="radius"></param> 1659 /// <param name="radius"></param>
1624 /// <param name="falloff"></param> 1660 /// <param name="falloff"></param>
1625 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1661 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1626 { 1662 {
1627 if (part == null) 1663 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1628 return; 1664 return;
1629 1665
1630 if (light) 1666 if (light)
@@ -1709,7 +1745,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1709 } 1745 }
1710 1746
1711 protected void SetTexture(SceneObjectPart part, string texture, int face) 1747 protected void SetTexture(SceneObjectPart part, string texture, int face)
1712 { 1748 {
1749 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1750 return;
1751
1713 UUID textureID=new UUID(); 1752 UUID textureID=new UUID();
1714 1753
1715 if (!UUID.TryParse(texture, out textureID)) 1754 if (!UUID.TryParse(texture, out textureID))
@@ -1754,7 +1793,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1754 } 1793 }
1755 1794
1756 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1795 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1757 { 1796 {
1797 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1798 return;
1799
1758 Primitive.TextureEntry tex = part.Shape.Textures; 1800 Primitive.TextureEntry tex = part.Shape.Textures;
1759 if (face >= 0 && face < GetNumberOfSides(part)) 1801 if (face >= 0 && face < GetNumberOfSides(part))
1760 { 1802 {
@@ -1790,7 +1832,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1790 } 1832 }
1791 1833
1792 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1834 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1793 { 1835 {
1836 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1837 return;
1838
1794 Primitive.TextureEntry tex = part.Shape.Textures; 1839 Primitive.TextureEntry tex = part.Shape.Textures;
1795 if (face >= 0 && face < GetNumberOfSides(part)) 1840 if (face >= 0 && face < GetNumberOfSides(part))
1796 { 1841 {
@@ -1826,7 +1871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1826 } 1871 }
1827 1872
1828 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 1873 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1829 { 1874 {
1875 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1876 return;
1877
1830 Primitive.TextureEntry tex = part.Shape.Textures; 1878 Primitive.TextureEntry tex = part.Shape.Textures;
1831 if (face >= 0 && face < GetNumberOfSides(part)) 1879 if (face >= 0 && face < GetNumberOfSides(part))
1832 { 1880 {
@@ -1896,7 +1944,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1896 } 1944 }
1897 1945
1898 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 1946 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1899 { 1947 {
1948 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1949 return;
1950
1900 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 1951 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1901 LSL_Vector currentPos = llGetLocalPos(); 1952 LSL_Vector currentPos = llGetLocalPos();
1902 1953
@@ -1990,7 +2041,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1990 } 2041 }
1991 2042
1992 protected void SetRot(SceneObjectPart part, Quaternion rot) 2043 protected void SetRot(SceneObjectPart part, Quaternion rot)
1993 { 2044 {
2045 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2046 return;
2047
1994 part.UpdateRotation(rot); 2048 part.UpdateRotation(rot);
1995 // Update rotation does not move the object in the physics scene if it's a linkset. 2049 // Update rotation does not move the object in the physics scene if it's a linkset.
1996 2050
@@ -2555,12 +2609,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 2609
2556 m_host.AddScriptLPS(1); 2610 m_host.AddScriptLPS(1);
2557 2611
2612 m_host.TaskInventory.LockItemsForRead(true);
2558 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2613 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2559 2614 m_host.TaskInventory.LockItemsForRead(false);
2560 lock (m_host.TaskInventory)
2561 {
2562 item = m_host.TaskInventory[invItemID];
2563 }
2564 2615
2565 if (item.PermsGranter == UUID.Zero) 2616 if (item.PermsGranter == UUID.Zero)
2566 return 0; 2617 return 0;
@@ -2635,6 +2686,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2635 if (dist > m_ScriptDistanceFactor * 10.0f) 2686 if (dist > m_ScriptDistanceFactor * 10.0f)
2636 return; 2687 return;
2637 2688
2689 //Clone is thread-safe
2638 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2690 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2639 2691
2640 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2692 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2720,6 +2772,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2720 // Orient the object to the angle calculated 2772 // Orient the object to the angle calculated
2721 llSetRot(rot); 2773 llSetRot(rot);
2722 } 2774 }
2775
2776 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
2777 {
2778 m_host.AddScriptLPS(1);
2779// NotImplemented("llRotLookAt");
2780 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
2781
2782 }
2723 2783
2724 public void llStopLookAt() 2784 public void llStopLookAt()
2725 { 2785 {
@@ -2759,13 +2819,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2759 { 2819 {
2760 TaskInventoryItem item; 2820 TaskInventoryItem item;
2761 2821
2762 lock (m_host.TaskInventory) 2822 m_host.TaskInventory.LockItemsForRead(true);
2823 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2763 { 2824 {
2764 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2825 m_host.TaskInventory.LockItemsForRead(false);
2765 return; 2826 return;
2766 else
2767 item = m_host.TaskInventory[InventorySelf()];
2768 } 2827 }
2828 else
2829 {
2830 item = m_host.TaskInventory[InventorySelf()];
2831 }
2832 m_host.TaskInventory.LockItemsForRead(false);
2769 2833
2770 if (item.PermsGranter != UUID.Zero) 2834 if (item.PermsGranter != UUID.Zero)
2771 { 2835 {
@@ -2787,13 +2851,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2787 { 2851 {
2788 TaskInventoryItem item; 2852 TaskInventoryItem item;
2789 2853
2854 m_host.TaskInventory.LockItemsForRead(true);
2790 lock (m_host.TaskInventory) 2855 lock (m_host.TaskInventory)
2791 { 2856 {
2857
2792 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2858 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2859 {
2860 m_host.TaskInventory.LockItemsForRead(false);
2793 return; 2861 return;
2862 }
2794 else 2863 else
2864 {
2795 item = m_host.TaskInventory[InventorySelf()]; 2865 item = m_host.TaskInventory[InventorySelf()];
2866 }
2796 } 2867 }
2868 m_host.TaskInventory.LockItemsForRead(false);
2797 2869
2798 m_host.AddScriptLPS(1); 2870 m_host.AddScriptLPS(1);
2799 2871
@@ -2830,13 +2902,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2830 2902
2831 TaskInventoryItem item; 2903 TaskInventoryItem item;
2832 2904
2833 lock (m_host.TaskInventory) 2905 m_host.TaskInventory.LockItemsForRead(true);
2906
2907 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2834 { 2908 {
2835 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2909 m_host.TaskInventory.LockItemsForRead(false);
2836 return; 2910 return;
2837 else
2838 item = m_host.TaskInventory[InventorySelf()];
2839 } 2911 }
2912 else
2913 {
2914 item = m_host.TaskInventory[InventorySelf()];
2915 }
2916
2917 m_host.TaskInventory.LockItemsForRead(false);
2840 2918
2841 if (item.PermsGranter != m_host.OwnerID) 2919 if (item.PermsGranter != m_host.OwnerID)
2842 return; 2920 return;
@@ -2862,13 +2940,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2862 2940
2863 TaskInventoryItem item; 2941 TaskInventoryItem item;
2864 2942
2865 lock (m_host.TaskInventory) 2943 m_host.TaskInventory.LockItemsForRead(true);
2944
2945 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2866 { 2946 {
2867 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2947 m_host.TaskInventory.LockItemsForRead(false);
2868 return; 2948 return;
2869 else
2870 item = m_host.TaskInventory[InventorySelf()];
2871 } 2949 }
2950 else
2951 {
2952 item = m_host.TaskInventory[InventorySelf()];
2953 }
2954 m_host.TaskInventory.LockItemsForRead(false);
2955
2872 2956
2873 if (item.PermsGranter != m_host.OwnerID) 2957 if (item.PermsGranter != m_host.OwnerID)
2874 return; 2958 return;
@@ -2904,8 +2988,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2904 return m_host.OwnerID.ToString(); 2988 return m_host.OwnerID.ToString();
2905 } 2989 }
2906 2990
2991 [DebuggerNonUserCode]
2907 public void llInstantMessage(string user, string message) 2992 public void llInstantMessage(string user, string message)
2908 { 2993 {
2994 UUID result;
2995 if (!UUID.TryParse(user, out result))
2996 {
2997 throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
2998 return;
2999 }
3000
3001
2909 m_host.AddScriptLPS(1); 3002 m_host.AddScriptLPS(1);
2910 3003
2911 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3004 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -2920,7 +3013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2920 UUID friendTransactionID = UUID.Random(); 3013 UUID friendTransactionID = UUID.Random();
2921 3014
2922 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3015 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
2923 3016
2924 GridInstantMessage msg = new GridInstantMessage(); 3017 GridInstantMessage msg = new GridInstantMessage();
2925 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3018 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
2926 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3019 msg.toAgentID = new Guid(user); // toAgentID.Guid;
@@ -3069,13 +3162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3069 m_host.AddScriptLPS(1); 3162 m_host.AddScriptLPS(1);
3070 } 3163 }
3071 3164
3072 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3073 {
3074 m_host.AddScriptLPS(1);
3075// NotImplemented("llRotLookAt");
3076 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
3077 }
3078
3079 public LSL_Integer llStringLength(string str) 3165 public LSL_Integer llStringLength(string str)
3080 { 3166 {
3081 m_host.AddScriptLPS(1); 3167 m_host.AddScriptLPS(1);
@@ -3099,14 +3185,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3099 3185
3100 TaskInventoryItem item; 3186 TaskInventoryItem item;
3101 3187
3102 lock (m_host.TaskInventory) 3188 m_host.TaskInventory.LockItemsForRead(true);
3189 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3103 { 3190 {
3104 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3191 m_host.TaskInventory.LockItemsForRead(false);
3105 return; 3192 return;
3106 else
3107 item = m_host.TaskInventory[InventorySelf()];
3108 } 3193 }
3109 3194 else
3195 {
3196 item = m_host.TaskInventory[InventorySelf()];
3197 }
3198 m_host.TaskInventory.LockItemsForRead(false);
3110 if (item.PermsGranter == UUID.Zero) 3199 if (item.PermsGranter == UUID.Zero)
3111 return; 3200 return;
3112 3201
@@ -3136,13 +3225,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3136 3225
3137 TaskInventoryItem item; 3226 TaskInventoryItem item;
3138 3227
3139 lock (m_host.TaskInventory) 3228 m_host.TaskInventory.LockItemsForRead(true);
3229 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3140 { 3230 {
3141 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3231 m_host.TaskInventory.LockItemsForRead(false);
3142 return; 3232 return;
3143 else
3144 item = m_host.TaskInventory[InventorySelf()];
3145 } 3233 }
3234 else
3235 {
3236 item = m_host.TaskInventory[InventorySelf()];
3237 }
3238 m_host.TaskInventory.LockItemsForRead(false);
3239
3146 3240
3147 if (item.PermsGranter == UUID.Zero) 3241 if (item.PermsGranter == UUID.Zero)
3148 return; 3242 return;
@@ -3215,10 +3309,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3215 3309
3216 TaskInventoryItem item; 3310 TaskInventoryItem item;
3217 3311
3218 lock (m_host.TaskInventory) 3312
3313 m_host.TaskInventory.LockItemsForRead(true);
3314 if (!m_host.TaskInventory.ContainsKey(invItemID))
3315 {
3316 m_host.TaskInventory.LockItemsForRead(false);
3317 return;
3318 }
3319 else
3219 { 3320 {
3220 item = m_host.TaskInventory[invItemID]; 3321 item = m_host.TaskInventory[invItemID];
3221 } 3322 }
3323 m_host.TaskInventory.LockItemsForRead(false);
3222 3324
3223 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3325 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3224 { 3326 {
@@ -3250,11 +3352,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3250 3352
3251 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3353 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3252 { 3354 {
3253 lock (m_host.TaskInventory) 3355 m_host.TaskInventory.LockItemsForWrite(true);
3254 { 3356 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3255 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3357 m_host.TaskInventory[invItemID].PermsMask = perm;
3256 m_host.TaskInventory[invItemID].PermsMask = perm; 3358 m_host.TaskInventory.LockItemsForWrite(false);
3257 }
3258 3359
3259 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3360 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3260 "run_time_permissions", new Object[] { 3361 "run_time_permissions", new Object[] {
@@ -3274,11 +3375,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3274 3375
3275 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3376 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3276 { 3377 {
3277 lock (m_host.TaskInventory) 3378 m_host.TaskInventory.LockItemsForWrite(true);
3278 { 3379 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3279 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3380 m_host.TaskInventory[invItemID].PermsMask = perm;
3280 m_host.TaskInventory[invItemID].PermsMask = perm; 3381 m_host.TaskInventory.LockItemsForWrite(false);
3281 }
3282 3382
3283 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3383 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3284 "run_time_permissions", new Object[] { 3384 "run_time_permissions", new Object[] {
@@ -3299,11 +3399,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3299 3399
3300 if (!m_waitingForScriptAnswer) 3400 if (!m_waitingForScriptAnswer)
3301 { 3401 {
3302 lock (m_host.TaskInventory) 3402 m_host.TaskInventory.LockItemsForWrite(true);
3303 { 3403 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3304 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3404 m_host.TaskInventory[invItemID].PermsMask = 0;
3305 m_host.TaskInventory[invItemID].PermsMask = 0; 3405 m_host.TaskInventory.LockItemsForWrite(false);
3306 }
3307 3406
3308 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3407 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3309 m_waitingForScriptAnswer=true; 3408 m_waitingForScriptAnswer=true;
@@ -3338,10 +3437,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3338 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3437 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3339 llReleaseControls(); 3438 llReleaseControls();
3340 3439
3341 lock (m_host.TaskInventory) 3440
3342 { 3441 m_host.TaskInventory.LockItemsForWrite(true);
3343 m_host.TaskInventory[invItemID].PermsMask = answer; 3442 m_host.TaskInventory[invItemID].PermsMask = answer;
3344 } 3443 m_host.TaskInventory.LockItemsForWrite(false);
3444
3345 3445
3346 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3446 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3347 "run_time_permissions", new Object[] { 3447 "run_time_permissions", new Object[] {
@@ -3353,16 +3453,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3353 { 3453 {
3354 m_host.AddScriptLPS(1); 3454 m_host.AddScriptLPS(1);
3355 3455
3356 lock (m_host.TaskInventory) 3456 m_host.TaskInventory.LockItemsForRead(true);
3457
3458 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3357 { 3459 {
3358 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3460 if (item.Type == 10 && item.ItemID == m_itemID)
3359 { 3461 {
3360 if (item.Type == 10 && item.ItemID == m_itemID) 3462 m_host.TaskInventory.LockItemsForRead(false);
3361 { 3463 return item.PermsGranter.ToString();
3362 return item.PermsGranter.ToString();
3363 }
3364 } 3464 }
3365 } 3465 }
3466 m_host.TaskInventory.LockItemsForRead(false);
3366 3467
3367 return UUID.Zero.ToString(); 3468 return UUID.Zero.ToString();
3368 } 3469 }
@@ -3371,19 +3472,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3371 { 3472 {
3372 m_host.AddScriptLPS(1); 3473 m_host.AddScriptLPS(1);
3373 3474
3374 lock (m_host.TaskInventory) 3475 m_host.TaskInventory.LockItemsForRead(true);
3476
3477 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3375 { 3478 {
3376 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3479 if (item.Type == 10 && item.ItemID == m_itemID)
3377 { 3480 {
3378 if (item.Type == 10 && item.ItemID == m_itemID) 3481 int perms = item.PermsMask;
3379 { 3482 if (m_automaticLinkPermission)
3380 int perms = item.PermsMask; 3483 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3381 if (m_automaticLinkPermission) 3484 m_host.TaskInventory.LockItemsForRead(false);
3382 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3485 return perms;
3383 return perms;
3384 }
3385 } 3486 }
3386 } 3487 }
3488 m_host.TaskInventory.LockItemsForRead(false);
3387 3489
3388 return 0; 3490 return 0;
3389 } 3491 }
@@ -3416,11 +3518,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3416 UUID invItemID = InventorySelf(); 3518 UUID invItemID = InventorySelf();
3417 3519
3418 TaskInventoryItem item; 3520 TaskInventoryItem item;
3419 lock (m_host.TaskInventory) 3521 m_host.TaskInventory.LockItemsForRead(true);
3420 { 3522 item = m_host.TaskInventory[invItemID];
3421 item = m_host.TaskInventory[invItemID]; 3523 m_host.TaskInventory.LockItemsForRead(false);
3422 } 3524
3423
3424 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3525 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3425 && !m_automaticLinkPermission) 3526 && !m_automaticLinkPermission)
3426 { 3527 {
@@ -3473,16 +3574,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3473 m_host.AddScriptLPS(1); 3574 m_host.AddScriptLPS(1);
3474 UUID invItemID = InventorySelf(); 3575 UUID invItemID = InventorySelf();
3475 3576
3476 lock (m_host.TaskInventory) 3577 m_host.TaskInventory.LockItemsForRead(true);
3477 {
3478 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3578 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3479 && !m_automaticLinkPermission) 3579 && !m_automaticLinkPermission)
3480 { 3580 {
3481 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3581 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3582 m_host.TaskInventory.LockItemsForRead(false);
3482 return; 3583 return;
3483 } 3584 }
3484 } 3585 m_host.TaskInventory.LockItemsForRead(false);
3485 3586
3486 if (linknum < ScriptBaseClass.LINK_THIS) 3587 if (linknum < ScriptBaseClass.LINK_THIS)
3487 return; 3588 return;
3488 3589
@@ -3659,17 +3760,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3659 m_host.AddScriptLPS(1); 3760 m_host.AddScriptLPS(1);
3660 int count = 0; 3761 int count = 0;
3661 3762
3662 lock (m_host.TaskInventory) 3763 m_host.TaskInventory.LockItemsForRead(true);
3764 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3663 { 3765 {
3664 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3766 if (inv.Value.Type == type || type == -1)
3665 { 3767 {
3666 if (inv.Value.Type == type || type == -1) 3768 count = count + 1;
3667 {
3668 count = count + 1;
3669 }
3670 } 3769 }
3671 } 3770 }
3672 3771
3772 m_host.TaskInventory.LockItemsForRead(false);
3673 return count; 3773 return count;
3674 } 3774 }
3675 3775
@@ -3678,16 +3778,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3678 m_host.AddScriptLPS(1); 3778 m_host.AddScriptLPS(1);
3679 ArrayList keys = new ArrayList(); 3779 ArrayList keys = new ArrayList();
3680 3780
3681 lock (m_host.TaskInventory) 3781 m_host.TaskInventory.LockItemsForRead(true);
3782 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3682 { 3783 {
3683 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3784 if (inv.Value.Type == type || type == -1)
3684 { 3785 {
3685 if (inv.Value.Type == type || type == -1) 3786 keys.Add(inv.Value.Name);
3686 {
3687 keys.Add(inv.Value.Name);
3688 }
3689 } 3787 }
3690 } 3788 }
3789 m_host.TaskInventory.LockItemsForRead(false);
3691 3790
3692 if (keys.Count == 0) 3791 if (keys.Count == 0)
3693 { 3792 {
@@ -3724,20 +3823,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3724 } 3823 }
3725 3824
3726 // move the first object found with this inventory name 3825 // move the first object found with this inventory name
3727 lock (m_host.TaskInventory) 3826 m_host.TaskInventory.LockItemsForRead(true);
3827 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3728 { 3828 {
3729 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3829 if (inv.Value.Name == inventory)
3730 { 3830 {
3731 if (inv.Value.Name == inventory) 3831 found = true;
3732 { 3832 objId = inv.Key;
3733 found = true; 3833 assetType = inv.Value.Type;
3734 objId = inv.Key; 3834 objName = inv.Value.Name;
3735 assetType = inv.Value.Type; 3835 break;
3736 objName = inv.Value.Name;
3737 break;
3738 }
3739 } 3836 }
3740 } 3837 }
3838 m_host.TaskInventory.LockItemsForRead(false);
3741 3839
3742 if (!found) 3840 if (!found)
3743 { 3841 {
@@ -3782,24 +3880,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3782 ScriptSleep(3000); 3880 ScriptSleep(3000);
3783 } 3881 }
3784 3882
3883 [DebuggerNonUserCode]
3785 public void llRemoveInventory(string name) 3884 public void llRemoveInventory(string name)
3786 { 3885 {
3787 m_host.AddScriptLPS(1); 3886 m_host.AddScriptLPS(1);
3788 3887
3789 lock (m_host.TaskInventory) 3888 m_host.TaskInventory.LockItemsForRead(true);
3889 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3790 { 3890 {
3791 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3891 if (item.Name == name)
3792 { 3892 {
3793 if (item.Name == name) 3893 if (item.ItemID == m_itemID)
3794 { 3894 throw new ScriptDeleteException();
3795 if (item.ItemID == m_itemID) 3895 else
3796 throw new ScriptDeleteException(); 3896 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3797 else 3897
3798 m_host.Inventory.RemoveInventoryItem(item.ItemID); 3898 m_host.TaskInventory.LockItemsForRead(false);
3799 return; 3899 return;
3800 }
3801 } 3900 }
3802 } 3901 }
3902 m_host.TaskInventory.LockItemsForRead(false);
3803 } 3903 }
3804 3904
3805 public void llSetText(string text, LSL_Vector color, double alpha) 3905 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3888,6 +3988,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3888 { 3988 {
3889 m_host.AddScriptLPS(1); 3989 m_host.AddScriptLPS(1);
3890 3990
3991 //Clone is thread safe
3891 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 3992 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3892 3993
3893 foreach (TaskInventoryItem item in itemDictionary.Values) 3994 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -3978,17 +4079,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3978 UUID soundId = UUID.Zero; 4079 UUID soundId = UUID.Zero;
3979 if (!UUID.TryParse(impact_sound, out soundId)) 4080 if (!UUID.TryParse(impact_sound, out soundId))
3980 { 4081 {
3981 lock (m_host.TaskInventory) 4082 m_host.TaskInventory.LockItemsForRead(true);
4083 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3982 { 4084 {
3983 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4085 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
3984 { 4086 {
3985 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4087 soundId = item.AssetID;
3986 { 4088 break;
3987 soundId = item.AssetID;
3988 break;
3989 }
3990 } 4089 }
3991 } 4090 }
4091 m_host.TaskInventory.LockItemsForRead(false);
3992 } 4092 }
3993 m_host.CollisionSound = soundId; 4093 m_host.CollisionSound = soundId;
3994 m_host.CollisionSoundVolume = (float)impact_volume; 4094 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4034,6 +4134,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4034 UUID partItemID; 4134 UUID partItemID;
4035 foreach (SceneObjectPart part in parts) 4135 foreach (SceneObjectPart part in parts)
4036 { 4136 {
4137 //Clone is thread safe
4037 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4138 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4038 4139
4039 foreach (TaskInventoryItem item in itemsDictionary.Values) 4140 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4241,17 +4342,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4241 4342
4242 m_host.AddScriptLPS(1); 4343 m_host.AddScriptLPS(1);
4243 4344
4244 lock (m_host.TaskInventory) 4345 m_host.TaskInventory.LockItemsForRead(true);
4346 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4245 { 4347 {
4246 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4348 if (item.Type == 10 && item.ItemID == m_itemID)
4247 { 4349 {
4248 if (item.Type == 10 && item.ItemID == m_itemID) 4350 result = item.Name!=null?item.Name:String.Empty;
4249 { 4351 break;
4250 result = item.Name!=null?item.Name:String.Empty;
4251 break;
4252 }
4253 } 4352 }
4254 } 4353 }
4354 m_host.TaskInventory.LockItemsForRead(false);
4255 4355
4256 return result; 4356 return result;
4257 } 4357 }
@@ -4509,23 +4609,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4509 { 4609 {
4510 m_host.AddScriptLPS(1); 4610 m_host.AddScriptLPS(1);
4511 4611
4512 lock (m_host.TaskInventory) 4612 m_host.TaskInventory.LockItemsForRead(true);
4613 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4513 { 4614 {
4514 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4615 if (inv.Value.Name == name)
4515 { 4616 {
4516 if (inv.Value.Name == name) 4617 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4517 { 4618 {
4518 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4619 m_host.TaskInventory.LockItemsForRead(false);
4519 { 4620 return inv.Value.AssetID.ToString();
4520 return inv.Value.AssetID.ToString(); 4621 }
4521 } 4622 else
4522 else 4623 {
4523 { 4624 m_host.TaskInventory.LockItemsForRead(false);
4524 return UUID.Zero.ToString(); 4625 return UUID.Zero.ToString();
4525 }
4526 } 4626 }
4527 } 4627 }
4528 } 4628 }
4629 m_host.TaskInventory.LockItemsForRead(false);
4529 4630
4530 return UUID.Zero.ToString(); 4631 return UUID.Zero.ToString();
4531 } 4632 }
@@ -6021,14 +6122,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6021 6122
6022 protected UUID GetTaskInventoryItem(string name) 6123 protected UUID GetTaskInventoryItem(string name)
6023 { 6124 {
6024 lock (m_host.TaskInventory) 6125 m_host.TaskInventory.LockItemsForRead(true);
6126 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6025 { 6127 {
6026 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6128 if (inv.Value.Name == name)
6027 { 6129 {
6028 if (inv.Value.Name == name) 6130 m_host.TaskInventory.LockItemsForRead(false);
6029 return inv.Key; 6131 return inv.Key;
6030 } 6132 }
6031 } 6133 }
6134 m_host.TaskInventory.LockItemsForRead(false);
6032 6135
6033 return UUID.Zero; 6136 return UUID.Zero;
6034 } 6137 }
@@ -6339,22 +6442,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6339 } 6442 }
6340 6443
6341 // copy the first script found with this inventory name 6444 // copy the first script found with this inventory name
6342 lock (m_host.TaskInventory) 6445 m_host.TaskInventory.LockItemsForRead(true);
6446 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6343 { 6447 {
6344 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6448 if (inv.Value.Name == name)
6345 { 6449 {
6346 if (inv.Value.Name == name) 6450 // make sure the object is a script
6451 if (10 == inv.Value.Type)
6347 { 6452 {
6348 // make sure the object is a script 6453 found = true;
6349 if (10 == inv.Value.Type) 6454 srcId = inv.Key;
6350 { 6455 break;
6351 found = true;
6352 srcId = inv.Key;
6353 break;
6354 }
6355 } 6456 }
6356 } 6457 }
6357 } 6458 }
6459 m_host.TaskInventory.LockItemsForRead(false);
6358 6460
6359 if (!found) 6461 if (!found)
6360 { 6462 {
@@ -6436,8 +6538,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6436 } 6538 }
6437 6539
6438 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6540 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6439 { 6541 {
6440 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6542 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6543 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6544 return shapeBlock;
6441 6545
6442 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6546 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6443 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6547 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6506,7 +6610,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6506 } 6610 }
6507 6611
6508 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6612 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6509 { 6613 {
6614 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6615 return;
6616
6510 ObjectShapePacket.ObjectDataBlock shapeBlock; 6617 ObjectShapePacket.ObjectDataBlock shapeBlock;
6511 6618
6512 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6619 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6554,7 +6661,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6554 } 6661 }
6555 6662
6556 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 6663 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6557 { 6664 {
6665 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6666 return;
6667
6558 ObjectShapePacket.ObjectDataBlock shapeBlock; 6668 ObjectShapePacket.ObjectDataBlock shapeBlock;
6559 6669
6560 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6670 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6595,7 +6705,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6595 } 6705 }
6596 6706
6597 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) 6707 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge)
6598 { 6708 {
6709 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6710 return;
6711
6599 ObjectShapePacket.ObjectDataBlock shapeBlock; 6712 ObjectShapePacket.ObjectDataBlock shapeBlock;
6600 6713
6601 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6714 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6715,7 +6828,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6715 } 6828 }
6716 6829
6717 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 6830 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6718 { 6831 {
6832 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6833 return;
6834
6719 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6835 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6720 UUID sculptId; 6836 UUID sculptId;
6721 6837
@@ -6749,14 +6865,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6749 } 6865 }
6750 6866
6751 public void llSetPrimitiveParams(LSL_List rules) 6867 public void llSetPrimitiveParams(LSL_List rules)
6752 { 6868 {
6753 m_host.AddScriptLPS(1); 6869 m_host.AddScriptLPS(1);
6754 SetPrimParams(m_host, rules); 6870 SetPrimParams(m_host, rules);
6755 } 6871 }
6756 6872
6757 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 6873 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6758 { 6874 {
6759 m_host.AddScriptLPS(1); 6875 m_host.AddScriptLPS(1);
6760 6876
6761 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6877 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6762 6878
@@ -6765,7 +6881,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6765 } 6881 }
6766 6882
6767 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 6883 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6768 { 6884 {
6885 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6886 return;
6887
6769 int idx = 0; 6888 int idx = 0;
6770 6889
6771 while (idx < rules.Length) 6890 while (idx < rules.Length)
@@ -8170,28 +8289,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8170 { 8289 {
8171 m_host.AddScriptLPS(1); 8290 m_host.AddScriptLPS(1);
8172 8291
8173 lock (m_host.TaskInventory) 8292 m_host.TaskInventory.LockItemsForRead(true);
8293 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8174 { 8294 {
8175 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8295 if (inv.Value.Name == item)
8176 { 8296 {
8177 if (inv.Value.Name == item) 8297 m_host.TaskInventory.LockItemsForRead(false);
8298 switch (mask)
8178 { 8299 {
8179 switch (mask) 8300 case 0:
8180 { 8301 return (int)inv.Value.BasePermissions;
8181 case 0: 8302 case 1:
8182 return (int)inv.Value.BasePermissions; 8303 return (int)inv.Value.CurrentPermissions;
8183 case 1: 8304 case 2:
8184 return (int)inv.Value.CurrentPermissions; 8305 return (int)inv.Value.GroupPermissions;
8185 case 2: 8306 case 3:
8186 return (int)inv.Value.GroupPermissions; 8307 return (int)inv.Value.EveryonePermissions;
8187 case 3: 8308 case 4:
8188 return (int)inv.Value.EveryonePermissions; 8309 return (int)inv.Value.NextPermissions;
8189 case 4:
8190 return (int)inv.Value.NextPermissions;
8191 }
8192 } 8310 }
8193 } 8311 }
8194 } 8312 }
8313 m_host.TaskInventory.LockItemsForRead(false);
8195 8314
8196 return -1; 8315 return -1;
8197 } 8316 }
@@ -8206,16 +8325,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8206 { 8325 {
8207 m_host.AddScriptLPS(1); 8326 m_host.AddScriptLPS(1);
8208 8327
8209 lock (m_host.TaskInventory) 8328 m_host.TaskInventory.LockItemsForRead(true);
8329 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8210 { 8330 {
8211 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8331 if (inv.Value.Name == item)
8212 { 8332 {
8213 if (inv.Value.Name == item) 8333 m_host.TaskInventory.LockItemsForRead(false);
8214 { 8334 return inv.Value.CreatorID.ToString();
8215 return inv.Value.CreatorID.ToString();
8216 }
8217 } 8335 }
8218 } 8336 }
8337 m_host.TaskInventory.LockItemsForRead(false);
8219 8338
8220 llSay(0, "No item name '" + item + "'"); 8339 llSay(0, "No item name '" + item + "'");
8221 8340
@@ -8739,16 +8858,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8739 { 8858 {
8740 m_host.AddScriptLPS(1); 8859 m_host.AddScriptLPS(1);
8741 8860
8742 lock (m_host.TaskInventory) 8861 m_host.TaskInventory.LockItemsForRead(true);
8862 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8743 { 8863 {
8744 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8864 if (inv.Value.Name == name)
8745 { 8865 {
8746 if (inv.Value.Name == name) 8866 m_host.TaskInventory.LockItemsForRead(false);
8747 { 8867 return inv.Value.Type;
8748 return inv.Value.Type;
8749 }
8750 } 8868 }
8751 } 8869 }
8870 m_host.TaskInventory.LockItemsForRead(false);
8752 8871
8753 return -1; 8872 return -1;
8754 } 8873 }
@@ -8779,17 +8898,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8779 if (invItemID == UUID.Zero) 8898 if (invItemID == UUID.Zero)
8780 return new LSL_Vector(); 8899 return new LSL_Vector();
8781 8900
8782 lock (m_host.TaskInventory) 8901 m_host.TaskInventory.LockItemsForRead(true);
8902 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8783 { 8903 {
8784 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 8904 m_host.TaskInventory.LockItemsForRead(false);
8785 return new LSL_Vector(); 8905 return new LSL_Vector();
8906 }
8786 8907
8787 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 8908 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8788 { 8909 {
8789 ShoutError("No permissions to track the camera"); 8910 ShoutError("No permissions to track the camera");
8790 return new LSL_Vector(); 8911 m_host.TaskInventory.LockItemsForRead(false);
8791 } 8912 return new LSL_Vector();
8792 } 8913 }
8914 m_host.TaskInventory.LockItemsForRead(false);
8793 8915
8794 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 8916 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8795 if (presence != null) 8917 if (presence != null)
@@ -8807,17 +8929,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8807 if (invItemID == UUID.Zero) 8929 if (invItemID == UUID.Zero)
8808 return new LSL_Rotation(); 8930 return new LSL_Rotation();
8809 8931
8810 lock (m_host.TaskInventory) 8932 m_host.TaskInventory.LockItemsForRead(true);
8933 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8811 { 8934 {
8812 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 8935 m_host.TaskInventory.LockItemsForRead(false);
8813 return new LSL_Rotation(); 8936 return new LSL_Rotation();
8814
8815 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8816 {
8817 ShoutError("No permissions to track the camera");
8818 return new LSL_Rotation();
8819 }
8820 } 8937 }
8938 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8939 {
8940 ShoutError("No permissions to track the camera");
8941 m_host.TaskInventory.LockItemsForRead(false);
8942 return new LSL_Rotation();
8943 }
8944 m_host.TaskInventory.LockItemsForRead(false);
8821 8945
8822 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 8946 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8823 if (presence != null) 8947 if (presence != null)
@@ -8967,14 +9091,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8967 if (objectID == UUID.Zero) return; 9091 if (objectID == UUID.Zero) return;
8968 9092
8969 UUID agentID; 9093 UUID agentID;
8970 lock (m_host.TaskInventory) 9094 m_host.TaskInventory.LockItemsForRead(true);
8971 { 9095 // we need the permission first, to know which avatar we want to set the camera for
8972 // we need the permission first, to know which avatar we want to set the camera for 9096 agentID = m_host.TaskInventory[invItemID].PermsGranter;
8973 agentID = m_host.TaskInventory[invItemID].PermsGranter;
8974 9097
8975 if (agentID == UUID.Zero) return; 9098 if (agentID == UUID.Zero)
8976 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9099 {
9100 m_host.TaskInventory.LockItemsForRead(false);
9101 return;
9102 }
9103 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9104 {
9105 m_host.TaskInventory.LockItemsForRead(false);
9106 return;
8977 } 9107 }
9108 m_host.TaskInventory.LockItemsForRead(false);
8978 9109
8979 ScenePresence presence = World.GetScenePresence(agentID); 9110 ScenePresence presence = World.GetScenePresence(agentID);
8980 9111
@@ -9024,12 +9155,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9024 9155
9025 // we need the permission first, to know which avatar we want to clear the camera for 9156 // we need the permission first, to know which avatar we want to clear the camera for
9026 UUID agentID; 9157 UUID agentID;
9027 lock (m_host.TaskInventory) 9158 m_host.TaskInventory.LockItemsForRead(true);
9159 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9160 if (agentID == UUID.Zero)
9028 { 9161 {
9029 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9162 m_host.TaskInventory.LockItemsForRead(false);
9030 if (agentID == UUID.Zero) return; 9163 return;
9031 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9164 }
9165 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9166 {
9167 m_host.TaskInventory.LockItemsForRead(false);
9168 return;
9032 } 9169 }
9170 m_host.TaskInventory.LockItemsForRead(false);
9033 9171
9034 ScenePresence presence = World.GetScenePresence(agentID); 9172 ScenePresence presence = World.GetScenePresence(agentID);
9035 9173
@@ -9486,15 +9624,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9486 9624
9487 internal UUID ScriptByName(string name) 9625 internal UUID ScriptByName(string name)
9488 { 9626 {
9489 lock (m_host.TaskInventory) 9627 m_host.TaskInventory.LockItemsForRead(true);
9628
9629 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
9490 { 9630 {
9491 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 9631 if (item.Type == 10 && item.Name == name)
9492 { 9632 {
9493 if (item.Type == 10 && item.Name == name) 9633 m_host.TaskInventory.LockItemsForRead(false);
9494 return item.ItemID; 9634 return item.ItemID;
9495 } 9635 }
9496 } 9636 }
9497 9637
9638 m_host.TaskInventory.LockItemsForRead(false);
9639
9498 return UUID.Zero; 9640 return UUID.Zero;
9499 } 9641 }
9500 9642
@@ -9535,6 +9677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9535 { 9677 {
9536 m_host.AddScriptLPS(1); 9678 m_host.AddScriptLPS(1);
9537 9679
9680 //Clone is thread safe
9538 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9681 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9539 9682
9540 UUID assetID = UUID.Zero; 9683 UUID assetID = UUID.Zero;
@@ -9597,6 +9740,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9597 { 9740 {
9598 m_host.AddScriptLPS(1); 9741 m_host.AddScriptLPS(1);
9599 9742
9743 //Clone is thread safe
9600 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9744 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9601 9745
9602 UUID assetID = UUID.Zero; 9746 UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 9c7604b..bd09534 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
728 if (target != null) 728 if (target != null)
729 { 729 {
730 UUID animID=UUID.Zero; 730 UUID animID=UUID.Zero;
731 lock (m_host.TaskInventory) 731 m_host.TaskInventory.LockItemsForRead(true);
732 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
732 { 733 {
733 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 734 if (inv.Value.Name == animation)
734 { 735 {
735 if (inv.Value.Name == animation) 736 if (inv.Value.Type == (int)AssetType.Animation)
736 { 737 animID = inv.Value.AssetID;
737 if (inv.Value.Type == (int)AssetType.Animation) 738 continue;
738 animID = inv.Value.AssetID;
739 continue;
740 }
741 } 739 }
742 } 740 }
741 m_host.TaskInventory.LockItemsForRead(false);
743 if (animID == UUID.Zero) 742 if (animID == UUID.Zero)
744 target.Animator.AddAnimation(animation, m_host.UUID); 743 target.Animator.AddAnimation(animation, m_host.UUID);
745 else 744 else
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
761 if (target != null) 760 if (target != null)
762 { 761 {
763 UUID animID=UUID.Zero; 762 UUID animID=UUID.Zero;
764 lock (m_host.TaskInventory) 763 m_host.TaskInventory.LockItemsForRead(true);
764 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
765 { 765 {
766 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 766 if (inv.Value.Name == animation)
767 { 767 {
768 if (inv.Value.Name == animation) 768 if (inv.Value.Type == (int)AssetType.Animation)
769 { 769 animID = inv.Value.AssetID;
770 if (inv.Value.Type == (int)AssetType.Animation) 770 continue;
771 animID = inv.Value.AssetID;
772 continue;
773 }
774 } 771 }
775 } 772 }
773 m_host.TaskInventory.LockItemsForRead(false);
776 774
777 if (animID == UUID.Zero) 775 if (animID == UUID.Zero)
778 target.Animator.RemoveAnimation(animation); 776 target.Animator.RemoveAnimation(animation);
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1541 1539
1542 if (!UUID.TryParse(name, out assetID)) 1540 if (!UUID.TryParse(name, out assetID))
1543 { 1541 {
1542 m_host.TaskInventory.LockItemsForRead(true);
1544 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1543 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1545 { 1544 {
1546 if (item.Type == 7 && item.Name == name) 1545 if (item.Type == 7 && item.Name == name)
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1548 assetID = item.AssetID; 1547 assetID = item.AssetID;
1549 } 1548 }
1550 } 1549 }
1550 m_host.TaskInventory.LockItemsForRead(false);
1551 } 1551 }
1552 1552
1553 if (assetID == UUID.Zero) 1553 if (assetID == UUID.Zero)
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1594 1594
1595 if (!UUID.TryParse(name, out assetID)) 1595 if (!UUID.TryParse(name, out assetID))
1596 { 1596 {
1597 m_host.TaskInventory.LockItemsForRead(true);
1597 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1598 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1598 { 1599 {
1599 if (item.Type == 7 && item.Name == name) 1600 if (item.Type == 7 && item.Name == name)
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1601 assetID = item.AssetID; 1602 assetID = item.AssetID;
1602 } 1603 }
1603 } 1604 }
1605 m_host.TaskInventory.LockItemsForRead(false);
1604 } 1606 }
1605 1607
1606 if (assetID == UUID.Zero) 1608 if (assetID == UUID.Zero)
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1651 1653
1652 if (!UUID.TryParse(name, out assetID)) 1654 if (!UUID.TryParse(name, out assetID))
1653 { 1655 {
1656 m_host.TaskInventory.LockItemsForRead(true);
1654 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1657 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1655 { 1658 {
1656 if (item.Type == 7 && item.Name == name) 1659 if (item.Type == 7 && item.Name == name)
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1658 assetID = item.AssetID; 1661 assetID = item.AssetID;
1659 } 1662 }
1660 } 1663 }
1664 m_host.TaskInventory.LockItemsForRead(false);
1661 } 1665 }
1662 1666
1663 if (assetID == UUID.Zero) 1667 if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
new file mode 100644
index 0000000..ef990a1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -0,0 +1,21 @@
1using System.Collections;
2using OpenSim.Region.ScriptEngine.Interfaces;
3
4using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
5using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
6using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
7using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
8using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
9using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
10using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
11
12namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
13{
14 public interface ICM_Api
15 {
16 // Windlight Functions
17 LSL_List cmGetWindlightScene(LSL_List rules);
18 int cmSetWindlightScene(LSL_List rules);
19 int cmSetWindlightSceneTargeted(LSL_List rules, key target);
20 }
21}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 580c354..d943b59 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
80 // Avatar Info Commands 80 // Avatar Info Commands
81 string osGetAgentIP(string agent); 81 string osGetAgentIP(string agent);
82 LSL_List osGetAgents(); 82 LSL_List osGetAgents();
83 83
84 // Teleport commands 84 // Teleport commands
85 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 85 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
86 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 86 void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
new file mode 100644
index 0000000..7b67fa3
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
@@ -0,0 +1,76 @@
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 vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
30using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
31using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
32
33namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
34{
35 public partial class ScriptBaseClass
36 {
37 // Constants for cmWindlight*
38 public const int WL_WATER_COLOR = 0;
39 public const int WL_WATER_FOG_DENSITY_EXPONENT = 1;
40 public const int WL_UNDERWATER_FOG_MODIFIER = 2;
41 public const int WL_REFLECTION_WAVELET_SCALE = 3;
42 public const int WL_FRESNEL_SCALE = 4;
43 public const int WL_FRESNEL_OFFSET = 5;
44 public const int WL_REFRACT_SCALE_ABOVE = 6;
45 public const int WL_REFRACT_SCALE_BELOW = 7;
46 public const int WL_BLUR_MULTIPLIER = 8;
47 public const int WL_BIG_WAVE_DIRECTION = 9;
48 public const int WL_LITTLE_WAVE_DIRECTION = 10;
49 public const int WL_NORMAL_MAP_TEXTURE = 11;
50 public const int WL_HORIZON = 12;
51 public const int WL_HAZE_HORIZON = 13;
52 public const int WL_BLUE_DENSITY = 14;
53 public const int WL_HAZE_DENSITY = 15;
54 public const int WL_DENSITY_MULTIPLIER = 16;
55 public const int WL_DISTANCE_MULTIPLIER = 17;
56 public const int WL_MAX_ALTITUDE = 18;
57 public const int WL_SUN_MOON_COLOR = 19;
58 public const int WL_AMBIENT = 20;
59 public const int WL_EAST_ANGLE = 21;
60 public const int WL_SUN_GLOW_FOCUS = 22;
61 public const int WL_SUN_GLOW_SIZE = 23;
62 public const int WL_SCENE_GAMMA = 24;
63 public const int WL_STAR_BRIGHTNESS = 25;
64 public const int WL_CLOUD_COLOR = 26;
65 public const int WL_CLOUD_XY_DENSITY = 27;
66 public const int WL_CLOUD_COVERAGE = 28;
67 public const int WL_CLOUD_SCALE = 29;
68 public const int WL_CLOUD_DETAIL_XY_DENSITY = 30;
69 public const int WL_CLOUD_SCROLL_X = 31;
70 public const int WL_CLOUD_SCROLL_Y = 32;
71 public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
72 public const int WL_CLOUD_SCROLL_X_LOCK = 34;
73 public const int WL_DRAW_CLASSIC_CLOUDS = 35;
74
75 }
76}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
new file mode 100644
index 0000000..5bc3a88
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -0,0 +1,76 @@
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.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
38using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
39using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
40using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
41using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
42using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
43using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
44using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
45using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
46
47namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
48{
49 public partial class ScriptBaseClass : MarshalByRefObject
50 {
51 public ICM_Api m_CM_Functions;
52
53 public void ApiTypeCM(IScriptApi api)
54 {
55 if (!(api is ICM_Api))
56 return;
57
58 m_CM_Functions = (ICM_Api)api;
59 }
60
61 public LSL_List cmGetWindlightScene(LSL_List rules)
62 {
63 return m_CM_Functions.cmGetWindlightScene(rules);
64 }
65
66 public int cmSetWindlightScene(LSL_List rules)
67 {
68 return m_CM_Functions.cmSetWindlightScene(rules);
69 }
70
71 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
72 {
73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
74 }
75 }
76}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 7f67599..15e0408 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Diagnostics; //for [DebuggerNonUserCode]
30using System.Reflection; 31using System.Reflection;
31using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
32using OpenSim.Region.ScriptEngine.Shared; 33using OpenSim.Region.ScriptEngine.Shared;
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
131 return (eventFlags); 132 return (eventFlags);
132 } 133 }
133 134
135 [DebuggerNonUserCode]
134 public void ExecuteEvent(string state, string FunctionName, object[] args) 136 public void ExecuteEvent(string state, string FunctionName, object[] args)
135 { 137 {
136 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 138 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
index 98bbc68..23138ef 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp
@@ -17,6 +17,8 @@
17 <excludeFiles /> 17 <excludeFiles />
18 </DeploymentInformation> 18 </DeploymentInformation>
19 <Contents> 19 <Contents>
20 <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
20 <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 22 <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
21 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 23 <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
22 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> 24 <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
index 121159c..a44abb0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs
@@ -33,6 +33,7 @@ using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using System.Collections; 34using System.Collections;
35using System.Collections.Generic; 35using System.Collections.Generic;
36using System.Diagnostics; //for [DebuggerNonUserCode]
36using OpenSim.Region.ScriptEngine.Interfaces; 37using OpenSim.Region.ScriptEngine.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared; 38using OpenSim.Region.ScriptEngine.Shared;
38using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; 39using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
90 return (int)m_Executor.GetStateEventFlags(state); 91 return (int)m_Executor.GetStateEventFlags(state);
91 } 92 }
92 93
94 [DebuggerNonUserCode]
93 public void ExecuteEvent(string state, string FunctionName, object[] args) 95 public void ExecuteEvent(string state, string FunctionName, object[] args)
94 { 96 {
95 m_Executor.ExecuteEvent(state, FunctionName, args); 97 m_Executor.ExecuteEvent(state, FunctionName, args);