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.cs477
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs963
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs36
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs32
-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.cs77
-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
11 files changed, 1349 insertions, 341 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..99973b4
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,477 @@
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_SUN_MOON_POSITION:
248 idx++;
249 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
250 break;
251 case (int)ScriptBaseClass.WL_AMBIENT:
252 idx++;
253 iQ = rules.GetQuaternionItem(idx);
254 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
255 break;
256 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
257 idx++;
258 iV = rules.GetVector3Item(idx);
259 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
260 break;
261 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
262 idx++;
263 iQ = rules.GetQuaternionItem(idx);
264 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
265 break;
266 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
267 idx++;
268 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
269 break;
270 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
271 idx++;
272 iQ = rules.GetQuaternionItem(idx);
273 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
274 break;
275 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
276 idx++;
277 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
278 break;
279 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
280 idx++;
281 iV = rules.GetVector3Item(idx);
282 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
283 break;
284 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
285 idx++;
286 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
287 break;
288 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
289 idx++;
290 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
291 break;
292 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
293 idx++;
294 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
295 break;
296 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
297 idx++;
298 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
299 break;
300 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
301 idx++;
302 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
303 break;
304 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
305 idx++;
306 iV = rules.GetVector3Item(idx);
307 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
308 break;
309 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
310 idx++;
311 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
312 break;
313 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
314 idx++;
315 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
316 break;
317 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
318 idx++;
319 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
320 break;
321 case (int)ScriptBaseClass.WL_EAST_ANGLE:
322 idx++;
323 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
324 break;
325 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
326 idx++;
327 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
328 break;
329 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
330 idx++;
331 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
332 break;
333 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
334 idx++;
335 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
336 break;
337 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
338 idx++;
339 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
340 break;
341 case (int)ScriptBaseClass.WL_HORIZON:
342 idx++;
343 iQ = rules.GetQuaternionItem(idx);
344 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
345 break;
346 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
347 idx++;
348 iV = rules.GetVector3Item(idx);
349 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
350 break;
351 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
352 idx++;
353 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
354 break;
355 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
356 idx++;
357 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
358 break;
359 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
360 idx++;
361 iV = rules.GetVector3Item(idx);
362 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
363 break;
364 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
365 idx++;
366 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
367 break;
368 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
369 idx++;
370 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
371 break;
372 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
373 idx++;
374 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
375 break;
376 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
377 idx++;
378 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
379 break;
380 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
381 idx++;
382 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
383 break;
384 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
385 idx++;
386 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
387 break;
388 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
389 idx++;
390 iQ = rules.GetQuaternionItem(idx);
391 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
392 break;
393 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
394 idx++;
395 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
396 break;
397 case (int)ScriptBaseClass.WL_WATER_COLOR:
398 idx++;
399 iV = rules.GetVector3Item(idx);
400 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
401 break;
402 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
403 idx++;
404 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
405 break;
406 }
407 idx++;
408 }
409 return wl;
410 }
411 /// <summary>
412 /// Set the current Windlight scene
413 /// </summary>
414 /// <param name="rules"></param>
415 /// <returns>success: true or false</returns>
416 public int cmSetWindlightScene(LSL_List rules)
417 {
418 if (!m_CMFunctionsEnabled)
419 {
420 CMShoutError("Careminster functions are not enabled.");
421 return 0;
422 }
423 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
424 {
425 CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
426 return 0;
427 }
428 int success = 0;
429 m_host.AddScriptLPS(1);
430 if (Meta7WindlightModule.EnableWindlight)
431 {
432 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
433 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
434 success = 1;
435 }
436 else
437 {
438 CMShoutError("Windlight module is disabled");
439 return 0;
440 }
441 return success;
442 }
443 /// <summary>
444 /// Set the current Windlight scene to a target avatar
445 /// </summary>
446 /// <param name="rules"></param>
447 /// <returns>success: true or false</returns>
448 public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
449 {
450 if (!m_CMFunctionsEnabled)
451 {
452 CMShoutError("Careminster functions are not enabled.");
453 return 0;
454 }
455 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
456 {
457 CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
458 return 0;
459 }
460 int success = 0;
461 m_host.AddScriptLPS(1);
462 if (Meta7WindlightModule.EnableWindlight)
463 {
464 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
465 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
466 success = 1;
467 }
468 else
469 {
470 CMShoutError("Windlight module is disabled");
471 return 0;
472 }
473 return success;
474 }
475
476 }
477}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dc4249c..3f9c026 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;
@@ -152,6 +153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
152 get { return m_ScriptEngine.World; } 153 get { return m_ScriptEngine.World; }
153 } 154 }
154 155
156 [DebuggerNonUserCode]
155 public void state(string newState) 157 public void state(string newState)
156 { 158 {
157 m_ScriptEngine.SetState(m_itemID, newState); 159 m_ScriptEngine.SetState(m_itemID, newState);
@@ -161,6 +163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
161 /// Reset the named script. The script must be present 163 /// Reset the named script. The script must be present
162 /// in the same prim. 164 /// in the same prim.
163 /// </summary> 165 /// </summary>
166 [DebuggerNonUserCode]
164 public void llResetScript() 167 public void llResetScript()
165 { 168 {
166 m_host.AddScriptLPS(1); 169 m_host.AddScriptLPS(1);
@@ -219,7 +222,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
219 222
220 public List<SceneObjectPart> GetLinkParts(int linkType) 223 public List<SceneObjectPart> GetLinkParts(int linkType)
221 { 224 {
222 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 225 List<SceneObjectPart> ret = new List<SceneObjectPart>();
226 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
227 return ret;
223 ret.Add(m_host); 228 ret.Add(m_host);
224 229
225 switch (linkType) 230 switch (linkType)
@@ -273,40 +278,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
273 protected UUID InventorySelf() 278 protected UUID InventorySelf()
274 { 279 {
275 UUID invItemID = new UUID(); 280 UUID invItemID = new UUID();
276 281 bool unlock = false;
277 lock (m_host.TaskInventory) 282 if (!m_host.TaskInventory.IsReadLockedByMe())
278 { 283 {
279 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 284 m_host.TaskInventory.LockItemsForRead(true);
285 unlock = true;
286 }
287 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
288 {
289 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
280 { 290 {
281 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 291 invItemID = inv.Key;
282 { 292 break;
283 invItemID = inv.Key;
284 break;
285 }
286 } 293 }
287 } 294 }
288 295 if (unlock)
296 {
297 m_host.TaskInventory.LockItemsForRead(false);
298 }
289 return invItemID; 299 return invItemID;
290 } 300 }
291 301
292 protected UUID InventoryKey(string name, int type) 302 protected UUID InventoryKey(string name, int type)
293 { 303 {
294 m_host.AddScriptLPS(1); 304 m_host.AddScriptLPS(1);
295 305 m_host.TaskInventory.LockItemsForRead(true);
296 lock (m_host.TaskInventory) 306
307 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
297 { 308 {
298 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 309 if (inv.Value.Name == name)
299 { 310 {
300 if (inv.Value.Name == name) 311 m_host.TaskInventory.LockItemsForRead(false);
312
313 if (inv.Value.Type != type)
301 { 314 {
302 if (inv.Value.Type != type) 315 return UUID.Zero;
303 return UUID.Zero;
304
305 return inv.Value.AssetID;
306 } 316 }
317
318 return inv.Value.AssetID;
307 } 319 }
308 } 320 }
309 321
322 m_host.TaskInventory.LockItemsForRead(false);
310 return UUID.Zero; 323 return UUID.Zero;
311 } 324 }
312 325
@@ -314,17 +327,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
314 { 327 {
315 m_host.AddScriptLPS(1); 328 m_host.AddScriptLPS(1);
316 329
317 lock (m_host.TaskInventory) 330
331 m_host.TaskInventory.LockItemsForRead(true);
332
333 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
318 { 334 {
319 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 335 if (inv.Value.Name == name)
320 { 336 {
321 if (inv.Value.Name == name) 337 m_host.TaskInventory.LockItemsForRead(false);
322 { 338 return inv.Value.AssetID;
323 return inv.Value.AssetID;
324 }
325 } 339 }
326 } 340 }
327 341
342 m_host.TaskInventory.LockItemsForRead(false);
343
344
328 return UUID.Zero; 345 return UUID.Zero;
329 } 346 }
330 347
@@ -706,6 +723,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
706 { 723 {
707 //A and B should both be normalized 724 //A and B should both be normalized
708 m_host.AddScriptLPS(1); 725 m_host.AddScriptLPS(1);
726 /* This method is more accurate than the SL one, and thus causes problems
727 for scripts that deal with the SL inaccuracy around 180-degrees -.- .._.
728
709 double dotProduct = LSL_Vector.Dot(a, b); 729 double dotProduct = LSL_Vector.Dot(a, b);
710 LSL_Vector crossProduct = LSL_Vector.Cross(a, b); 730 LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
711 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); 731 double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b);
@@ -722,8 +742,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
722 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); 742 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
723 743
724 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); 744 return new LSL_Rotation((float)x, (float)y, (float)z, (float)w);
725 } 745 */
726 746
747 // This method mimics the 180 errors found in SL
748 // See www.euclideanspace.com... angleBetween
749 LSL_Vector vec_a = a;
750 LSL_Vector vec_b = b;
751
752 // Eliminate zero length
753 LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a);
754 LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b);
755 if (vec_a_mag < 0.00001 ||
756 vec_b_mag < 0.00001)
757 {
758 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
759 }
760
761 // Normalize
762 vec_a = llVecNorm(vec_a);
763 vec_b = llVecNorm(vec_b);
764
765 // Calculate axis and rotation angle
766 LSL_Vector axis = vec_a % vec_b;
767 LSL_Float cos_theta = vec_a * vec_b;
768
769 // Check if parallel
770 if (cos_theta > 0.99999)
771 {
772 return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
773 }
774
775 // Check if anti-parallel
776 else if (cos_theta < -0.99999)
777 {
778 LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a);
779 if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0);
780 return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0);
781 }
782 else // other rotation
783 {
784 LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f;
785 axis = llVecNorm(axis);
786 double x, y, z, s, t;
787 s = Math.Cos(theta);
788 t = Math.Sin(theta);
789 x = axis.x * t;
790 y = axis.y * t;
791 z = axis.z * t;
792 return new LSL_Rotation(x,y,z,s);
793 }
794 }
795
727 public void llWhisper(int channelID, string text) 796 public void llWhisper(int channelID, string text)
728 { 797 {
729 m_host.AddScriptLPS(1); 798 m_host.AddScriptLPS(1);
@@ -1050,7 +1119,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1050 public virtual void llDie() 1119 public virtual void llDie()
1051 { 1120 {
1052 m_host.AddScriptLPS(1); 1121 m_host.AddScriptLPS(1);
1053 throw new SelfDeleteException(); 1122 if (!m_host.IsAttachment) throw new SelfDeleteException();
1054 } 1123 }
1055 1124
1056 public LSL_Float llGround(LSL_Vector offset) 1125 public LSL_Float llGround(LSL_Vector offset)
@@ -1122,7 +1191,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1122 } 1191 }
1123 1192
1124 public void llSetStatus(int status, int value) 1193 public void llSetStatus(int status, int value)
1125 { 1194 {
1195 if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted)
1196 return;
1126 m_host.AddScriptLPS(1); 1197 m_host.AddScriptLPS(1);
1127 1198
1128 int statusrotationaxis = 0; 1199 int statusrotationaxis = 0;
@@ -1297,7 +1368,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1297 } 1368 }
1298 1369
1299 protected void SetScale(SceneObjectPart part, LSL_Vector scale) 1370 protected void SetScale(SceneObjectPart part, LSL_Vector scale)
1300 { 1371 {
1301 // TODO: this needs to trigger a persistance save as well 1372 // TODO: this needs to trigger a persistance save as well
1302 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1373 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1303 return; 1374 return;
@@ -1352,6 +1423,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1352 { 1423 {
1353 m_host.AddScriptLPS(1); 1424 m_host.AddScriptLPS(1);
1354 1425
1426 SetColor(m_host, color, face);
1427 }
1428
1429 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1430 {
1431 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1432 return;
1433
1434 Primitive.TextureEntry tex = part.Shape.Textures;
1435 Color4 texcolor;
1436 if (face >= 0 && face < GetNumberOfSides(part))
1437 {
1438 texcolor = tex.CreateFace((uint)face).RGBA;
1439 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1440 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1441 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1442 tex.FaceTextures[face].RGBA = texcolor;
1443 part.UpdateTexture(tex);
1444 return;
1445 }
1446 else if (face == ScriptBaseClass.ALL_SIDES)
1447 {
1448 for (uint i = 0; i < GetNumberOfSides(part); i++)
1449 {
1450 if (tex.FaceTextures[i] != null)
1451 {
1452 texcolor = tex.FaceTextures[i].RGBA;
1453 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1454 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1455 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1456 tex.FaceTextures[i].RGBA = texcolor;
1457 }
1458 texcolor = tex.DefaultTexture.RGBA;
1459 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1460 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1461 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1462 tex.DefaultTexture.RGBA = texcolor;
1463 }
1464 part.UpdateTexture(tex);
1465 return;
1466 }
1467
1355 if (face == ScriptBaseClass.ALL_SIDES) 1468 if (face == ScriptBaseClass.ALL_SIDES)
1356 face = SceneObjectPart.ALL_SIDES; 1469 face = SceneObjectPart.ALL_SIDES;
1357 1470
@@ -1359,7 +1472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1359 } 1472 }
1360 1473
1361 public void SetTexGen(SceneObjectPart part, int face,int style) 1474 public void SetTexGen(SceneObjectPart part, int face,int style)
1362 { 1475 {
1476 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1477 return;
1478
1363 Primitive.TextureEntry tex = part.Shape.Textures; 1479 Primitive.TextureEntry tex = part.Shape.Textures;
1364 MappingType textype; 1480 MappingType textype;
1365 textype = MappingType.Default; 1481 textype = MappingType.Default;
@@ -1389,7 +1505,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1389 } 1505 }
1390 1506
1391 public void SetGlow(SceneObjectPart part, int face, float glow) 1507 public void SetGlow(SceneObjectPart part, int face, float glow)
1392 { 1508 {
1509 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1510 return;
1511
1393 Primitive.TextureEntry tex = part.Shape.Textures; 1512 Primitive.TextureEntry tex = part.Shape.Textures;
1394 if (face >= 0 && face < GetNumberOfSides(part)) 1513 if (face >= 0 && face < GetNumberOfSides(part))
1395 { 1514 {
@@ -1414,7 +1533,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1414 } 1533 }
1415 1534
1416 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) 1535 public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump)
1417 { 1536 {
1537 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1538 return;
1418 1539
1419 Shininess sval = new Shininess(); 1540 Shininess sval = new Shininess();
1420 1541
@@ -1464,7 +1585,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1464 } 1585 }
1465 1586
1466 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1587 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1467 { 1588 {
1589 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1590 return;
1591
1468 Primitive.TextureEntry tex = part.Shape.Textures; 1592 Primitive.TextureEntry tex = part.Shape.Textures;
1469 if (face >= 0 && face < GetNumberOfSides(part)) 1593 if (face >= 0 && face < GetNumberOfSides(part))
1470 { 1594 {
@@ -1531,7 +1655,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1531 } 1655 }
1532 1656
1533 protected void SetAlpha(SceneObjectPart part, double alpha, int face) 1657 protected void SetAlpha(SceneObjectPart part, double alpha, int face)
1534 { 1658 {
1659 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1660 return;
1661
1535 Primitive.TextureEntry tex = part.Shape.Textures; 1662 Primitive.TextureEntry tex = part.Shape.Textures;
1536 Color4 texcolor; 1663 Color4 texcolor;
1537 if (face >= 0 && face < GetNumberOfSides(part)) 1664 if (face >= 0 && face < GetNumberOfSides(part))
@@ -1576,8 +1703,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1576 /// <param name="Force"></param> 1703 /// <param name="Force"></param>
1577 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, 1704 protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
1578 float wind, float tension, LSL_Vector Force) 1705 float wind, float tension, LSL_Vector Force)
1579 { 1706 {
1580 if (part == null) 1707 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1581 return; 1708 return;
1582 1709
1583 if (flexi) 1710 if (flexi)
@@ -1611,8 +1738,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1611 /// <param name="radius"></param> 1738 /// <param name="radius"></param>
1612 /// <param name="falloff"></param> 1739 /// <param name="falloff"></param>
1613 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) 1740 protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff)
1614 { 1741 {
1615 if (part == null) 1742 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1616 return; 1743 return;
1617 1744
1618 if (light) 1745 if (light)
@@ -1697,7 +1824,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1697 } 1824 }
1698 1825
1699 protected void SetTexture(SceneObjectPart part, string texture, int face) 1826 protected void SetTexture(SceneObjectPart part, string texture, int face)
1700 { 1827 {
1828 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1829 return;
1830
1701 UUID textureID=new UUID(); 1831 UUID textureID=new UUID();
1702 1832
1703 if (!UUID.TryParse(texture, out textureID)) 1833 if (!UUID.TryParse(texture, out textureID))
@@ -1742,7 +1872,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1742 } 1872 }
1743 1873
1744 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1874 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1745 { 1875 {
1876 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1877 return;
1878
1746 Primitive.TextureEntry tex = part.Shape.Textures; 1879 Primitive.TextureEntry tex = part.Shape.Textures;
1747 if (face >= 0 && face < GetNumberOfSides(part)) 1880 if (face >= 0 && face < GetNumberOfSides(part))
1748 { 1881 {
@@ -1778,7 +1911,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1778 } 1911 }
1779 1912
1780 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1913 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1781 { 1914 {
1915 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1916 return;
1917
1782 Primitive.TextureEntry tex = part.Shape.Textures; 1918 Primitive.TextureEntry tex = part.Shape.Textures;
1783 if (face >= 0 && face < GetNumberOfSides(part)) 1919 if (face >= 0 && face < GetNumberOfSides(part))
1784 { 1920 {
@@ -1814,7 +1950,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1814 } 1950 }
1815 1951
1816 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 1952 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1817 { 1953 {
1954 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1955 return;
1956
1818 Primitive.TextureEntry tex = part.Shape.Textures; 1957 Primitive.TextureEntry tex = part.Shape.Textures;
1819 if (face >= 0 && face < GetNumberOfSides(part)) 1958 if (face >= 0 && face < GetNumberOfSides(part))
1820 { 1959 {
@@ -1884,7 +2023,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1884 } 2023 }
1885 2024
1886 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) 2025 protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
1887 { 2026 {
2027 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2028 return;
2029
1888 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) 2030 // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
1889 LSL_Vector currentPos = llGetLocalPos(); 2031 LSL_Vector currentPos = llGetLocalPos();
1890 2032
@@ -1978,7 +2120,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1978 } 2120 }
1979 2121
1980 protected void SetRot(SceneObjectPart part, Quaternion rot) 2122 protected void SetRot(SceneObjectPart part, Quaternion rot)
1981 { 2123 {
2124 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2125 return;
2126
1982 part.UpdateRotation(rot); 2127 part.UpdateRotation(rot);
1983 // Update rotation does not move the object in the physics scene if it's a linkset. 2128 // Update rotation does not move the object in the physics scene if it's a linkset.
1984 2129
@@ -2598,12 +2743,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2598 2743
2599 m_host.AddScriptLPS(1); 2744 m_host.AddScriptLPS(1);
2600 2745
2746 m_host.TaskInventory.LockItemsForRead(true);
2601 TaskInventoryItem item = m_host.TaskInventory[invItemID]; 2747 TaskInventoryItem item = m_host.TaskInventory[invItemID];
2602 2748 m_host.TaskInventory.LockItemsForRead(false);
2603 lock (m_host.TaskInventory)
2604 {
2605 item = m_host.TaskInventory[invItemID];
2606 }
2607 2749
2608 if (item.PermsGranter == UUID.Zero) 2750 if (item.PermsGranter == UUID.Zero)
2609 return 0; 2751 return 0;
@@ -2678,6 +2820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2678 if (dist > m_ScriptDistanceFactor * 10.0f) 2820 if (dist > m_ScriptDistanceFactor * 10.0f)
2679 return; 2821 return;
2680 2822
2823 //Clone is thread-safe
2681 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 2824 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
2682 2825
2683 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 2826 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@@ -2762,6 +2905,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2762 // Orient the object to the angle calculated 2905 // Orient the object to the angle calculated
2763 //llSetRot(rot); 2906 //llSetRot(rot);
2764 } 2907 }
2908
2909 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
2910 {
2911 m_host.AddScriptLPS(1);
2912// NotImplemented("llRotLookAt");
2913 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
2914
2915 }
2765 2916
2766 public void llStopLookAt() 2917 public void llStopLookAt()
2767 { 2918 {
@@ -2809,13 +2960,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2809 { 2960 {
2810 TaskInventoryItem item; 2961 TaskInventoryItem item;
2811 2962
2812 lock (m_host.TaskInventory) 2963 m_host.TaskInventory.LockItemsForRead(true);
2964 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2813 { 2965 {
2814 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2966 m_host.TaskInventory.LockItemsForRead(false);
2815 return; 2967 return;
2816 else 2968 }
2817 item = m_host.TaskInventory[InventorySelf()]; 2969 else
2970 {
2971 item = m_host.TaskInventory[InventorySelf()];
2818 } 2972 }
2973 m_host.TaskInventory.LockItemsForRead(false);
2819 2974
2820 if (item.PermsGranter != UUID.Zero) 2975 if (item.PermsGranter != UUID.Zero)
2821 { 2976 {
@@ -2837,13 +2992,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2837 { 2992 {
2838 TaskInventoryItem item; 2993 TaskInventoryItem item;
2839 2994
2995 m_host.TaskInventory.LockItemsForRead(true);
2840 lock (m_host.TaskInventory) 2996 lock (m_host.TaskInventory)
2841 { 2997 {
2998
2842 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 2999 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3000 {
3001 m_host.TaskInventory.LockItemsForRead(false);
2843 return; 3002 return;
3003 }
2844 else 3004 else
3005 {
2845 item = m_host.TaskInventory[InventorySelf()]; 3006 item = m_host.TaskInventory[InventorySelf()];
3007 }
2846 } 3008 }
3009 m_host.TaskInventory.LockItemsForRead(false);
2847 3010
2848 m_host.AddScriptLPS(1); 3011 m_host.AddScriptLPS(1);
2849 3012
@@ -2880,13 +3043,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2880 3043
2881 TaskInventoryItem item; 3044 TaskInventoryItem item;
2882 3045
2883 lock (m_host.TaskInventory) 3046 m_host.TaskInventory.LockItemsForRead(true);
3047
3048 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2884 { 3049 {
2885 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3050 m_host.TaskInventory.LockItemsForRead(false);
2886 return; 3051 return;
2887 else
2888 item = m_host.TaskInventory[InventorySelf()];
2889 } 3052 }
3053 else
3054 {
3055 item = m_host.TaskInventory[InventorySelf()];
3056 }
3057
3058 m_host.TaskInventory.LockItemsForRead(false);
2890 3059
2891 if (item.PermsGranter != m_host.OwnerID) 3060 if (item.PermsGranter != m_host.OwnerID)
2892 return; 3061 return;
@@ -2912,13 +3081,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2912 3081
2913 TaskInventoryItem item; 3082 TaskInventoryItem item;
2914 3083
2915 lock (m_host.TaskInventory) 3084 m_host.TaskInventory.LockItemsForRead(true);
3085
3086 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
2916 { 3087 {
2917 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3088 m_host.TaskInventory.LockItemsForRead(false);
2918 return; 3089 return;
2919 else
2920 item = m_host.TaskInventory[InventorySelf()];
2921 } 3090 }
3091 else
3092 {
3093 item = m_host.TaskInventory[InventorySelf()];
3094 }
3095 m_host.TaskInventory.LockItemsForRead(false);
3096
2922 3097
2923 if (item.PermsGranter != m_host.OwnerID) 3098 if (item.PermsGranter != m_host.OwnerID)
2924 return; 3099 return;
@@ -2954,8 +3129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2954 return m_host.OwnerID.ToString(); 3129 return m_host.OwnerID.ToString();
2955 } 3130 }
2956 3131
3132 [DebuggerNonUserCode]
2957 public void llInstantMessage(string user, string message) 3133 public void llInstantMessage(string user, string message)
2958 { 3134 {
3135 UUID result;
3136 if (!UUID.TryParse(user, out result))
3137 {
3138 throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user));
3139 return;
3140 }
3141
3142
2959 m_host.AddScriptLPS(1); 3143 m_host.AddScriptLPS(1);
2960 3144
2961 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. 3145 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
@@ -2970,7 +3154,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2970 UUID friendTransactionID = UUID.Random(); 3154 UUID friendTransactionID = UUID.Random();
2971 3155
2972 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 3156 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
2973 3157
2974 GridInstantMessage msg = new GridInstantMessage(); 3158 GridInstantMessage msg = new GridInstantMessage();
2975 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; 3159 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
2976 msg.toAgentID = new Guid(user); // toAgentID.Guid; 3160 msg.toAgentID = new Guid(user); // toAgentID.Guid;
@@ -3119,13 +3303,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3119 m_host.AddScriptLPS(1); 3303 m_host.AddScriptLPS(1);
3120 } 3304 }
3121 3305
3122 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
3123 {
3124 m_host.AddScriptLPS(1);
3125 Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s);
3126 m_host.RotLookAt(rot, (float)strength, (float)damping);
3127 }
3128
3129 public LSL_Integer llStringLength(string str) 3306 public LSL_Integer llStringLength(string str)
3130 { 3307 {
3131 m_host.AddScriptLPS(1); 3308 m_host.AddScriptLPS(1);
@@ -3149,14 +3326,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3149 3326
3150 TaskInventoryItem item; 3327 TaskInventoryItem item;
3151 3328
3152 lock (m_host.TaskInventory) 3329 m_host.TaskInventory.LockItemsForRead(true);
3330 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3153 { 3331 {
3154 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3332 m_host.TaskInventory.LockItemsForRead(false);
3155 return; 3333 return;
3156 else
3157 item = m_host.TaskInventory[InventorySelf()];
3158 } 3334 }
3159 3335 else
3336 {
3337 item = m_host.TaskInventory[InventorySelf()];
3338 }
3339 m_host.TaskInventory.LockItemsForRead(false);
3160 if (item.PermsGranter == UUID.Zero) 3340 if (item.PermsGranter == UUID.Zero)
3161 return; 3341 return;
3162 3342
@@ -3186,13 +3366,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3186 3366
3187 TaskInventoryItem item; 3367 TaskInventoryItem item;
3188 3368
3189 lock (m_host.TaskInventory) 3369 m_host.TaskInventory.LockItemsForRead(true);
3370 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
3190 { 3371 {
3191 if (!m_host.TaskInventory.ContainsKey(InventorySelf())) 3372 m_host.TaskInventory.LockItemsForRead(false);
3192 return; 3373 return;
3193 else
3194 item = m_host.TaskInventory[InventorySelf()];
3195 } 3374 }
3375 else
3376 {
3377 item = m_host.TaskInventory[InventorySelf()];
3378 }
3379 m_host.TaskInventory.LockItemsForRead(false);
3380
3196 3381
3197 if (item.PermsGranter == UUID.Zero) 3382 if (item.PermsGranter == UUID.Zero)
3198 return; 3383 return;
@@ -3269,10 +3454,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3269 3454
3270 TaskInventoryItem item; 3455 TaskInventoryItem item;
3271 3456
3272 lock (m_host.TaskInventory) 3457
3458 m_host.TaskInventory.LockItemsForRead(true);
3459 if (!m_host.TaskInventory.ContainsKey(invItemID))
3460 {
3461 m_host.TaskInventory.LockItemsForRead(false);
3462 return;
3463 }
3464 else
3273 { 3465 {
3274 item = m_host.TaskInventory[invItemID]; 3466 item = m_host.TaskInventory[invItemID];
3275 } 3467 }
3468 m_host.TaskInventory.LockItemsForRead(false);
3276 3469
3277 if (agentID == UUID.Zero || perm == 0) // Releasing permissions 3470 if (agentID == UUID.Zero || perm == 0) // Releasing permissions
3278 { 3471 {
@@ -3304,11 +3497,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3304 3497
3305 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3498 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3306 { 3499 {
3307 lock (m_host.TaskInventory) 3500 m_host.TaskInventory.LockItemsForWrite(true);
3308 { 3501 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3309 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3502 m_host.TaskInventory[invItemID].PermsMask = perm;
3310 m_host.TaskInventory[invItemID].PermsMask = perm; 3503 m_host.TaskInventory.LockItemsForWrite(false);
3311 }
3312 3504
3313 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3505 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3314 "run_time_permissions", new Object[] { 3506 "run_time_permissions", new Object[] {
@@ -3328,11 +3520,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3328 3520
3329 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms 3521 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
3330 { 3522 {
3331 lock (m_host.TaskInventory) 3523 m_host.TaskInventory.LockItemsForWrite(true);
3332 { 3524 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3333 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3525 m_host.TaskInventory[invItemID].PermsMask = perm;
3334 m_host.TaskInventory[invItemID].PermsMask = perm; 3526 m_host.TaskInventory.LockItemsForWrite(false);
3335 }
3336 3527
3337 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3528 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3338 "run_time_permissions", new Object[] { 3529 "run_time_permissions", new Object[] {
@@ -3353,11 +3544,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3353 3544
3354 if (!m_waitingForScriptAnswer) 3545 if (!m_waitingForScriptAnswer)
3355 { 3546 {
3356 lock (m_host.TaskInventory) 3547 m_host.TaskInventory.LockItemsForWrite(true);
3357 { 3548 m_host.TaskInventory[invItemID].PermsGranter = agentID;
3358 m_host.TaskInventory[invItemID].PermsGranter = agentID; 3549 m_host.TaskInventory[invItemID].PermsMask = 0;
3359 m_host.TaskInventory[invItemID].PermsMask = 0; 3550 m_host.TaskInventory.LockItemsForWrite(false);
3360 }
3361 3551
3362 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; 3552 presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
3363 m_waitingForScriptAnswer=true; 3553 m_waitingForScriptAnswer=true;
@@ -3392,10 +3582,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3392 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) 3582 if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
3393 llReleaseControls(); 3583 llReleaseControls();
3394 3584
3395 lock (m_host.TaskInventory) 3585
3396 { 3586 m_host.TaskInventory.LockItemsForWrite(true);
3397 m_host.TaskInventory[invItemID].PermsMask = answer; 3587 m_host.TaskInventory[invItemID].PermsMask = answer;
3398 } 3588 m_host.TaskInventory.LockItemsForWrite(false);
3589
3399 3590
3400 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( 3591 m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
3401 "run_time_permissions", new Object[] { 3592 "run_time_permissions", new Object[] {
@@ -3407,16 +3598,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3407 { 3598 {
3408 m_host.AddScriptLPS(1); 3599 m_host.AddScriptLPS(1);
3409 3600
3410 lock (m_host.TaskInventory) 3601 m_host.TaskInventory.LockItemsForRead(true);
3602
3603 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3411 { 3604 {
3412 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3605 if (item.Type == 10 && item.ItemID == m_itemID)
3413 { 3606 {
3414 if (item.Type == 10 && item.ItemID == m_itemID) 3607 m_host.TaskInventory.LockItemsForRead(false);
3415 { 3608 return item.PermsGranter.ToString();
3416 return item.PermsGranter.ToString();
3417 }
3418 } 3609 }
3419 } 3610 }
3611 m_host.TaskInventory.LockItemsForRead(false);
3420 3612
3421 return UUID.Zero.ToString(); 3613 return UUID.Zero.ToString();
3422 } 3614 }
@@ -3425,19 +3617,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3425 { 3617 {
3426 m_host.AddScriptLPS(1); 3618 m_host.AddScriptLPS(1);
3427 3619
3428 lock (m_host.TaskInventory) 3620 m_host.TaskInventory.LockItemsForRead(true);
3621
3622 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3429 { 3623 {
3430 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 3624 if (item.Type == 10 && item.ItemID == m_itemID)
3431 { 3625 {
3432 if (item.Type == 10 && item.ItemID == m_itemID) 3626 int perms = item.PermsMask;
3433 { 3627 if (m_automaticLinkPermission)
3434 int perms = item.PermsMask; 3628 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
3435 if (m_automaticLinkPermission) 3629 m_host.TaskInventory.LockItemsForRead(false);
3436 perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 3630 return perms;
3437 return perms;
3438 }
3439 } 3631 }
3440 } 3632 }
3633 m_host.TaskInventory.LockItemsForRead(false);
3441 3634
3442 return 0; 3635 return 0;
3443 } 3636 }
@@ -3470,11 +3663,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3470 UUID invItemID = InventorySelf(); 3663 UUID invItemID = InventorySelf();
3471 3664
3472 TaskInventoryItem item; 3665 TaskInventoryItem item;
3473 lock (m_host.TaskInventory) 3666 m_host.TaskInventory.LockItemsForRead(true);
3474 { 3667 item = m_host.TaskInventory[invItemID];
3475 item = m_host.TaskInventory[invItemID]; 3668 m_host.TaskInventory.LockItemsForRead(false);
3476 } 3669
3477
3478 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3670 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3479 && !m_automaticLinkPermission) 3671 && !m_automaticLinkPermission)
3480 { 3672 {
@@ -3527,16 +3719,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3527 m_host.AddScriptLPS(1); 3719 m_host.AddScriptLPS(1);
3528 UUID invItemID = InventorySelf(); 3720 UUID invItemID = InventorySelf();
3529 3721
3530 lock (m_host.TaskInventory) 3722 m_host.TaskInventory.LockItemsForRead(true);
3531 {
3532 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 3723 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
3533 && !m_automaticLinkPermission) 3724 && !m_automaticLinkPermission)
3534 { 3725 {
3535 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); 3726 ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
3727 m_host.TaskInventory.LockItemsForRead(false);
3536 return; 3728 return;
3537 } 3729 }
3538 } 3730 m_host.TaskInventory.LockItemsForRead(false);
3539 3731
3540 if (linknum < ScriptBaseClass.LINK_THIS) 3732 if (linknum < ScriptBaseClass.LINK_THIS)
3541 return; 3733 return;
3542 3734
@@ -3713,17 +3905,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3713 m_host.AddScriptLPS(1); 3905 m_host.AddScriptLPS(1);
3714 int count = 0; 3906 int count = 0;
3715 3907
3716 lock (m_host.TaskInventory) 3908 m_host.TaskInventory.LockItemsForRead(true);
3909 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3717 { 3910 {
3718 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3911 if (inv.Value.Type == type || type == -1)
3719 { 3912 {
3720 if (inv.Value.Type == type || type == -1) 3913 count = count + 1;
3721 {
3722 count = count + 1;
3723 }
3724 } 3914 }
3725 } 3915 }
3726 3916
3917 m_host.TaskInventory.LockItemsForRead(false);
3727 return count; 3918 return count;
3728 } 3919 }
3729 3920
@@ -3732,16 +3923,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3732 m_host.AddScriptLPS(1); 3923 m_host.AddScriptLPS(1);
3733 ArrayList keys = new ArrayList(); 3924 ArrayList keys = new ArrayList();
3734 3925
3735 lock (m_host.TaskInventory) 3926 m_host.TaskInventory.LockItemsForRead(true);
3927 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3736 { 3928 {
3737 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3929 if (inv.Value.Type == type || type == -1)
3738 { 3930 {
3739 if (inv.Value.Type == type || type == -1) 3931 keys.Add(inv.Value.Name);
3740 {
3741 keys.Add(inv.Value.Name);
3742 }
3743 } 3932 }
3744 } 3933 }
3934 m_host.TaskInventory.LockItemsForRead(false);
3745 3935
3746 if (keys.Count == 0) 3936 if (keys.Count == 0)
3747 { 3937 {
@@ -3778,20 +3968,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3778 } 3968 }
3779 3969
3780 // move the first object found with this inventory name 3970 // move the first object found with this inventory name
3781 lock (m_host.TaskInventory) 3971 m_host.TaskInventory.LockItemsForRead(true);
3972 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
3782 { 3973 {
3783 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 3974 if (inv.Value.Name == inventory)
3784 { 3975 {
3785 if (inv.Value.Name == inventory) 3976 found = true;
3786 { 3977 objId = inv.Key;
3787 found = true; 3978 assetType = inv.Value.Type;
3788 objId = inv.Key; 3979 objName = inv.Value.Name;
3789 assetType = inv.Value.Type; 3980 break;
3790 objName = inv.Value.Name;
3791 break;
3792 }
3793 } 3981 }
3794 } 3982 }
3983 m_host.TaskInventory.LockItemsForRead(false);
3795 3984
3796 if (!found) 3985 if (!found)
3797 { 3986 {
@@ -3836,24 +4025,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3836 ScriptSleep(3000); 4025 ScriptSleep(3000);
3837 } 4026 }
3838 4027
4028 [DebuggerNonUserCode]
3839 public void llRemoveInventory(string name) 4029 public void llRemoveInventory(string name)
3840 { 4030 {
3841 m_host.AddScriptLPS(1); 4031 m_host.AddScriptLPS(1);
3842 4032
3843 lock (m_host.TaskInventory) 4033 m_host.TaskInventory.LockItemsForRead(true);
4034 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
3844 { 4035 {
3845 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4036 if (item.Name == name)
3846 { 4037 {
3847 if (item.Name == name) 4038 if (item.ItemID == m_itemID)
3848 { 4039 throw new ScriptDeleteException();
3849 if (item.ItemID == m_itemID) 4040 else
3850 throw new ScriptDeleteException(); 4041 m_host.Inventory.RemoveInventoryItem(item.ItemID);
3851 else 4042
3852 m_host.Inventory.RemoveInventoryItem(item.ItemID); 4043 m_host.TaskInventory.LockItemsForRead(false);
3853 return; 4044 return;
3854 }
3855 } 4045 }
3856 } 4046 }
4047 m_host.TaskInventory.LockItemsForRead(false);
3857 } 4048 }
3858 4049
3859 public void llSetText(string text, LSL_Vector color, double alpha) 4050 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -3942,6 +4133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3942 { 4133 {
3943 m_host.AddScriptLPS(1); 4134 m_host.AddScriptLPS(1);
3944 4135
4136 //Clone is thread safe
3945 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 4137 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3946 4138
3947 foreach (TaskInventoryItem item in itemDictionary.Values) 4139 foreach (TaskInventoryItem item in itemDictionary.Values)
@@ -4030,17 +4222,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4030 UUID soundId = UUID.Zero; 4222 UUID soundId = UUID.Zero;
4031 if (!UUID.TryParse(impact_sound, out soundId)) 4223 if (!UUID.TryParse(impact_sound, out soundId))
4032 { 4224 {
4033 lock (m_host.TaskInventory) 4225 m_host.TaskInventory.LockItemsForRead(true);
4226 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4034 { 4227 {
4035 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4228 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
4036 { 4229 {
4037 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4230 soundId = item.AssetID;
4038 { 4231 break;
4039 soundId = item.AssetID;
4040 break;
4041 }
4042 } 4232 }
4043 } 4233 }
4234 m_host.TaskInventory.LockItemsForRead(false);
4044 } 4235 }
4045 m_host.CollisionSound = soundId; 4236 m_host.CollisionSound = soundId;
4046 m_host.CollisionSoundVolume = (float)impact_volume; 4237 m_host.CollisionSoundVolume = (float)impact_volume;
@@ -4086,6 +4277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4086 UUID partItemID; 4277 UUID partItemID;
4087 foreach (SceneObjectPart part in parts) 4278 foreach (SceneObjectPart part in parts)
4088 { 4279 {
4280 //Clone is thread safe
4089 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); 4281 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4090 4282
4091 foreach (TaskInventoryItem item in itemsDictionary.Values) 4283 foreach (TaskInventoryItem item in itemsDictionary.Values)
@@ -4300,17 +4492,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4300 4492
4301 m_host.AddScriptLPS(1); 4493 m_host.AddScriptLPS(1);
4302 4494
4303 lock (m_host.TaskInventory) 4495 m_host.TaskInventory.LockItemsForRead(true);
4496 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
4304 { 4497 {
4305 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4498 if (item.Type == 10 && item.ItemID == m_itemID)
4306 { 4499 {
4307 if (item.Type == 10 && item.ItemID == m_itemID) 4500 result = item.Name!=null?item.Name:String.Empty;
4308 { 4501 break;
4309 result = item.Name != null ? item.Name : String.Empty;
4310 break;
4311 }
4312 } 4502 }
4313 } 4503 }
4504 m_host.TaskInventory.LockItemsForRead(false);
4314 4505
4315 return result; 4506 return result;
4316 } 4507 }
@@ -4463,23 +4654,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4463 { 4654 {
4464 m_host.AddScriptLPS(1); 4655 m_host.AddScriptLPS(1);
4465 4656
4466 lock (m_host.TaskInventory) 4657 m_host.TaskInventory.LockItemsForRead(true);
4658 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4467 { 4659 {
4468 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 4660 if (inv.Value.Name == name)
4469 { 4661 {
4470 if (inv.Value.Name == name) 4662 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
4471 { 4663 {
4472 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) 4664 m_host.TaskInventory.LockItemsForRead(false);
4473 { 4665 return inv.Value.AssetID.ToString();
4474 return inv.Value.AssetID.ToString(); 4666 }
4475 } 4667 else
4476 else 4668 {
4477 { 4669 m_host.TaskInventory.LockItemsForRead(false);
4478 return UUID.Zero.ToString(); 4670 return UUID.Zero.ToString();
4479 }
4480 } 4671 }
4481 } 4672 }
4482 } 4673 }
4674 m_host.TaskInventory.LockItemsForRead(false);
4483 4675
4484 return UUID.Zero.ToString(); 4676 return UUID.Zero.ToString();
4485 } 4677 }
@@ -5995,14 +6187,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5995 6187
5996 protected UUID GetTaskInventoryItem(string name) 6188 protected UUID GetTaskInventoryItem(string name)
5997 { 6189 {
5998 lock (m_host.TaskInventory) 6190 m_host.TaskInventory.LockItemsForRead(true);
6191 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
5999 { 6192 {
6000 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6193 if (inv.Value.Name == name)
6001 { 6194 {
6002 if (inv.Value.Name == name) 6195 m_host.TaskInventory.LockItemsForRead(false);
6003 return inv.Key; 6196 return inv.Key;
6004 } 6197 }
6005 } 6198 }
6199 m_host.TaskInventory.LockItemsForRead(false);
6006 6200
6007 return UUID.Zero; 6201 return UUID.Zero;
6008 } 6202 }
@@ -6330,22 +6524,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6330 } 6524 }
6331 6525
6332 // copy the first script found with this inventory name 6526 // copy the first script found with this inventory name
6333 lock (m_host.TaskInventory) 6527 m_host.TaskInventory.LockItemsForRead(true);
6528 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6334 { 6529 {
6335 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 6530 if (inv.Value.Name == name)
6336 { 6531 {
6337 if (inv.Value.Name == name) 6532 // make sure the object is a script
6533 if (10 == inv.Value.Type)
6338 { 6534 {
6339 // make sure the object is a script 6535 found = true;
6340 if (10 == inv.Value.Type) 6536 srcId = inv.Key;
6341 { 6537 break;
6342 found = true;
6343 srcId = inv.Key;
6344 break;
6345 }
6346 } 6538 }
6347 } 6539 }
6348 } 6540 }
6541 m_host.TaskInventory.LockItemsForRead(false);
6349 6542
6350 if (!found) 6543 if (!found)
6351 { 6544 {
@@ -6427,8 +6620,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6427 } 6620 }
6428 6621
6429 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) 6622 protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
6430 { 6623 {
6431 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6624 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6625 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6626 return shapeBlock;
6432 6627
6433 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && 6628 if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT &&
6434 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && 6629 holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE &&
@@ -6498,7 +6693,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6498 } 6693 }
6499 6694
6500 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) 6695 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge)
6501 { 6696 {
6697 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6698 return;
6699
6502 ObjectShapePacket.ObjectDataBlock shapeBlock; 6700 ObjectShapePacket.ObjectDataBlock shapeBlock;
6503 6701
6504 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6702 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6547,7 +6745,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6547 } 6745 }
6548 6746
6549 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) 6747 protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge)
6550 { 6748 {
6749 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6750 return;
6751
6551 ObjectShapePacket.ObjectDataBlock shapeBlock; 6752 ObjectShapePacket.ObjectDataBlock shapeBlock;
6552 6753
6553 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6754 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6589,7 +6790,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6589 } 6790 }
6590 6791
6591 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) 6792 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)
6592 { 6793 {
6794 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6795 return;
6796
6593 ObjectShapePacket.ObjectDataBlock shapeBlock; 6797 ObjectShapePacket.ObjectDataBlock shapeBlock;
6594 6798
6595 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); 6799 shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
@@ -6710,7 +6914,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6710 } 6914 }
6711 6915
6712 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) 6916 protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type)
6713 { 6917 {
6918 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6919 return;
6920
6714 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); 6921 ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock();
6715 UUID sculptId; 6922 UUID sculptId;
6716 6923
@@ -6744,14 +6951,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6744 } 6951 }
6745 6952
6746 public void llSetPrimitiveParams(LSL_List rules) 6953 public void llSetPrimitiveParams(LSL_List rules)
6747 { 6954 {
6748 m_host.AddScriptLPS(1); 6955 m_host.AddScriptLPS(1);
6749 SetPrimParams(m_host, rules); 6956 SetPrimParams(m_host, rules);
6750 } 6957 }
6751 6958
6752 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 6959 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
6753 { 6960 {
6754 m_host.AddScriptLPS(1); 6961 m_host.AddScriptLPS(1);
6755 6962
6756 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6963 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6757 6964
@@ -6760,7 +6967,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6760 } 6967 }
6761 6968
6762 protected void SetPrimParams(SceneObjectPart part, LSL_List rules) 6969 protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
6763 { 6970 {
6971 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
6972 return;
6973
6764 int idx = 0; 6974 int idx = 0;
6765 6975
6766 while (idx < rules.Length) 6976 while (idx < rules.Length)
@@ -7562,25 +7772,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7562 } 7772 }
7563 break; 7773 break;
7564 7774
7565 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 7775 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7566 // TODO-------------- 7776 if (remain < 1)
7567 if (remain < 1) 7777 return res;
7568 return res; 7778 face = (int)rules.GetLSLIntegerItem(idx++);
7569 7779
7570 face=(int)rules.GetLSLIntegerItem(idx++); 7780 tex = part.Shape.Textures;
7571 7781 int shiny;
7572 res.Add(new LSL_Integer(0)); 7782 if (face == ScriptBaseClass.ALL_SIDES)
7573 res.Add(new LSL_Integer(0)); 7783 {
7784 for (face = 0; face < GetNumberOfSides(part); face++)
7785 {
7786 Shininess shinyness = tex.GetFace((uint)face).Shiny;
7787 if (shinyness == Shininess.High)
7788 {
7789 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7790 }
7791 else if (shinyness == Shininess.Medium)
7792 {
7793 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
7794 }
7795 else if (shinyness == Shininess.Low)
7796 {
7797 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
7798 }
7799 else
7800 {
7801 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
7802 }
7803 res.Add(new LSL_Integer(shiny));
7804 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7805 }
7806 }
7807 else
7808 {
7809 Shininess shinyness = tex.GetFace((uint)face).Shiny;
7810 if (shinyness == Shininess.High)
7811 {
7812 shiny = ScriptBaseClass.PRIM_SHINY_HIGH;
7813 }
7814 else if (shinyness == Shininess.Medium)
7815 {
7816 shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM;
7817 }
7818 else if (shinyness == Shininess.Low)
7819 {
7820 shiny = ScriptBaseClass.PRIM_SHINY_LOW;
7821 }
7822 else
7823 {
7824 shiny = ScriptBaseClass.PRIM_SHINY_NONE;
7825 }
7826 res.Add(new LSL_Integer(shiny));
7827 res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump));
7828 }
7574 break; 7829 break;
7575 7830
7576 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 7831 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7577 // TODO-------------- 7832 if (remain < 1)
7578 if (remain < 1) 7833 return res;
7579 return res; 7834 face = (int)rules.GetLSLIntegerItem(idx++);
7580 7835
7581 face=(int)rules.GetLSLIntegerItem(idx++); 7836 tex = part.Shape.Textures;
7582 7837 int fullbright;
7583 res.Add(new LSL_Integer(0)); 7838 if (face == ScriptBaseClass.ALL_SIDES)
7839 {
7840 for (face = 0; face < GetNumberOfSides(part); face++)
7841 {
7842 if (tex.GetFace((uint)face).Fullbright == true)
7843 {
7844 fullbright = ScriptBaseClass.TRUE;
7845 }
7846 else
7847 {
7848 fullbright = ScriptBaseClass.FALSE;
7849 }
7850 res.Add(new LSL_Integer(fullbright));
7851 }
7852 }
7853 else
7854 {
7855 if (tex.GetFace((uint)face).Fullbright == true)
7856 {
7857 fullbright = ScriptBaseClass.TRUE;
7858 }
7859 else
7860 {
7861 fullbright = ScriptBaseClass.FALSE;
7862 }
7863 res.Add(new LSL_Integer(fullbright));
7864 }
7584 break; 7865 break;
7585 7866
7586 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 7867 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7601,14 +7882,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7601 break; 7882 break;
7602 7883
7603 case (int)ScriptBaseClass.PRIM_TEXGEN: 7884 case (int)ScriptBaseClass.PRIM_TEXGEN:
7604 // TODO-------------- 7885 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7605 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) 7886 if (remain < 1)
7606 if (remain < 1) 7887 return res;
7607 return res; 7888 face = (int)rules.GetLSLIntegerItem(idx++);
7608 7889
7609 face=(int)rules.GetLSLIntegerItem(idx++); 7890 tex = part.Shape.Textures;
7610 7891 if (face == ScriptBaseClass.ALL_SIDES)
7611 res.Add(new LSL_Integer(0)); 7892 {
7893 for (face = 0; face < GetNumberOfSides(part); face++)
7894 {
7895 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7896 {
7897 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
7898 }
7899 else
7900 {
7901 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
7902 }
7903 }
7904 }
7905 else
7906 {
7907 if (tex.GetFace((uint)face).TexMapType == MappingType.Planar)
7908 {
7909 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR));
7910 }
7911 else
7912 {
7913 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
7914 }
7915 }
7612 break; 7916 break;
7613 7917
7614 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 7918 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7626,14 +7930,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7626 res.Add(new LSL_Float(shape.LightFalloff)); // falloff 7930 res.Add(new LSL_Float(shape.LightFalloff)); // falloff
7627 break; 7931 break;
7628 7932
7629 case (int)ScriptBaseClass.PRIM_GLOW: 7933 case (int)ScriptBaseClass.PRIM_GLOW:
7630 // TODO-------------- 7934 if (remain < 1)
7631 if (remain < 1)
7632 return res; 7935 return res;
7633 7936 face = (int)rules.GetLSLIntegerItem(idx++);
7634 face=(int)rules.GetLSLIntegerItem(idx++); 7937
7635 7938 tex = part.Shape.Textures;
7636 res.Add(new LSL_Float(0)); 7939 float primglow;
7940 if (face == ScriptBaseClass.ALL_SIDES)
7941 {
7942 for (face = 0; face < GetNumberOfSides(part); face++)
7943 {
7944 primglow = tex.GetFace((uint)face).Glow;
7945 res.Add(new LSL_Float(primglow));
7946 }
7947 }
7948 else
7949 {
7950 primglow = tex.GetFace((uint)face).Glow;
7951 res.Add(new LSL_Float(primglow));
7952 }
7637 break; 7953 break;
7638 } 7954 }
7639 } 7955 }
@@ -8162,28 +8478,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8162 { 8478 {
8163 m_host.AddScriptLPS(1); 8479 m_host.AddScriptLPS(1);
8164 8480
8165 lock (m_host.TaskInventory) 8481 m_host.TaskInventory.LockItemsForRead(true);
8482 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8166 { 8483 {
8167 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8484 if (inv.Value.Name == item)
8168 { 8485 {
8169 if (inv.Value.Name == item) 8486 m_host.TaskInventory.LockItemsForRead(false);
8487 switch (mask)
8170 { 8488 {
8171 switch (mask) 8489 case 0:
8172 { 8490 return (int)inv.Value.BasePermissions;
8173 case 0: 8491 case 1:
8174 return (int)inv.Value.BasePermissions; 8492 return (int)inv.Value.CurrentPermissions;
8175 case 1: 8493 case 2:
8176 return (int)inv.Value.CurrentPermissions; 8494 return (int)inv.Value.GroupPermissions;
8177 case 2: 8495 case 3:
8178 return (int)inv.Value.GroupPermissions; 8496 return (int)inv.Value.EveryonePermissions;
8179 case 3: 8497 case 4:
8180 return (int)inv.Value.EveryonePermissions; 8498 return (int)inv.Value.NextPermissions;
8181 case 4:
8182 return (int)inv.Value.NextPermissions;
8183 }
8184 } 8499 }
8185 } 8500 }
8186 } 8501 }
8502 m_host.TaskInventory.LockItemsForRead(false);
8187 8503
8188 return -1; 8504 return -1;
8189 } 8505 }
@@ -8230,16 +8546,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8230 { 8546 {
8231 m_host.AddScriptLPS(1); 8547 m_host.AddScriptLPS(1);
8232 8548
8233 lock (m_host.TaskInventory) 8549 m_host.TaskInventory.LockItemsForRead(true);
8550 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8234 { 8551 {
8235 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 8552 if (inv.Value.Name == item)
8236 { 8553 {
8237 if (inv.Value.Name == item) 8554 m_host.TaskInventory.LockItemsForRead(false);
8238 { 8555 return inv.Value.CreatorID.ToString();
8239 return inv.Value.CreatorID.ToString();
8240 }
8241 } 8556 }
8242 } 8557 }
8558 m_host.TaskInventory.LockItemsForRead(false);
8243 8559
8244 llSay(0, "No item name '" + item + "'"); 8560 llSay(0, "No item name '" + item + "'");
8245 8561
@@ -8768,16 +9084,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8768 { 9084 {
8769 m_host.AddScriptLPS(1); 9085 m_host.AddScriptLPS(1);
8770 9086
8771 lock (m_host.TaskInventory) 9087 m_host.TaskInventory.LockItemsForRead(true);
9088 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
8772 { 9089 {
8773 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 9090 if (inv.Value.Name == name)
8774 { 9091 {
8775 if (inv.Value.Name == name) 9092 m_host.TaskInventory.LockItemsForRead(false);
8776 { 9093 return inv.Value.Type;
8777 return inv.Value.Type;
8778 }
8779 } 9094 }
8780 } 9095 }
9096 m_host.TaskInventory.LockItemsForRead(false);
8781 9097
8782 return -1; 9098 return -1;
8783 } 9099 }
@@ -8787,16 +9103,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8787 m_host.AddScriptLPS(1); 9103 m_host.AddScriptLPS(1);
8788 9104
8789 if (quick_pay_buttons.Data.Length < 4) 9105 if (quick_pay_buttons.Data.Length < 4)
8790 { 9106 {
8791 LSLError("List must have at least 4 elements"); 9107 int x;
8792 return; 9108 for (x=quick_pay_buttons.Data.Length; x<= 4; x++)
9109 {
9110 quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE);
9111 }
8793 } 9112 }
8794 m_host.ParentGroup.RootPart.PayPrice[0]=price; 9113 int[] nPrice = new int[5];
8795 9114 nPrice[0]=price;
8796 m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; 9115 nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0];
8797 m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; 9116 nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1];
8798 m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; 9117 nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2];
8799 m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; 9118 nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3];
9119 m_host.ParentGroup.RootPart.PayPrice = nPrice;
8800 m_host.ParentGroup.HasGroupChanged = true; 9120 m_host.ParentGroup.HasGroupChanged = true;
8801 } 9121 }
8802 9122
@@ -8808,17 +9128,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8808 if (invItemID == UUID.Zero) 9128 if (invItemID == UUID.Zero)
8809 return new LSL_Vector(); 9129 return new LSL_Vector();
8810 9130
8811 lock (m_host.TaskInventory) 9131 m_host.TaskInventory.LockItemsForRead(true);
9132 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8812 { 9133 {
8813 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9134 m_host.TaskInventory.LockItemsForRead(false);
8814 return new LSL_Vector(); 9135 return new LSL_Vector();
9136 }
8815 9137
8816 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9138 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8817 { 9139 {
8818 ShoutError("No permissions to track the camera"); 9140 ShoutError("No permissions to track the camera");
8819 return new LSL_Vector(); 9141 m_host.TaskInventory.LockItemsForRead(false);
8820 } 9142 return new LSL_Vector();
8821 } 9143 }
9144 m_host.TaskInventory.LockItemsForRead(false);
8822 9145
8823 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9146 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8824 if (presence != null) 9147 if (presence != null)
@@ -8836,17 +9159,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8836 if (invItemID == UUID.Zero) 9159 if (invItemID == UUID.Zero)
8837 return new LSL_Rotation(); 9160 return new LSL_Rotation();
8838 9161
8839 lock (m_host.TaskInventory) 9162 m_host.TaskInventory.LockItemsForRead(true);
9163 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
8840 { 9164 {
8841 if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) 9165 m_host.TaskInventory.LockItemsForRead(false);
8842 return new LSL_Rotation(); 9166 return new LSL_Rotation();
8843 9167 }
8844 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) 9168 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
8845 { 9169 {
8846 ShoutError("No permissions to track the camera"); 9170 ShoutError("No permissions to track the camera");
8847 return new LSL_Rotation(); 9171 m_host.TaskInventory.LockItemsForRead(false);
8848 } 9172 return new LSL_Rotation();
8849 } 9173 }
9174 m_host.TaskInventory.LockItemsForRead(false);
8850 9175
8851 ScenePresence presence = World.GetScenePresence(m_host.OwnerID); 9176 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
8852 if (presence != null) 9177 if (presence != null)
@@ -8996,14 +9321,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8996 if (objectID == UUID.Zero) return; 9321 if (objectID == UUID.Zero) return;
8997 9322
8998 UUID agentID; 9323 UUID agentID;
8999 lock (m_host.TaskInventory) 9324 m_host.TaskInventory.LockItemsForRead(true);
9000 { 9325 // we need the permission first, to know which avatar we want to set the camera for
9001 // we need the permission first, to know which avatar we want to set the camera for 9326 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9002 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9003 9327
9004 if (agentID == UUID.Zero) return; 9328 if (agentID == UUID.Zero)
9005 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; 9329 {
9330 m_host.TaskInventory.LockItemsForRead(false);
9331 return;
9332 }
9333 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9334 {
9335 m_host.TaskInventory.LockItemsForRead(false);
9336 return;
9006 } 9337 }
9338 m_host.TaskInventory.LockItemsForRead(false);
9007 9339
9008 ScenePresence presence = World.GetScenePresence(agentID); 9340 ScenePresence presence = World.GetScenePresence(agentID);
9009 9341
@@ -9053,12 +9385,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9053 9385
9054 // we need the permission first, to know which avatar we want to clear the camera for 9386 // we need the permission first, to know which avatar we want to clear the camera for
9055 UUID agentID; 9387 UUID agentID;
9056 lock (m_host.TaskInventory) 9388 m_host.TaskInventory.LockItemsForRead(true);
9389 agentID = m_host.TaskInventory[invItemID].PermsGranter;
9390 if (agentID == UUID.Zero)
9057 { 9391 {
9058 agentID = m_host.TaskInventory[invItemID].PermsGranter; 9392 m_host.TaskInventory.LockItemsForRead(false);
9059 if (agentID == UUID.Zero) return; 9393 return;
9060 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
9061 } 9394 }
9395 if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
9396 {
9397 m_host.TaskInventory.LockItemsForRead(false);
9398 return;
9399 }
9400 m_host.TaskInventory.LockItemsForRead(false);
9062 9401
9063 ScenePresence presence = World.GetScenePresence(agentID); 9402 ScenePresence presence = World.GetScenePresence(agentID);
9064 9403
@@ -9515,15 +9854,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9515 9854
9516 internal UUID ScriptByName(string name) 9855 internal UUID ScriptByName(string name)
9517 { 9856 {
9518 lock (m_host.TaskInventory) 9857 m_host.TaskInventory.LockItemsForRead(true);
9858
9859 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
9519 { 9860 {
9520 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 9861 if (item.Type == 10 && item.Name == name)
9521 { 9862 {
9522 if (item.Type == 10 && item.Name == name) 9863 m_host.TaskInventory.LockItemsForRead(false);
9523 return item.ItemID; 9864 return item.ItemID;
9524 } 9865 }
9525 } 9866 }
9526 9867
9868 m_host.TaskInventory.LockItemsForRead(false);
9869
9527 return UUID.Zero; 9870 return UUID.Zero;
9528 } 9871 }
9529 9872
@@ -9564,6 +9907,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9564 { 9907 {
9565 m_host.AddScriptLPS(1); 9908 m_host.AddScriptLPS(1);
9566 9909
9910 //Clone is thread safe
9567 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9911 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9568 9912
9569 UUID assetID = UUID.Zero; 9913 UUID assetID = UUID.Zero;
@@ -9626,6 +9970,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9626 { 9970 {
9627 m_host.AddScriptLPS(1); 9971 m_host.AddScriptLPS(1);
9628 9972
9973 //Clone is thread safe
9629 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); 9974 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
9630 9975
9631 UUID assetID = UUID.Zero; 9976 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 85ee29d..845834e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -718,18 +718,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
718 if (target != null) 718 if (target != null)
719 { 719 {
720 UUID animID=UUID.Zero; 720 UUID animID=UUID.Zero;
721 lock (m_host.TaskInventory) 721 m_host.TaskInventory.LockItemsForRead(true);
722 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
722 { 723 {
723 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 724 if (inv.Value.Name == animation)
724 { 725 {
725 if (inv.Value.Name == animation) 726 if (inv.Value.Type == (int)AssetType.Animation)
726 { 727 animID = inv.Value.AssetID;
727 if (inv.Value.Type == (int)AssetType.Animation) 728 continue;
728 animID = inv.Value.AssetID;
729 continue;
730 }
731 } 729 }
732 } 730 }
731 m_host.TaskInventory.LockItemsForRead(false);
733 if (animID == UUID.Zero) 732 if (animID == UUID.Zero)
734 target.Animator.AddAnimation(animation, m_host.UUID); 733 target.Animator.AddAnimation(animation, m_host.UUID);
735 else 734 else
@@ -751,18 +750,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
751 if (target != null) 750 if (target != null)
752 { 751 {
753 UUID animID=UUID.Zero; 752 UUID animID=UUID.Zero;
754 lock (m_host.TaskInventory) 753 m_host.TaskInventory.LockItemsForRead(true);
754 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
755 { 755 {
756 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 756 if (inv.Value.Name == animation)
757 { 757 {
758 if (inv.Value.Name == animation) 758 if (inv.Value.Type == (int)AssetType.Animation)
759 { 759 animID = inv.Value.AssetID;
760 if (inv.Value.Type == (int)AssetType.Animation) 760 continue;
761 animID = inv.Value.AssetID;
762 continue;
763 }
764 } 761 }
765 } 762 }
763 m_host.TaskInventory.LockItemsForRead(false);
766 764
767 if (animID == UUID.Zero) 765 if (animID == UUID.Zero)
768 target.Animator.RemoveAnimation(animation); 766 target.Animator.RemoveAnimation(animation);
@@ -1531,6 +1529,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1531 1529
1532 if (!UUID.TryParse(name, out assetID)) 1530 if (!UUID.TryParse(name, out assetID))
1533 { 1531 {
1532 m_host.TaskInventory.LockItemsForRead(true);
1534 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1533 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1535 { 1534 {
1536 if (item.Type == 7 && item.Name == name) 1535 if (item.Type == 7 && item.Name == name)
@@ -1538,6 +1537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1538 assetID = item.AssetID; 1537 assetID = item.AssetID;
1539 } 1538 }
1540 } 1539 }
1540 m_host.TaskInventory.LockItemsForRead(false);
1541 } 1541 }
1542 1542
1543 if (assetID == UUID.Zero) 1543 if (assetID == UUID.Zero)
@@ -1584,6 +1584,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1584 1584
1585 if (!UUID.TryParse(name, out assetID)) 1585 if (!UUID.TryParse(name, out assetID))
1586 { 1586 {
1587 m_host.TaskInventory.LockItemsForRead(true);
1587 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1588 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1588 { 1589 {
1589 if (item.Type == 7 && item.Name == name) 1590 if (item.Type == 7 && item.Name == name)
@@ -1591,6 +1592,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1591 assetID = item.AssetID; 1592 assetID = item.AssetID;
1592 } 1593 }
1593 } 1594 }
1595 m_host.TaskInventory.LockItemsForRead(false);
1594 } 1596 }
1595 1597
1596 if (assetID == UUID.Zero) 1598 if (assetID == UUID.Zero)
@@ -1641,6 +1643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1641 1643
1642 if (!UUID.TryParse(name, out assetID)) 1644 if (!UUID.TryParse(name, out assetID))
1643 { 1645 {
1646 m_host.TaskInventory.LockItemsForRead(true);
1644 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1647 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1645 { 1648 {
1646 if (item.Type == 7 && item.Name == name) 1649 if (item.Type == 7 && item.Name == name)
@@ -1648,6 +1651,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1648 assetID = item.AssetID; 1651 assetID = item.AssetID;
1649 } 1652 }
1650 } 1653 }
1654 m_host.TaskInventory.LockItemsForRead(false);
1651 } 1655 }
1652 1656
1653 if (assetID == UUID.Zero) 1657 if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
index eeb59d9..2fd33fe 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
109 if (Timers.Count == 0) 109 if (Timers.Count == 0)
110 return; 110 return;
111 111
112 Dictionary<string, TimerClass>.ValueCollection tvals;
112 lock (TimerListLock) 113 lock (TimerListLock)
113 { 114 {
114 // Go through all timers 115 // Go through all timers
115 Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; 116 tvals = Timers.Values;
116 foreach (TimerClass ts in tvals) 117 }
118
119 foreach (TimerClass ts in tvals)
120 {
121 // Time has passed?
122 if (ts.next < DateTime.Now.Ticks)
117 { 123 {
118 // Time has passed? 124 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
119 if (ts.next < DateTime.Now.Ticks) 125 // Add it to queue
120 { 126 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
121 //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); 127 new EventParams("timer", new Object[0],
122 // Add it to queue 128 new DetectParams[0]));
123 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, 129 // set next interval
124 new EventParams("timer", new Object[0], 130
125 new DetectParams[0])); 131 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
126 // set next interval 132 ts.next = DateTime.Now.Ticks + ts.interval;
127
128 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
129 ts.next = DateTime.Now.Ticks + ts.interval;
130 }
131 } 133 }
132 } 134 }
133 } 135 }
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 60b8050..f5921e1 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..522c020
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
@@ -0,0 +1,77 @@
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 public const int WL_SUN_MOON_POSITION = 36;
75
76 }
77}
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 9615315..943d7a2 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;
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
132 return (eventFlags); 133 return (eventFlags);
133 } 134 }
134 135
136 [DebuggerNonUserCode]
135 public void ExecuteEvent(string state, string FunctionName, object[] args) 137 public void ExecuteEvent(string state, string FunctionName, object[] args)
136 { 138 {
137 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 139 // 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 edbbc2a..b138da3 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);