diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
11 files changed, 1154 insertions, 300 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..d4250c1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,473 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using System.Collections; | ||
4 | using System.Collections.Generic; | ||
5 | using System.Runtime.Remoting.Lifetime; | ||
6 | using OpenMetaverse; | ||
7 | using Nini.Config; | ||
8 | using OpenSim; | ||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Region.CoreModules.World.Meta7Windlight; | ||
11 | using OpenSim.Region.Framework.Interfaces; | ||
12 | using OpenSim.Region.Framework.Scenes; | ||
13 | using OpenSim.Region.ScriptEngine.Shared; | ||
14 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
15 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
16 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
17 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
18 | |||
19 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
20 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
21 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
22 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
23 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
24 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
25 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
26 | |||
27 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
28 | { | ||
29 | [Serializable] | ||
30 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
31 | { | ||
32 | internal IScriptEngine m_ScriptEngine; | ||
33 | internal SceneObjectPart m_host; | ||
34 | internal uint m_localID; | ||
35 | internal UUID m_itemID; | ||
36 | internal bool m_CMFunctionsEnabled = false; | ||
37 | internal IScriptModuleComms m_comms = null; | ||
38 | |||
39 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
40 | { | ||
41 | m_ScriptEngine = ScriptEngine; | ||
42 | m_host = host; | ||
43 | m_localID = localID; | ||
44 | m_itemID = itemID; | ||
45 | |||
46 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
47 | m_CMFunctionsEnabled = true; | ||
48 | |||
49 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
50 | if (m_comms == null) | ||
51 | m_CMFunctionsEnabled = false; | ||
52 | } | ||
53 | |||
54 | public override Object InitializeLifetimeService() | ||
55 | { | ||
56 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
57 | |||
58 | if (lease.CurrentState == LeaseState.Initial) | ||
59 | { | ||
60 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
61 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
62 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
63 | } | ||
64 | return lease; | ||
65 | } | ||
66 | |||
67 | public Scene World | ||
68 | { | ||
69 | get { return m_ScriptEngine.World; } | ||
70 | } | ||
71 | |||
72 | // | ||
73 | //Dumps an error message on the debug console. | ||
74 | // | ||
75 | |||
76 | internal void CMShoutError(string message) | ||
77 | { | ||
78 | if (message.Length > 1023) | ||
79 | message = message.Substring(0, 1023); | ||
80 | |||
81 | World.SimChat(Utils.StringToBytes(message), | ||
82 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
83 | |||
84 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
85 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// Get the current Windlight scene | ||
90 | /// </summary> | ||
91 | /// <returns>List of windlight parameters</returns> | ||
92 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
93 | { | ||
94 | if (!m_CMFunctionsEnabled) | ||
95 | { | ||
96 | CMShoutError("Careminster functions are not enabled."); | ||
97 | return new LSL_List(); | ||
98 | } | ||
99 | m_host.AddScriptLPS(1); | ||
100 | RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
101 | |||
102 | LSL_List values = new LSL_List(); | ||
103 | int idx = 0; | ||
104 | while (idx < rules.Length) | ||
105 | { | ||
106 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
107 | LSL_List toadd = new LSL_List(); | ||
108 | |||
109 | switch (rule) | ||
110 | { | ||
111 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
112 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
113 | break; | ||
114 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
115 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
116 | break; | ||
117 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
118 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
119 | break; | ||
120 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
121 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
122 | break; | ||
123 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
124 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
125 | break; | ||
126 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
127 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
128 | break; | ||
129 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
130 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
131 | break; | ||
132 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
133 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
134 | break; | ||
135 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
136 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
137 | break; | ||
138 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
139 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
140 | break; | ||
141 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
142 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
143 | break; | ||
144 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
145 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
146 | break; | ||
147 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
148 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
149 | break; | ||
150 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
151 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
152 | break; | ||
153 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
154 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
155 | break; | ||
156 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
157 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
158 | break; | ||
159 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
160 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
161 | break; | ||
162 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
163 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
164 | break; | ||
165 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
166 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
167 | break; | ||
168 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
169 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
170 | break; | ||
171 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
172 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
173 | break; | ||
174 | case (int)ScriptBaseClass.WL_HORIZON: | ||
175 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
176 | break; | ||
177 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
178 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
179 | break; | ||
180 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
181 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
182 | break; | ||
183 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
184 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
185 | break; | ||
186 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
187 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
188 | break; | ||
189 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
190 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
191 | break; | ||
192 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
193 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
194 | break; | ||
195 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
196 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
197 | break; | ||
198 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
199 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
200 | break; | ||
201 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
202 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
203 | break; | ||
204 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
205 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
206 | break; | ||
207 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
208 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
209 | break; | ||
210 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
211 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
212 | break; | ||
213 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
214 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
215 | break; | ||
216 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
217 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
218 | break; | ||
219 | } | ||
220 | |||
221 | if (toadd.Length > 0) | ||
222 | { | ||
223 | values.Add(rule); | ||
224 | values.Add(toadd.Data[0]); | ||
225 | } | ||
226 | idx++; | ||
227 | } | ||
228 | |||
229 | |||
230 | return values; | ||
231 | |||
232 | } | ||
233 | |||
234 | private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) | ||
235 | { | ||
236 | RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
237 | |||
238 | LSL_List values = new LSL_List(); | ||
239 | int idx = 0; | ||
240 | while (idx < rules.Length) | ||
241 | { | ||
242 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
243 | LSL_Types.Quaternion iQ; | ||
244 | LSL_Types.Vector3 iV; | ||
245 | switch (rule) | ||
246 | { | ||
247 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
248 | idx++; | ||
249 | iQ = rules.GetQuaternionItem(idx); | ||
250 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
251 | break; | ||
252 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
253 | idx++; | ||
254 | iV = rules.GetVector3Item(idx); | ||
255 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
256 | break; | ||
257 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
258 | idx++; | ||
259 | iQ = rules.GetQuaternionItem(idx); | ||
260 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
261 | break; | ||
262 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
263 | idx++; | ||
264 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
265 | break; | ||
266 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
267 | idx++; | ||
268 | iQ = rules.GetQuaternionItem(idx); | ||
269 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
270 | break; | ||
271 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
272 | idx++; | ||
273 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
274 | break; | ||
275 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
276 | idx++; | ||
277 | iV = rules.GetVector3Item(idx); | ||
278 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
279 | break; | ||
280 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
281 | idx++; | ||
282 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
283 | break; | ||
284 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
285 | idx++; | ||
286 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
289 | idx++; | ||
290 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
291 | break; | ||
292 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
293 | idx++; | ||
294 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
295 | break; | ||
296 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
297 | idx++; | ||
298 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
299 | break; | ||
300 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
301 | idx++; | ||
302 | iV = rules.GetVector3Item(idx); | ||
303 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
304 | break; | ||
305 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
306 | idx++; | ||
307 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
308 | break; | ||
309 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
310 | idx++; | ||
311 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
312 | break; | ||
313 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
314 | idx++; | ||
315 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
316 | break; | ||
317 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
318 | idx++; | ||
319 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
320 | break; | ||
321 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
322 | idx++; | ||
323 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
324 | break; | ||
325 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
326 | idx++; | ||
327 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
328 | break; | ||
329 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
330 | idx++; | ||
331 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
332 | break; | ||
333 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
334 | idx++; | ||
335 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
336 | break; | ||
337 | case (int)ScriptBaseClass.WL_HORIZON: | ||
338 | idx++; | ||
339 | iQ = rules.GetQuaternionItem(idx); | ||
340 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
341 | break; | ||
342 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
343 | idx++; | ||
344 | iV = rules.GetVector3Item(idx); | ||
345 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
346 | break; | ||
347 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
348 | idx++; | ||
349 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
350 | break; | ||
351 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
352 | idx++; | ||
353 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
354 | break; | ||
355 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
356 | idx++; | ||
357 | iV = rules.GetVector3Item(idx); | ||
358 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
359 | break; | ||
360 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
361 | idx++; | ||
362 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
365 | idx++; | ||
366 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
369 | idx++; | ||
370 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
371 | break; | ||
372 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
373 | idx++; | ||
374 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
375 | break; | ||
376 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
377 | idx++; | ||
378 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
379 | break; | ||
380 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
381 | idx++; | ||
382 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
383 | break; | ||
384 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
385 | idx++; | ||
386 | iQ = rules.GetQuaternionItem(idx); | ||
387 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
388 | break; | ||
389 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
390 | idx++; | ||
391 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
392 | break; | ||
393 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
394 | idx++; | ||
395 | iV = rules.GetVector3Item(idx); | ||
396 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
397 | break; | ||
398 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
399 | idx++; | ||
400 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
401 | break; | ||
402 | } | ||
403 | idx++; | ||
404 | } | ||
405 | return wl; | ||
406 | } | ||
407 | /// <summary> | ||
408 | /// Set the current Windlight scene | ||
409 | /// </summary> | ||
410 | /// <param name="rules"></param> | ||
411 | /// <returns>success: true or false</returns> | ||
412 | public int cmSetWindlightScene(LSL_List rules) | ||
413 | { | ||
414 | if (!m_CMFunctionsEnabled) | ||
415 | { | ||
416 | CMShoutError("Careminster functions are not enabled."); | ||
417 | return 0; | ||
418 | } | ||
419 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
420 | { | ||
421 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
422 | return 0; | ||
423 | } | ||
424 | int success = 0; | ||
425 | m_host.AddScriptLPS(1); | ||
426 | if (Meta7WindlightModule.EnableWindlight) | ||
427 | { | ||
428 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
429 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
430 | success = 1; | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | CMShoutError("Windlight module is disabled"); | ||
435 | return 0; | ||
436 | } | ||
437 | return success; | ||
438 | } | ||
439 | /// <summary> | ||
440 | /// Set the current Windlight scene to a target avatar | ||
441 | /// </summary> | ||
442 | /// <param name="rules"></param> | ||
443 | /// <returns>success: true or false</returns> | ||
444 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
445 | { | ||
446 | if (!m_CMFunctionsEnabled) | ||
447 | { | ||
448 | CMShoutError("Careminster functions are not enabled."); | ||
449 | return 0; | ||
450 | } | ||
451 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
452 | { | ||
453 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
454 | return 0; | ||
455 | } | ||
456 | int success = 0; | ||
457 | m_host.AddScriptLPS(1); | ||
458 | if (Meta7WindlightModule.EnableWindlight) | ||
459 | { | ||
460 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
461 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
462 | success = 1; | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | CMShoutError("Windlight module is disabled"); | ||
467 | return 0; | ||
468 | } | ||
469 | return success; | ||
470 | } | ||
471 | |||
472 | } | ||
473 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c9998c0..085d61f 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 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
@@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
151 | get { return m_ScriptEngine.World; } | 152 | get { return m_ScriptEngine.World; } |
152 | } | 153 | } |
153 | 154 | ||
155 | [DebuggerNonUserCode] | ||
154 | public void state(string newState) | 156 | public void state(string newState) |
155 | { | 157 | { |
156 | m_ScriptEngine.SetState(m_itemID, newState); | 158 | m_ScriptEngine.SetState(m_itemID, newState); |
@@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | /// Reset the named script. The script must be present | 162 | /// Reset the named script. The script must be present |
161 | /// in the same prim. | 163 | /// in the same prim. |
162 | /// </summary> | 164 | /// </summary> |
165 | [DebuggerNonUserCode] | ||
163 | public void llResetScript() | 166 | public void llResetScript() |
164 | { | 167 | { |
165 | m_host.AddScriptLPS(1); | 168 | m_host.AddScriptLPS(1); |
@@ -218,7 +221,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
218 | 221 | ||
219 | public List<SceneObjectPart> GetLinkParts(int linkType) | 222 | public List<SceneObjectPart> GetLinkParts(int linkType) |
220 | { | 223 | { |
221 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 224 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
225 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
226 | return ret; | ||
222 | ret.Add(m_host); | 227 | ret.Add(m_host); |
223 | 228 | ||
224 | switch (linkType) | 229 | switch (linkType) |
@@ -272,40 +277,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 277 | protected UUID InventorySelf() |
273 | { | 278 | { |
274 | UUID invItemID = new UUID(); | 279 | UUID invItemID = new UUID(); |
275 | 280 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 281 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
282 | { | ||
283 | m_host.TaskInventory.LockItemsForRead(true); | ||
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 287 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 288 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 289 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 290 | invItemID = inv.Key; |
281 | { | 291 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | if (unlock) | |
295 | { | ||
296 | m_host.TaskInventory.LockItemsForRead(false); | ||
297 | } | ||
288 | return invItemID; | 298 | return invItemID; |
289 | } | 299 | } |
290 | 300 | ||
291 | protected UUID InventoryKey(string name, int type) | 301 | protected UUID InventoryKey(string name, int type) |
292 | { | 302 | { |
293 | m_host.AddScriptLPS(1); | 303 | m_host.AddScriptLPS(1); |
294 | 304 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 305 | |
306 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 307 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 308 | if (inv.Value.Name == name) |
298 | { | 309 | { |
299 | if (inv.Value.Name == name) | 310 | m_host.TaskInventory.LockItemsForRead(false); |
311 | |||
312 | if (inv.Value.Type != type) | ||
300 | { | 313 | { |
301 | if (inv.Value.Type != type) | 314 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 315 | } |
316 | |||
317 | return inv.Value.AssetID; | ||
306 | } | 318 | } |
307 | } | 319 | } |
308 | 320 | ||
321 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 322 | return UUID.Zero; |
310 | } | 323 | } |
311 | 324 | ||
@@ -313,17 +326,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 326 | { |
314 | m_host.AddScriptLPS(1); | 327 | m_host.AddScriptLPS(1); |
315 | 328 | ||
316 | lock (m_host.TaskInventory) | 329 | |
330 | m_host.TaskInventory.LockItemsForRead(true); | ||
331 | |||
332 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 333 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 334 | if (inv.Value.Name == name) |
319 | { | 335 | { |
320 | if (inv.Value.Name == name) | 336 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 337 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 338 | } |
325 | } | 339 | } |
326 | 340 | ||
341 | m_host.TaskInventory.LockItemsForRead(false); | ||
342 | |||
343 | |||
327 | return UUID.Zero; | 344 | return UUID.Zero; |
328 | } | 345 | } |
329 | 346 | ||
@@ -705,6 +722,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
705 | { | 722 | { |
706 | //A and B should both be normalized | 723 | //A and B should both be normalized |
707 | m_host.AddScriptLPS(1); | 724 | m_host.AddScriptLPS(1); |
725 | /* This method is more accurate than the SL one, and thus causes problems | ||
726 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. | ||
727 | |||
708 | double dotProduct = LSL_Vector.Dot(a, b); | 728 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 729 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | 730 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
@@ -721,8 +741,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
721 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 741 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | 742 | ||
723 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | 743 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | } | 744 | */ |
725 | 745 | ||
746 | // This method mimics the 180 errors found in SL | ||
747 | // See www.euclideanspace.com... angleBetween | ||
748 | LSL_Vector vec_a = a; | ||
749 | LSL_Vector vec_b = b; | ||
750 | |||
751 | // Eliminate zero length | ||
752 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
753 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
754 | if (vec_a_mag < 0.00001 || | ||
755 | vec_b_mag < 0.00001) | ||
756 | { | ||
757 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
758 | } | ||
759 | |||
760 | // Normalize | ||
761 | vec_a = llVecNorm(vec_a); | ||
762 | vec_b = llVecNorm(vec_b); | ||
763 | |||
764 | // Calculate axis and rotation angle | ||
765 | LSL_Vector axis = vec_a % vec_b; | ||
766 | LSL_Float cos_theta = vec_a * vec_b; | ||
767 | |||
768 | // Check if parallel | ||
769 | if (cos_theta > 0.99999) | ||
770 | { | ||
771 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
772 | } | ||
773 | |||
774 | // Check if anti-parallel | ||
775 | else if (cos_theta < -0.99999) | ||
776 | { | ||
777 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); | ||
778 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); | ||
779 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); | ||
780 | } | ||
781 | else // other rotation | ||
782 | { | ||
783 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; | ||
784 | axis = llVecNorm(axis); | ||
785 | double x, y, z, s, t; | ||
786 | s = Math.Cos(theta); | ||
787 | t = Math.Sin(theta); | ||
788 | x = axis.x * t; | ||
789 | y = axis.y * t; | ||
790 | z = axis.z * t; | ||
791 | return new LSL_Rotation(x,y,z,s); | ||
792 | } | ||
793 | } | ||
794 | |||
726 | public void llWhisper(int channelID, string text) | 795 | public void llWhisper(int channelID, string text) |
727 | { | 796 | { |
728 | m_host.AddScriptLPS(1); | 797 | m_host.AddScriptLPS(1); |
@@ -1121,7 +1190,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1121 | } | 1190 | } |
1122 | 1191 | ||
1123 | public void llSetStatus(int status, int value) | 1192 | public void llSetStatus(int status, int value) |
1124 | { | 1193 | { |
1194 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1195 | return; | ||
1125 | m_host.AddScriptLPS(1); | 1196 | m_host.AddScriptLPS(1); |
1126 | 1197 | ||
1127 | int statusrotationaxis = 0; | 1198 | int statusrotationaxis = 0; |
@@ -1275,7 +1346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1275 | } | 1346 | } |
1276 | 1347 | ||
1277 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) | 1348 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) |
1278 | { | 1349 | { |
1279 | // TODO: this needs to trigger a persistance save as well | 1350 | // TODO: this needs to trigger a persistance save as well |
1280 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1351 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1281 | return; | 1352 | return; |
@@ -1334,7 +1405,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1334 | } | 1405 | } |
1335 | 1406 | ||
1336 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | 1407 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) |
1337 | { | 1408 | { |
1409 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1410 | return; | ||
1411 | |||
1338 | Primitive.TextureEntry tex = part.Shape.Textures; | 1412 | Primitive.TextureEntry tex = part.Shape.Textures; |
1339 | Color4 texcolor; | 1413 | Color4 texcolor; |
1340 | if (face >= 0 && face < GetNumberOfSides(part)) | 1414 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1371,7 +1445,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1371 | } | 1445 | } |
1372 | 1446 | ||
1373 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1447 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1374 | { | 1448 | { |
1449 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1450 | return; | ||
1451 | |||
1375 | Primitive.TextureEntry tex = part.Shape.Textures; | 1452 | Primitive.TextureEntry tex = part.Shape.Textures; |
1376 | MappingType textype; | 1453 | MappingType textype; |
1377 | textype = MappingType.Default; | 1454 | textype = MappingType.Default; |
@@ -1401,7 +1478,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1401 | } | 1478 | } |
1402 | 1479 | ||
1403 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1480 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1404 | { | 1481 | { |
1482 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1483 | return; | ||
1484 | |||
1405 | Primitive.TextureEntry tex = part.Shape.Textures; | 1485 | Primitive.TextureEntry tex = part.Shape.Textures; |
1406 | if (face >= 0 && face < GetNumberOfSides(part)) | 1486 | if (face >= 0 && face < GetNumberOfSides(part)) |
1407 | { | 1487 | { |
@@ -1426,7 +1506,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1426 | } | 1506 | } |
1427 | 1507 | ||
1428 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1508 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1429 | { | 1509 | { |
1510 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1511 | return; | ||
1430 | 1512 | ||
1431 | Shininess sval = new Shininess(); | 1513 | Shininess sval = new Shininess(); |
1432 | 1514 | ||
@@ -1476,7 +1558,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1476 | } | 1558 | } |
1477 | 1559 | ||
1478 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1560 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1479 | { | 1561 | { |
1562 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1563 | return; | ||
1564 | |||
1480 | Primitive.TextureEntry tex = part.Shape.Textures; | 1565 | Primitive.TextureEntry tex = part.Shape.Textures; |
1481 | if (face >= 0 && face < GetNumberOfSides(part)) | 1566 | if (face >= 0 && face < GetNumberOfSides(part)) |
1482 | { | 1567 | { |
@@ -1543,7 +1628,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1543 | } | 1628 | } |
1544 | 1629 | ||
1545 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1630 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1546 | { | 1631 | { |
1632 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1633 | return; | ||
1634 | |||
1547 | Primitive.TextureEntry tex = part.Shape.Textures; | 1635 | Primitive.TextureEntry tex = part.Shape.Textures; |
1548 | Color4 texcolor; | 1636 | Color4 texcolor; |
1549 | if (face >= 0 && face < GetNumberOfSides(part)) | 1637 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1588,8 +1676,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1588 | /// <param name="Force"></param> | 1676 | /// <param name="Force"></param> |
1589 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1677 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1590 | float wind, float tension, LSL_Vector Force) | 1678 | float wind, float tension, LSL_Vector Force) |
1591 | { | 1679 | { |
1592 | if (part == null) | 1680 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1593 | return; | 1681 | return; |
1594 | 1682 | ||
1595 | if (flexi) | 1683 | if (flexi) |
@@ -1623,8 +1711,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1623 | /// <param name="radius"></param> | 1711 | /// <param name="radius"></param> |
1624 | /// <param name="falloff"></param> | 1712 | /// <param name="falloff"></param> |
1625 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1713 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1626 | { | 1714 | { |
1627 | if (part == null) | 1715 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1628 | return; | 1716 | return; |
1629 | 1717 | ||
1630 | if (light) | 1718 | if (light) |
@@ -1709,7 +1797,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1709 | } | 1797 | } |
1710 | 1798 | ||
1711 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1799 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1712 | { | 1800 | { |
1801 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1802 | return; | ||
1803 | |||
1713 | UUID textureID=new UUID(); | 1804 | UUID textureID=new UUID(); |
1714 | 1805 | ||
1715 | if (!UUID.TryParse(texture, out textureID)) | 1806 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1754,7 +1845,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1754 | } | 1845 | } |
1755 | 1846 | ||
1756 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1847 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1757 | { | 1848 | { |
1849 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1850 | return; | ||
1851 | |||
1758 | Primitive.TextureEntry tex = part.Shape.Textures; | 1852 | Primitive.TextureEntry tex = part.Shape.Textures; |
1759 | if (face >= 0 && face < GetNumberOfSides(part)) | 1853 | if (face >= 0 && face < GetNumberOfSides(part)) |
1760 | { | 1854 | { |
@@ -1790,7 +1884,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1790 | } | 1884 | } |
1791 | 1885 | ||
1792 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1886 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1793 | { | 1887 | { |
1888 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1889 | return; | ||
1890 | |||
1794 | Primitive.TextureEntry tex = part.Shape.Textures; | 1891 | Primitive.TextureEntry tex = part.Shape.Textures; |
1795 | if (face >= 0 && face < GetNumberOfSides(part)) | 1892 | if (face >= 0 && face < GetNumberOfSides(part)) |
1796 | { | 1893 | { |
@@ -1826,7 +1923,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1826 | } | 1923 | } |
1827 | 1924 | ||
1828 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1925 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1829 | { | 1926 | { |
1927 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1928 | return; | ||
1929 | |||
1830 | Primitive.TextureEntry tex = part.Shape.Textures; | 1930 | Primitive.TextureEntry tex = part.Shape.Textures; |
1831 | if (face >= 0 && face < GetNumberOfSides(part)) | 1931 | if (face >= 0 && face < GetNumberOfSides(part)) |
1832 | { | 1932 | { |
@@ -1896,7 +1996,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1896 | } | 1996 | } |
1897 | 1997 | ||
1898 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 1998 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1899 | { | 1999 | { |
2000 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2001 | return; | ||
2002 | |||
1900 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2003 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1901 | LSL_Vector currentPos = llGetLocalPos(); | 2004 | LSL_Vector currentPos = llGetLocalPos(); |
1902 | 2005 | ||
@@ -1990,7 +2093,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1990 | } | 2093 | } |
1991 | 2094 | ||
1992 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2095 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1993 | { | 2096 | { |
2097 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2098 | return; | ||
2099 | |||
1994 | part.UpdateRotation(rot); | 2100 | part.UpdateRotation(rot); |
1995 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2101 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1996 | 2102 | ||
@@ -2554,12 +2660,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2554 | 2660 | ||
2555 | m_host.AddScriptLPS(1); | 2661 | m_host.AddScriptLPS(1); |
2556 | 2662 | ||
2663 | m_host.TaskInventory.LockItemsForRead(true); | ||
2557 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2664 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2558 | 2665 | m_host.TaskInventory.LockItemsForRead(false); | |
2559 | lock (m_host.TaskInventory) | ||
2560 | { | ||
2561 | item = m_host.TaskInventory[invItemID]; | ||
2562 | } | ||
2563 | 2666 | ||
2564 | if (item.PermsGranter == UUID.Zero) | 2667 | if (item.PermsGranter == UUID.Zero) |
2565 | return 0; | 2668 | return 0; |
@@ -2634,6 +2737,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2634 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2737 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2635 | return; | 2738 | return; |
2636 | 2739 | ||
2740 | //Clone is thread-safe | ||
2637 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2741 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2638 | 2742 | ||
2639 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2743 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2719,6 +2823,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2719 | // Orient the object to the angle calculated | 2823 | // Orient the object to the angle calculated |
2720 | llSetRot(rot); | 2824 | llSetRot(rot); |
2721 | } | 2825 | } |
2826 | |||
2827 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2828 | { | ||
2829 | m_host.AddScriptLPS(1); | ||
2830 | // NotImplemented("llRotLookAt"); | ||
2831 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2832 | |||
2833 | } | ||
2722 | 2834 | ||
2723 | public void llStopLookAt() | 2835 | public void llStopLookAt() |
2724 | { | 2836 | { |
@@ -2766,13 +2878,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2766 | { | 2878 | { |
2767 | TaskInventoryItem item; | 2879 | TaskInventoryItem item; |
2768 | 2880 | ||
2769 | lock (m_host.TaskInventory) | 2881 | m_host.TaskInventory.LockItemsForRead(true); |
2882 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2770 | { | 2883 | { |
2771 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2884 | m_host.TaskInventory.LockItemsForRead(false); |
2772 | return; | 2885 | return; |
2773 | else | ||
2774 | item = m_host.TaskInventory[InventorySelf()]; | ||
2775 | } | 2886 | } |
2887 | else | ||
2888 | { | ||
2889 | item = m_host.TaskInventory[InventorySelf()]; | ||
2890 | } | ||
2891 | m_host.TaskInventory.LockItemsForRead(false); | ||
2776 | 2892 | ||
2777 | if (item.PermsGranter != UUID.Zero) | 2893 | if (item.PermsGranter != UUID.Zero) |
2778 | { | 2894 | { |
@@ -2794,13 +2910,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2794 | { | 2910 | { |
2795 | TaskInventoryItem item; | 2911 | TaskInventoryItem item; |
2796 | 2912 | ||
2913 | m_host.TaskInventory.LockItemsForRead(true); | ||
2797 | lock (m_host.TaskInventory) | 2914 | lock (m_host.TaskInventory) |
2798 | { | 2915 | { |
2916 | |||
2799 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2917 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2918 | { | ||
2919 | m_host.TaskInventory.LockItemsForRead(false); | ||
2800 | return; | 2920 | return; |
2921 | } | ||
2801 | else | 2922 | else |
2923 | { | ||
2802 | item = m_host.TaskInventory[InventorySelf()]; | 2924 | item = m_host.TaskInventory[InventorySelf()]; |
2925 | } | ||
2803 | } | 2926 | } |
2927 | m_host.TaskInventory.LockItemsForRead(false); | ||
2804 | 2928 | ||
2805 | m_host.AddScriptLPS(1); | 2929 | m_host.AddScriptLPS(1); |
2806 | 2930 | ||
@@ -2837,13 +2961,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2837 | 2961 | ||
2838 | TaskInventoryItem item; | 2962 | TaskInventoryItem item; |
2839 | 2963 | ||
2840 | lock (m_host.TaskInventory) | 2964 | m_host.TaskInventory.LockItemsForRead(true); |
2965 | |||
2966 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2841 | { | 2967 | { |
2842 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2968 | m_host.TaskInventory.LockItemsForRead(false); |
2843 | return; | 2969 | return; |
2844 | else | ||
2845 | item = m_host.TaskInventory[InventorySelf()]; | ||
2846 | } | 2970 | } |
2971 | else | ||
2972 | { | ||
2973 | item = m_host.TaskInventory[InventorySelf()]; | ||
2974 | } | ||
2975 | |||
2976 | m_host.TaskInventory.LockItemsForRead(false); | ||
2847 | 2977 | ||
2848 | if (item.PermsGranter != m_host.OwnerID) | 2978 | if (item.PermsGranter != m_host.OwnerID) |
2849 | return; | 2979 | return; |
@@ -2869,13 +2999,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2869 | 2999 | ||
2870 | TaskInventoryItem item; | 3000 | TaskInventoryItem item; |
2871 | 3001 | ||
2872 | lock (m_host.TaskInventory) | 3002 | m_host.TaskInventory.LockItemsForRead(true); |
3003 | |||
3004 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2873 | { | 3005 | { |
2874 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3006 | m_host.TaskInventory.LockItemsForRead(false); |
2875 | return; | 3007 | return; |
2876 | else | ||
2877 | item = m_host.TaskInventory[InventorySelf()]; | ||
2878 | } | 3008 | } |
3009 | else | ||
3010 | { | ||
3011 | item = m_host.TaskInventory[InventorySelf()]; | ||
3012 | } | ||
3013 | m_host.TaskInventory.LockItemsForRead(false); | ||
3014 | |||
2879 | 3015 | ||
2880 | if (item.PermsGranter != m_host.OwnerID) | 3016 | if (item.PermsGranter != m_host.OwnerID) |
2881 | return; | 3017 | return; |
@@ -2911,8 +3047,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2911 | return m_host.OwnerID.ToString(); | 3047 | return m_host.OwnerID.ToString(); |
2912 | } | 3048 | } |
2913 | 3049 | ||
3050 | [DebuggerNonUserCode] | ||
2914 | public void llInstantMessage(string user, string message) | 3051 | public void llInstantMessage(string user, string message) |
2915 | { | 3052 | { |
3053 | UUID result; | ||
3054 | if (!UUID.TryParse(user, out result)) | ||
3055 | { | ||
3056 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3057 | return; | ||
3058 | } | ||
3059 | |||
3060 | |||
2916 | m_host.AddScriptLPS(1); | 3061 | m_host.AddScriptLPS(1); |
2917 | 3062 | ||
2918 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3063 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2927,7 +3072,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2927 | UUID friendTransactionID = UUID.Random(); | 3072 | UUID friendTransactionID = UUID.Random(); |
2928 | 3073 | ||
2929 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3074 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2930 | 3075 | ||
2931 | GridInstantMessage msg = new GridInstantMessage(); | 3076 | GridInstantMessage msg = new GridInstantMessage(); |
2932 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3077 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2933 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3078 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3076,13 +3221,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3076 | m_host.AddScriptLPS(1); | 3221 | m_host.AddScriptLPS(1); |
3077 | } | 3222 | } |
3078 | 3223 | ||
3079 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3080 | { | ||
3081 | m_host.AddScriptLPS(1); | ||
3082 | // NotImplemented("llRotLookAt"); | ||
3083 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3084 | } | ||
3085 | |||
3086 | public LSL_Integer llStringLength(string str) | 3224 | public LSL_Integer llStringLength(string str) |
3087 | { | 3225 | { |
3088 | m_host.AddScriptLPS(1); | 3226 | m_host.AddScriptLPS(1); |
@@ -3106,14 +3244,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3106 | 3244 | ||
3107 | TaskInventoryItem item; | 3245 | TaskInventoryItem item; |
3108 | 3246 | ||
3109 | lock (m_host.TaskInventory) | 3247 | m_host.TaskInventory.LockItemsForRead(true); |
3248 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3110 | { | 3249 | { |
3111 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3250 | m_host.TaskInventory.LockItemsForRead(false); |
3112 | return; | 3251 | return; |
3113 | else | ||
3114 | item = m_host.TaskInventory[InventorySelf()]; | ||
3115 | } | 3252 | } |
3116 | 3253 | else | |
3254 | { | ||
3255 | item = m_host.TaskInventory[InventorySelf()]; | ||
3256 | } | ||
3257 | m_host.TaskInventory.LockItemsForRead(false); | ||
3117 | if (item.PermsGranter == UUID.Zero) | 3258 | if (item.PermsGranter == UUID.Zero) |
3118 | return; | 3259 | return; |
3119 | 3260 | ||
@@ -3143,13 +3284,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3143 | 3284 | ||
3144 | TaskInventoryItem item; | 3285 | TaskInventoryItem item; |
3145 | 3286 | ||
3146 | lock (m_host.TaskInventory) | 3287 | m_host.TaskInventory.LockItemsForRead(true); |
3288 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3147 | { | 3289 | { |
3148 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3290 | m_host.TaskInventory.LockItemsForRead(false); |
3149 | return; | 3291 | return; |
3150 | else | 3292 | } |
3151 | item = m_host.TaskInventory[InventorySelf()]; | 3293 | else |
3294 | { | ||
3295 | item = m_host.TaskInventory[InventorySelf()]; | ||
3152 | } | 3296 | } |
3297 | m_host.TaskInventory.LockItemsForRead(false); | ||
3298 | |||
3153 | 3299 | ||
3154 | if (item.PermsGranter == UUID.Zero) | 3300 | if (item.PermsGranter == UUID.Zero) |
3155 | return; | 3301 | return; |
@@ -3222,10 +3368,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3222 | 3368 | ||
3223 | TaskInventoryItem item; | 3369 | TaskInventoryItem item; |
3224 | 3370 | ||
3225 | lock (m_host.TaskInventory) | 3371 | |
3372 | m_host.TaskInventory.LockItemsForRead(true); | ||
3373 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3374 | { | ||
3375 | m_host.TaskInventory.LockItemsForRead(false); | ||
3376 | return; | ||
3377 | } | ||
3378 | else | ||
3226 | { | 3379 | { |
3227 | item = m_host.TaskInventory[invItemID]; | 3380 | item = m_host.TaskInventory[invItemID]; |
3228 | } | 3381 | } |
3382 | m_host.TaskInventory.LockItemsForRead(false); | ||
3229 | 3383 | ||
3230 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3384 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3231 | { | 3385 | { |
@@ -3257,11 +3411,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3257 | 3411 | ||
3258 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3412 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3259 | { | 3413 | { |
3260 | lock (m_host.TaskInventory) | 3414 | m_host.TaskInventory.LockItemsForWrite(true); |
3261 | { | 3415 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3262 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3416 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3263 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3417 | m_host.TaskInventory.LockItemsForWrite(false); |
3264 | } | ||
3265 | 3418 | ||
3266 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3419 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3267 | "run_time_permissions", new Object[] { | 3420 | "run_time_permissions", new Object[] { |
@@ -3281,11 +3434,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3281 | 3434 | ||
3282 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3435 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3283 | { | 3436 | { |
3284 | lock (m_host.TaskInventory) | 3437 | m_host.TaskInventory.LockItemsForWrite(true); |
3285 | { | 3438 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3286 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3439 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3287 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3440 | m_host.TaskInventory.LockItemsForWrite(false); |
3288 | } | ||
3289 | 3441 | ||
3290 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3442 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3291 | "run_time_permissions", new Object[] { | 3443 | "run_time_permissions", new Object[] { |
@@ -3306,11 +3458,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3306 | 3458 | ||
3307 | if (!m_waitingForScriptAnswer) | 3459 | if (!m_waitingForScriptAnswer) |
3308 | { | 3460 | { |
3309 | lock (m_host.TaskInventory) | 3461 | m_host.TaskInventory.LockItemsForWrite(true); |
3310 | { | 3462 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3463 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3312 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3464 | m_host.TaskInventory.LockItemsForWrite(false); |
3313 | } | ||
3314 | 3465 | ||
3315 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3466 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3316 | m_waitingForScriptAnswer=true; | 3467 | m_waitingForScriptAnswer=true; |
@@ -3345,10 +3496,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3345 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3496 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3346 | llReleaseControls(); | 3497 | llReleaseControls(); |
3347 | 3498 | ||
3348 | lock (m_host.TaskInventory) | 3499 | |
3349 | { | 3500 | m_host.TaskInventory.LockItemsForWrite(true); |
3350 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3501 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3351 | } | 3502 | m_host.TaskInventory.LockItemsForWrite(false); |
3503 | |||
3352 | 3504 | ||
3353 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3505 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3354 | "run_time_permissions", new Object[] { | 3506 | "run_time_permissions", new Object[] { |
@@ -3360,16 +3512,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3360 | { | 3512 | { |
3361 | m_host.AddScriptLPS(1); | 3513 | m_host.AddScriptLPS(1); |
3362 | 3514 | ||
3363 | lock (m_host.TaskInventory) | 3515 | m_host.TaskInventory.LockItemsForRead(true); |
3516 | |||
3517 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3364 | { | 3518 | { |
3365 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3519 | if (item.Type == 10 && item.ItemID == m_itemID) |
3366 | { | 3520 | { |
3367 | if (item.Type == 10 && item.ItemID == m_itemID) | 3521 | m_host.TaskInventory.LockItemsForRead(false); |
3368 | { | 3522 | return item.PermsGranter.ToString(); |
3369 | return item.PermsGranter.ToString(); | ||
3370 | } | ||
3371 | } | 3523 | } |
3372 | } | 3524 | } |
3525 | m_host.TaskInventory.LockItemsForRead(false); | ||
3373 | 3526 | ||
3374 | return UUID.Zero.ToString(); | 3527 | return UUID.Zero.ToString(); |
3375 | } | 3528 | } |
@@ -3378,19 +3531,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3378 | { | 3531 | { |
3379 | m_host.AddScriptLPS(1); | 3532 | m_host.AddScriptLPS(1); |
3380 | 3533 | ||
3381 | lock (m_host.TaskInventory) | 3534 | m_host.TaskInventory.LockItemsForRead(true); |
3535 | |||
3536 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3382 | { | 3537 | { |
3383 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3538 | if (item.Type == 10 && item.ItemID == m_itemID) |
3384 | { | 3539 | { |
3385 | if (item.Type == 10 && item.ItemID == m_itemID) | 3540 | int perms = item.PermsMask; |
3386 | { | 3541 | if (m_automaticLinkPermission) |
3387 | int perms = item.PermsMask; | 3542 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3388 | if (m_automaticLinkPermission) | 3543 | m_host.TaskInventory.LockItemsForRead(false); |
3389 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3544 | return perms; |
3390 | return perms; | ||
3391 | } | ||
3392 | } | 3545 | } |
3393 | } | 3546 | } |
3547 | m_host.TaskInventory.LockItemsForRead(false); | ||
3394 | 3548 | ||
3395 | return 0; | 3549 | return 0; |
3396 | } | 3550 | } |
@@ -3423,11 +3577,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3423 | UUID invItemID = InventorySelf(); | 3577 | UUID invItemID = InventorySelf(); |
3424 | 3578 | ||
3425 | TaskInventoryItem item; | 3579 | TaskInventoryItem item; |
3426 | lock (m_host.TaskInventory) | 3580 | m_host.TaskInventory.LockItemsForRead(true); |
3427 | { | 3581 | item = m_host.TaskInventory[invItemID]; |
3428 | item = m_host.TaskInventory[invItemID]; | 3582 | m_host.TaskInventory.LockItemsForRead(false); |
3429 | } | 3583 | |
3430 | |||
3431 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3584 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3432 | && !m_automaticLinkPermission) | 3585 | && !m_automaticLinkPermission) |
3433 | { | 3586 | { |
@@ -3480,16 +3633,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3480 | m_host.AddScriptLPS(1); | 3633 | m_host.AddScriptLPS(1); |
3481 | UUID invItemID = InventorySelf(); | 3634 | UUID invItemID = InventorySelf(); |
3482 | 3635 | ||
3483 | lock (m_host.TaskInventory) | 3636 | m_host.TaskInventory.LockItemsForRead(true); |
3484 | { | ||
3485 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3637 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3486 | && !m_automaticLinkPermission) | 3638 | && !m_automaticLinkPermission) |
3487 | { | 3639 | { |
3488 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3640 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3641 | m_host.TaskInventory.LockItemsForRead(false); | ||
3489 | return; | 3642 | return; |
3490 | } | 3643 | } |
3491 | } | 3644 | m_host.TaskInventory.LockItemsForRead(false); |
3492 | 3645 | ||
3493 | if (linknum < ScriptBaseClass.LINK_THIS) | 3646 | if (linknum < ScriptBaseClass.LINK_THIS) |
3494 | return; | 3647 | return; |
3495 | 3648 | ||
@@ -3666,17 +3819,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3666 | m_host.AddScriptLPS(1); | 3819 | m_host.AddScriptLPS(1); |
3667 | int count = 0; | 3820 | int count = 0; |
3668 | 3821 | ||
3669 | lock (m_host.TaskInventory) | 3822 | m_host.TaskInventory.LockItemsForRead(true); |
3823 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3670 | { | 3824 | { |
3671 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3825 | if (inv.Value.Type == type || type == -1) |
3672 | { | 3826 | { |
3673 | if (inv.Value.Type == type || type == -1) | 3827 | count = count + 1; |
3674 | { | ||
3675 | count = count + 1; | ||
3676 | } | ||
3677 | } | 3828 | } |
3678 | } | 3829 | } |
3679 | 3830 | ||
3831 | m_host.TaskInventory.LockItemsForRead(false); | ||
3680 | return count; | 3832 | return count; |
3681 | } | 3833 | } |
3682 | 3834 | ||
@@ -3685,16 +3837,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3685 | m_host.AddScriptLPS(1); | 3837 | m_host.AddScriptLPS(1); |
3686 | ArrayList keys = new ArrayList(); | 3838 | ArrayList keys = new ArrayList(); |
3687 | 3839 | ||
3688 | lock (m_host.TaskInventory) | 3840 | m_host.TaskInventory.LockItemsForRead(true); |
3841 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3689 | { | 3842 | { |
3690 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3843 | if (inv.Value.Type == type || type == -1) |
3691 | { | 3844 | { |
3692 | if (inv.Value.Type == type || type == -1) | 3845 | keys.Add(inv.Value.Name); |
3693 | { | ||
3694 | keys.Add(inv.Value.Name); | ||
3695 | } | ||
3696 | } | 3846 | } |
3697 | } | 3847 | } |
3848 | m_host.TaskInventory.LockItemsForRead(false); | ||
3698 | 3849 | ||
3699 | if (keys.Count == 0) | 3850 | if (keys.Count == 0) |
3700 | { | 3851 | { |
@@ -3731,20 +3882,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3731 | } | 3882 | } |
3732 | 3883 | ||
3733 | // move the first object found with this inventory name | 3884 | // move the first object found with this inventory name |
3734 | lock (m_host.TaskInventory) | 3885 | m_host.TaskInventory.LockItemsForRead(true); |
3886 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3735 | { | 3887 | { |
3736 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3888 | if (inv.Value.Name == inventory) |
3737 | { | 3889 | { |
3738 | if (inv.Value.Name == inventory) | 3890 | found = true; |
3739 | { | 3891 | objId = inv.Key; |
3740 | found = true; | 3892 | assetType = inv.Value.Type; |
3741 | objId = inv.Key; | 3893 | objName = inv.Value.Name; |
3742 | assetType = inv.Value.Type; | 3894 | break; |
3743 | objName = inv.Value.Name; | ||
3744 | break; | ||
3745 | } | ||
3746 | } | 3895 | } |
3747 | } | 3896 | } |
3897 | m_host.TaskInventory.LockItemsForRead(false); | ||
3748 | 3898 | ||
3749 | if (!found) | 3899 | if (!found) |
3750 | { | 3900 | { |
@@ -3789,24 +3939,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3789 | ScriptSleep(3000); | 3939 | ScriptSleep(3000); |
3790 | } | 3940 | } |
3791 | 3941 | ||
3942 | [DebuggerNonUserCode] | ||
3792 | public void llRemoveInventory(string name) | 3943 | public void llRemoveInventory(string name) |
3793 | { | 3944 | { |
3794 | m_host.AddScriptLPS(1); | 3945 | m_host.AddScriptLPS(1); |
3795 | 3946 | ||
3796 | lock (m_host.TaskInventory) | 3947 | m_host.TaskInventory.LockItemsForRead(true); |
3948 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3797 | { | 3949 | { |
3798 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3950 | if (item.Name == name) |
3799 | { | 3951 | { |
3800 | if (item.Name == name) | 3952 | if (item.ItemID == m_itemID) |
3801 | { | 3953 | throw new ScriptDeleteException(); |
3802 | if (item.ItemID == m_itemID) | 3954 | else |
3803 | throw new ScriptDeleteException(); | 3955 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3804 | else | 3956 | |
3805 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3957 | m_host.TaskInventory.LockItemsForRead(false); |
3806 | return; | 3958 | return; |
3807 | } | ||
3808 | } | 3959 | } |
3809 | } | 3960 | } |
3961 | m_host.TaskInventory.LockItemsForRead(false); | ||
3810 | } | 3962 | } |
3811 | 3963 | ||
3812 | public void llSetText(string text, LSL_Vector color, double alpha) | 3964 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3896,6 +4048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3896 | { | 4048 | { |
3897 | m_host.AddScriptLPS(1); | 4049 | m_host.AddScriptLPS(1); |
3898 | 4050 | ||
4051 | //Clone is thread safe | ||
3899 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4052 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3900 | 4053 | ||
3901 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4054 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3986,17 +4139,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3986 | UUID soundId = UUID.Zero; | 4139 | UUID soundId = UUID.Zero; |
3987 | if (!UUID.TryParse(impact_sound, out soundId)) | 4140 | if (!UUID.TryParse(impact_sound, out soundId)) |
3988 | { | 4141 | { |
3989 | lock (m_host.TaskInventory) | 4142 | m_host.TaskInventory.LockItemsForRead(true); |
4143 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3990 | { | 4144 | { |
3991 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4145 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3992 | { | 4146 | { |
3993 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4147 | soundId = item.AssetID; |
3994 | { | 4148 | break; |
3995 | soundId = item.AssetID; | ||
3996 | break; | ||
3997 | } | ||
3998 | } | 4149 | } |
3999 | } | 4150 | } |
4151 | m_host.TaskInventory.LockItemsForRead(false); | ||
4000 | } | 4152 | } |
4001 | m_host.CollisionSound = soundId; | 4153 | m_host.CollisionSound = soundId; |
4002 | m_host.CollisionSoundVolume = (float)impact_volume; | 4154 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4042,6 +4194,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4042 | UUID partItemID; | 4194 | UUID partItemID; |
4043 | foreach (SceneObjectPart part in parts) | 4195 | foreach (SceneObjectPart part in parts) |
4044 | { | 4196 | { |
4197 | //Clone is thread safe | ||
4045 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4198 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4046 | 4199 | ||
4047 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4200 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4256,17 +4409,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4256 | 4409 | ||
4257 | m_host.AddScriptLPS(1); | 4410 | m_host.AddScriptLPS(1); |
4258 | 4411 | ||
4259 | lock (m_host.TaskInventory) | 4412 | m_host.TaskInventory.LockItemsForRead(true); |
4413 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4260 | { | 4414 | { |
4261 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4415 | if (item.Type == 10 && item.ItemID == m_itemID) |
4262 | { | 4416 | { |
4263 | if (item.Type == 10 && item.ItemID == m_itemID) | 4417 | result = item.Name!=null?item.Name:String.Empty; |
4264 | { | 4418 | break; |
4265 | result = item.Name!=null?item.Name:String.Empty; | ||
4266 | break; | ||
4267 | } | ||
4268 | } | 4419 | } |
4269 | } | 4420 | } |
4421 | m_host.TaskInventory.LockItemsForRead(false); | ||
4270 | 4422 | ||
4271 | return result; | 4423 | return result; |
4272 | } | 4424 | } |
@@ -4524,23 +4676,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4524 | { | 4676 | { |
4525 | m_host.AddScriptLPS(1); | 4677 | m_host.AddScriptLPS(1); |
4526 | 4678 | ||
4527 | lock (m_host.TaskInventory) | 4679 | m_host.TaskInventory.LockItemsForRead(true); |
4680 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4528 | { | 4681 | { |
4529 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4682 | if (inv.Value.Name == name) |
4530 | { | 4683 | { |
4531 | if (inv.Value.Name == name) | 4684 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4532 | { | 4685 | { |
4533 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4686 | m_host.TaskInventory.LockItemsForRead(false); |
4534 | { | 4687 | return inv.Value.AssetID.ToString(); |
4535 | return inv.Value.AssetID.ToString(); | 4688 | } |
4536 | } | 4689 | else |
4537 | else | 4690 | { |
4538 | { | 4691 | m_host.TaskInventory.LockItemsForRead(false); |
4539 | return UUID.Zero.ToString(); | 4692 | return UUID.Zero.ToString(); |
4540 | } | ||
4541 | } | 4693 | } |
4542 | } | 4694 | } |
4543 | } | 4695 | } |
4696 | m_host.TaskInventory.LockItemsForRead(false); | ||
4544 | 4697 | ||
4545 | return UUID.Zero.ToString(); | 4698 | return UUID.Zero.ToString(); |
4546 | } | 4699 | } |
@@ -6036,14 +6189,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6036 | 6189 | ||
6037 | protected UUID GetTaskInventoryItem(string name) | 6190 | protected UUID GetTaskInventoryItem(string name) |
6038 | { | 6191 | { |
6039 | lock (m_host.TaskInventory) | 6192 | m_host.TaskInventory.LockItemsForRead(true); |
6193 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6040 | { | 6194 | { |
6041 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6195 | if (inv.Value.Name == name) |
6042 | { | 6196 | { |
6043 | if (inv.Value.Name == name) | 6197 | m_host.TaskInventory.LockItemsForRead(false); |
6044 | return inv.Key; | 6198 | return inv.Key; |
6045 | } | 6199 | } |
6046 | } | 6200 | } |
6201 | m_host.TaskInventory.LockItemsForRead(false); | ||
6047 | 6202 | ||
6048 | return UUID.Zero; | 6203 | return UUID.Zero; |
6049 | } | 6204 | } |
@@ -6359,22 +6514,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6359 | } | 6514 | } |
6360 | 6515 | ||
6361 | // copy the first script found with this inventory name | 6516 | // copy the first script found with this inventory name |
6362 | lock (m_host.TaskInventory) | 6517 | m_host.TaskInventory.LockItemsForRead(true); |
6518 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6363 | { | 6519 | { |
6364 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6520 | if (inv.Value.Name == name) |
6365 | { | 6521 | { |
6366 | if (inv.Value.Name == name) | 6522 | // make sure the object is a script |
6523 | if (10 == inv.Value.Type) | ||
6367 | { | 6524 | { |
6368 | // make sure the object is a script | 6525 | found = true; |
6369 | if (10 == inv.Value.Type) | 6526 | srcId = inv.Key; |
6370 | { | 6527 | break; |
6371 | found = true; | ||
6372 | srcId = inv.Key; | ||
6373 | break; | ||
6374 | } | ||
6375 | } | 6528 | } |
6376 | } | 6529 | } |
6377 | } | 6530 | } |
6531 | m_host.TaskInventory.LockItemsForRead(false); | ||
6378 | 6532 | ||
6379 | if (!found) | 6533 | if (!found) |
6380 | { | 6534 | { |
@@ -6456,8 +6610,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6456 | } | 6610 | } |
6457 | 6611 | ||
6458 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6612 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6459 | { | 6613 | { |
6460 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6614 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6615 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6616 | return shapeBlock; | ||
6461 | 6617 | ||
6462 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6618 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6463 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6619 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6527,7 +6683,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6527 | } | 6683 | } |
6528 | 6684 | ||
6529 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6685 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6530 | { | 6686 | { |
6687 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6688 | return; | ||
6689 | |||
6531 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6690 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6532 | 6691 | ||
6533 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6692 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6576,7 +6735,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6576 | } | 6735 | } |
6577 | 6736 | ||
6578 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6737 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6579 | { | 6738 | { |
6739 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6740 | return; | ||
6741 | |||
6580 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6742 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6581 | 6743 | ||
6582 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6744 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6618,7 +6780,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6618 | } | 6780 | } |
6619 | 6781 | ||
6620 | 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) | 6782 | 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) |
6621 | { | 6783 | { |
6784 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6785 | return; | ||
6786 | |||
6622 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6787 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6623 | 6788 | ||
6624 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6789 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6739,7 +6904,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6739 | } | 6904 | } |
6740 | 6905 | ||
6741 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6906 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6742 | { | 6907 | { |
6908 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6909 | return; | ||
6910 | |||
6743 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6911 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6744 | UUID sculptId; | 6912 | UUID sculptId; |
6745 | 6913 | ||
@@ -6773,14 +6941,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6773 | } | 6941 | } |
6774 | 6942 | ||
6775 | public void llSetPrimitiveParams(LSL_List rules) | 6943 | public void llSetPrimitiveParams(LSL_List rules) |
6776 | { | 6944 | { |
6777 | m_host.AddScriptLPS(1); | 6945 | m_host.AddScriptLPS(1); |
6778 | SetPrimParams(m_host, rules); | 6946 | SetPrimParams(m_host, rules); |
6779 | } | 6947 | } |
6780 | 6948 | ||
6781 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 6949 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6782 | { | 6950 | { |
6783 | m_host.AddScriptLPS(1); | 6951 | m_host.AddScriptLPS(1); |
6784 | 6952 | ||
6785 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6953 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6786 | 6954 | ||
@@ -6789,7 +6957,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6789 | } | 6957 | } |
6790 | 6958 | ||
6791 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 6959 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6792 | { | 6960 | { |
6961 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6962 | return; | ||
6963 | |||
6793 | int idx = 0; | 6964 | int idx = 0; |
6794 | 6965 | ||
6795 | while (idx < rules.Length) | 6966 | while (idx < rules.Length) |
@@ -8183,28 +8354,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8183 | { | 8354 | { |
8184 | m_host.AddScriptLPS(1); | 8355 | m_host.AddScriptLPS(1); |
8185 | 8356 | ||
8186 | lock (m_host.TaskInventory) | 8357 | m_host.TaskInventory.LockItemsForRead(true); |
8358 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8187 | { | 8359 | { |
8188 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8360 | if (inv.Value.Name == item) |
8189 | { | 8361 | { |
8190 | if (inv.Value.Name == item) | 8362 | m_host.TaskInventory.LockItemsForRead(false); |
8363 | switch (mask) | ||
8191 | { | 8364 | { |
8192 | switch (mask) | 8365 | case 0: |
8193 | { | 8366 | return (int)inv.Value.BasePermissions; |
8194 | case 0: | 8367 | case 1: |
8195 | return (int)inv.Value.BasePermissions; | 8368 | return (int)inv.Value.CurrentPermissions; |
8196 | case 1: | 8369 | case 2: |
8197 | return (int)inv.Value.CurrentPermissions; | 8370 | return (int)inv.Value.GroupPermissions; |
8198 | case 2: | 8371 | case 3: |
8199 | return (int)inv.Value.GroupPermissions; | 8372 | return (int)inv.Value.EveryonePermissions; |
8200 | case 3: | 8373 | case 4: |
8201 | return (int)inv.Value.EveryonePermissions; | 8374 | return (int)inv.Value.NextPermissions; |
8202 | case 4: | ||
8203 | return (int)inv.Value.NextPermissions; | ||
8204 | } | ||
8205 | } | 8375 | } |
8206 | } | 8376 | } |
8207 | } | 8377 | } |
8378 | m_host.TaskInventory.LockItemsForRead(false); | ||
8208 | 8379 | ||
8209 | return -1; | 8380 | return -1; |
8210 | } | 8381 | } |
@@ -8219,16 +8390,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8219 | { | 8390 | { |
8220 | m_host.AddScriptLPS(1); | 8391 | m_host.AddScriptLPS(1); |
8221 | 8392 | ||
8222 | lock (m_host.TaskInventory) | 8393 | m_host.TaskInventory.LockItemsForRead(true); |
8394 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8223 | { | 8395 | { |
8224 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8396 | if (inv.Value.Name == item) |
8225 | { | 8397 | { |
8226 | if (inv.Value.Name == item) | 8398 | m_host.TaskInventory.LockItemsForRead(false); |
8227 | { | 8399 | return inv.Value.CreatorID.ToString(); |
8228 | return inv.Value.CreatorID.ToString(); | ||
8229 | } | ||
8230 | } | 8400 | } |
8231 | } | 8401 | } |
8402 | m_host.TaskInventory.LockItemsForRead(false); | ||
8232 | 8403 | ||
8233 | llSay(0, "No item name '" + item + "'"); | 8404 | llSay(0, "No item name '" + item + "'"); |
8234 | 8405 | ||
@@ -8752,16 +8923,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8752 | { | 8923 | { |
8753 | m_host.AddScriptLPS(1); | 8924 | m_host.AddScriptLPS(1); |
8754 | 8925 | ||
8755 | lock (m_host.TaskInventory) | 8926 | m_host.TaskInventory.LockItemsForRead(true); |
8927 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8756 | { | 8928 | { |
8757 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8929 | if (inv.Value.Name == name) |
8758 | { | 8930 | { |
8759 | if (inv.Value.Name == name) | 8931 | m_host.TaskInventory.LockItemsForRead(false); |
8760 | { | 8932 | return inv.Value.Type; |
8761 | return inv.Value.Type; | ||
8762 | } | ||
8763 | } | 8933 | } |
8764 | } | 8934 | } |
8935 | m_host.TaskInventory.LockItemsForRead(false); | ||
8765 | 8936 | ||
8766 | return -1; | 8937 | return -1; |
8767 | } | 8938 | } |
@@ -8792,17 +8963,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8792 | if (invItemID == UUID.Zero) | 8963 | if (invItemID == UUID.Zero) |
8793 | return new LSL_Vector(); | 8964 | return new LSL_Vector(); |
8794 | 8965 | ||
8795 | lock (m_host.TaskInventory) | 8966 | m_host.TaskInventory.LockItemsForRead(true); |
8967 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8796 | { | 8968 | { |
8797 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8969 | m_host.TaskInventory.LockItemsForRead(false); |
8798 | return new LSL_Vector(); | 8970 | return new LSL_Vector(); |
8971 | } | ||
8799 | 8972 | ||
8800 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8973 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8801 | { | 8974 | { |
8802 | ShoutError("No permissions to track the camera"); | 8975 | ShoutError("No permissions to track the camera"); |
8803 | return new LSL_Vector(); | 8976 | m_host.TaskInventory.LockItemsForRead(false); |
8804 | } | 8977 | return new LSL_Vector(); |
8805 | } | 8978 | } |
8979 | m_host.TaskInventory.LockItemsForRead(false); | ||
8806 | 8980 | ||
8807 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8981 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8808 | if (presence != null) | 8982 | if (presence != null) |
@@ -8820,17 +8994,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8820 | if (invItemID == UUID.Zero) | 8994 | if (invItemID == UUID.Zero) |
8821 | return new LSL_Rotation(); | 8995 | return new LSL_Rotation(); |
8822 | 8996 | ||
8823 | lock (m_host.TaskInventory) | 8997 | m_host.TaskInventory.LockItemsForRead(true); |
8998 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8824 | { | 8999 | { |
8825 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9000 | m_host.TaskInventory.LockItemsForRead(false); |
8826 | return new LSL_Rotation(); | 9001 | return new LSL_Rotation(); |
8827 | |||
8828 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8829 | { | ||
8830 | ShoutError("No permissions to track the camera"); | ||
8831 | return new LSL_Rotation(); | ||
8832 | } | ||
8833 | } | 9002 | } |
9003 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
9004 | { | ||
9005 | ShoutError("No permissions to track the camera"); | ||
9006 | m_host.TaskInventory.LockItemsForRead(false); | ||
9007 | return new LSL_Rotation(); | ||
9008 | } | ||
9009 | m_host.TaskInventory.LockItemsForRead(false); | ||
8834 | 9010 | ||
8835 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9011 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8836 | if (presence != null) | 9012 | if (presence != null) |
@@ -8980,14 +9156,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8980 | if (objectID == UUID.Zero) return; | 9156 | if (objectID == UUID.Zero) return; |
8981 | 9157 | ||
8982 | UUID agentID; | 9158 | UUID agentID; |
8983 | lock (m_host.TaskInventory) | 9159 | m_host.TaskInventory.LockItemsForRead(true); |
8984 | { | 9160 | // we need the permission first, to know which avatar we want to set the camera for |
8985 | // we need the permission first, to know which avatar we want to set the camera for | 9161 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8986 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8987 | 9162 | ||
8988 | if (agentID == UUID.Zero) return; | 9163 | if (agentID == UUID.Zero) |
8989 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9164 | { |
9165 | m_host.TaskInventory.LockItemsForRead(false); | ||
9166 | return; | ||
9167 | } | ||
9168 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9169 | { | ||
9170 | m_host.TaskInventory.LockItemsForRead(false); | ||
9171 | return; | ||
8990 | } | 9172 | } |
9173 | m_host.TaskInventory.LockItemsForRead(false); | ||
8991 | 9174 | ||
8992 | ScenePresence presence = World.GetScenePresence(agentID); | 9175 | ScenePresence presence = World.GetScenePresence(agentID); |
8993 | 9176 | ||
@@ -9037,12 +9220,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9037 | 9220 | ||
9038 | // we need the permission first, to know which avatar we want to clear the camera for | 9221 | // we need the permission first, to know which avatar we want to clear the camera for |
9039 | UUID agentID; | 9222 | UUID agentID; |
9040 | lock (m_host.TaskInventory) | 9223 | m_host.TaskInventory.LockItemsForRead(true); |
9224 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9225 | if (agentID == UUID.Zero) | ||
9041 | { | 9226 | { |
9042 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9227 | m_host.TaskInventory.LockItemsForRead(false); |
9043 | if (agentID == UUID.Zero) return; | 9228 | return; |
9044 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9229 | } |
9230 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9231 | { | ||
9232 | m_host.TaskInventory.LockItemsForRead(false); | ||
9233 | return; | ||
9045 | } | 9234 | } |
9235 | m_host.TaskInventory.LockItemsForRead(false); | ||
9046 | 9236 | ||
9047 | ScenePresence presence = World.GetScenePresence(agentID); | 9237 | ScenePresence presence = World.GetScenePresence(agentID); |
9048 | 9238 | ||
@@ -9499,15 +9689,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9499 | 9689 | ||
9500 | internal UUID ScriptByName(string name) | 9690 | internal UUID ScriptByName(string name) |
9501 | { | 9691 | { |
9502 | lock (m_host.TaskInventory) | 9692 | m_host.TaskInventory.LockItemsForRead(true); |
9693 | |||
9694 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9503 | { | 9695 | { |
9504 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9696 | if (item.Type == 10 && item.Name == name) |
9505 | { | 9697 | { |
9506 | if (item.Type == 10 && item.Name == name) | 9698 | m_host.TaskInventory.LockItemsForRead(false); |
9507 | return item.ItemID; | 9699 | return item.ItemID; |
9508 | } | 9700 | } |
9509 | } | 9701 | } |
9510 | 9702 | ||
9703 | m_host.TaskInventory.LockItemsForRead(false); | ||
9704 | |||
9511 | return UUID.Zero; | 9705 | return UUID.Zero; |
9512 | } | 9706 | } |
9513 | 9707 | ||
@@ -9548,6 +9742,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9548 | { | 9742 | { |
9549 | m_host.AddScriptLPS(1); | 9743 | m_host.AddScriptLPS(1); |
9550 | 9744 | ||
9745 | //Clone is thread safe | ||
9551 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9746 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9552 | 9747 | ||
9553 | UUID assetID = UUID.Zero; | 9748 | UUID assetID = UUID.Zero; |
@@ -9610,6 +9805,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9610 | { | 9805 | { |
9611 | m_host.AddScriptLPS(1); | 9806 | m_host.AddScriptLPS(1); |
9612 | 9807 | ||
9808 | //Clone is thread safe | ||
9613 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9809 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9614 | 9810 | ||
9615 | UUID assetID = UUID.Zero; | 9811 | 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 2c8b0ea..1ddba1e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/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 @@ | |||
1 | using System.Collections; | ||
2 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
3 | |||
4 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
5 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
6 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
7 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
8 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
9 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
10 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
11 | |||
12 | namespace 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..7b67fa3 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | |||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..5bc3a88 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using 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; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using 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); |