diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
12 files changed, 1347 insertions, 434 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 a1db77e..e4ccce8 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()) |
277 | { | 282 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 283 | m_host.TaskInventory.LockItemsForRead(true); |
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
287 | { | ||
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; |
@@ -1330,6 +1401,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1330 | { | 1401 | { |
1331 | m_host.AddScriptLPS(1); | 1402 | m_host.AddScriptLPS(1); |
1332 | 1403 | ||
1404 | SetColor(m_host, color, face); | ||
1405 | } | ||
1406 | |||
1407 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1408 | { | ||
1409 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1410 | return; | ||
1411 | |||
1412 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1413 | Color4 texcolor; | ||
1414 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1415 | { | ||
1416 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1417 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1418 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1419 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1420 | tex.FaceTextures[face].RGBA = texcolor; | ||
1421 | part.UpdateTexture(tex); | ||
1422 | return; | ||
1423 | } | ||
1424 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1425 | { | ||
1426 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1427 | { | ||
1428 | if (tex.FaceTextures[i] != null) | ||
1429 | { | ||
1430 | texcolor = tex.FaceTextures[i].RGBA; | ||
1431 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1432 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1433 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1434 | tex.FaceTextures[i].RGBA = texcolor; | ||
1435 | } | ||
1436 | texcolor = tex.DefaultTexture.RGBA; | ||
1437 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1438 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1439 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1440 | tex.DefaultTexture.RGBA = texcolor; | ||
1441 | } | ||
1442 | part.UpdateTexture(tex); | ||
1443 | return; | ||
1444 | } | ||
1445 | |||
1333 | if (face == ScriptBaseClass.ALL_SIDES) | 1446 | if (face == ScriptBaseClass.ALL_SIDES) |
1334 | face = SceneObjectPart.ALL_SIDES; | 1447 | face = SceneObjectPart.ALL_SIDES; |
1335 | 1448 | ||
@@ -1337,7 +1450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1337 | } | 1450 | } |
1338 | 1451 | ||
1339 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1452 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1340 | { | 1453 | { |
1454 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1455 | return; | ||
1456 | |||
1341 | Primitive.TextureEntry tex = part.Shape.Textures; | 1457 | Primitive.TextureEntry tex = part.Shape.Textures; |
1342 | MappingType textype; | 1458 | MappingType textype; |
1343 | textype = MappingType.Default; | 1459 | textype = MappingType.Default; |
@@ -1367,7 +1483,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1367 | } | 1483 | } |
1368 | 1484 | ||
1369 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1485 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1370 | { | 1486 | { |
1487 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1488 | return; | ||
1489 | |||
1371 | Primitive.TextureEntry tex = part.Shape.Textures; | 1490 | Primitive.TextureEntry tex = part.Shape.Textures; |
1372 | if (face >= 0 && face < GetNumberOfSides(part)) | 1491 | if (face >= 0 && face < GetNumberOfSides(part)) |
1373 | { | 1492 | { |
@@ -1392,7 +1511,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1392 | } | 1511 | } |
1393 | 1512 | ||
1394 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1513 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1395 | { | 1514 | { |
1515 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1516 | return; | ||
1396 | 1517 | ||
1397 | Shininess sval = new Shininess(); | 1518 | Shininess sval = new Shininess(); |
1398 | 1519 | ||
@@ -1442,7 +1563,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1442 | } | 1563 | } |
1443 | 1564 | ||
1444 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1565 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1445 | { | 1566 | { |
1567 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1568 | return; | ||
1569 | |||
1446 | Primitive.TextureEntry tex = part.Shape.Textures; | 1570 | Primitive.TextureEntry tex = part.Shape.Textures; |
1447 | if (face >= 0 && face < GetNumberOfSides(part)) | 1571 | if (face >= 0 && face < GetNumberOfSides(part)) |
1448 | { | 1572 | { |
@@ -1509,7 +1633,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1509 | } | 1633 | } |
1510 | 1634 | ||
1511 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1635 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1512 | { | 1636 | { |
1637 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1638 | return; | ||
1639 | |||
1513 | Primitive.TextureEntry tex = part.Shape.Textures; | 1640 | Primitive.TextureEntry tex = part.Shape.Textures; |
1514 | Color4 texcolor; | 1641 | Color4 texcolor; |
1515 | if (face >= 0 && face < GetNumberOfSides(part)) | 1642 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1554,8 +1681,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1554 | /// <param name="Force"></param> | 1681 | /// <param name="Force"></param> |
1555 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1682 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1556 | float wind, float tension, LSL_Vector Force) | 1683 | float wind, float tension, LSL_Vector Force) |
1557 | { | 1684 | { |
1558 | if (part == null) | 1685 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1559 | return; | 1686 | return; |
1560 | 1687 | ||
1561 | if (flexi) | 1688 | if (flexi) |
@@ -1589,8 +1716,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1589 | /// <param name="radius"></param> | 1716 | /// <param name="radius"></param> |
1590 | /// <param name="falloff"></param> | 1717 | /// <param name="falloff"></param> |
1591 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1718 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1592 | { | 1719 | { |
1593 | if (part == null) | 1720 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1594 | return; | 1721 | return; |
1595 | 1722 | ||
1596 | if (light) | 1723 | if (light) |
@@ -1675,7 +1802,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1675 | } | 1802 | } |
1676 | 1803 | ||
1677 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1804 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1678 | { | 1805 | { |
1806 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1807 | return; | ||
1808 | |||
1679 | UUID textureID=new UUID(); | 1809 | UUID textureID=new UUID(); |
1680 | 1810 | ||
1681 | if (!UUID.TryParse(texture, out textureID)) | 1811 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1720,7 +1850,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1720 | } | 1850 | } |
1721 | 1851 | ||
1722 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1852 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1723 | { | 1853 | { |
1854 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1855 | return; | ||
1856 | |||
1724 | Primitive.TextureEntry tex = part.Shape.Textures; | 1857 | Primitive.TextureEntry tex = part.Shape.Textures; |
1725 | if (face >= 0 && face < GetNumberOfSides(part)) | 1858 | if (face >= 0 && face < GetNumberOfSides(part)) |
1726 | { | 1859 | { |
@@ -1756,7 +1889,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1756 | } | 1889 | } |
1757 | 1890 | ||
1758 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1891 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1759 | { | 1892 | { |
1893 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1894 | return; | ||
1895 | |||
1760 | Primitive.TextureEntry tex = part.Shape.Textures; | 1896 | Primitive.TextureEntry tex = part.Shape.Textures; |
1761 | if (face >= 0 && face < GetNumberOfSides(part)) | 1897 | if (face >= 0 && face < GetNumberOfSides(part)) |
1762 | { | 1898 | { |
@@ -1792,7 +1928,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1792 | } | 1928 | } |
1793 | 1929 | ||
1794 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1930 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1795 | { | 1931 | { |
1932 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1933 | return; | ||
1934 | |||
1796 | Primitive.TextureEntry tex = part.Shape.Textures; | 1935 | Primitive.TextureEntry tex = part.Shape.Textures; |
1797 | if (face >= 0 && face < GetNumberOfSides(part)) | 1936 | if (face >= 0 && face < GetNumberOfSides(part)) |
1798 | { | 1937 | { |
@@ -1862,7 +2001,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1862 | } | 2001 | } |
1863 | 2002 | ||
1864 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2003 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1865 | { | 2004 | { |
2005 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2006 | return; | ||
2007 | |||
1866 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2008 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1867 | LSL_Vector currentPos = llGetLocalPos(); | 2009 | LSL_Vector currentPos = llGetLocalPos(); |
1868 | 2010 | ||
@@ -1956,7 +2098,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1956 | } | 2098 | } |
1957 | 2099 | ||
1958 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2100 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1959 | { | 2101 | { |
2102 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2103 | return; | ||
2104 | |||
1960 | part.UpdateRotation(rot); | 2105 | part.UpdateRotation(rot); |
1961 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2106 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1962 | 2107 | ||
@@ -2520,12 +2665,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2520 | 2665 | ||
2521 | m_host.AddScriptLPS(1); | 2666 | m_host.AddScriptLPS(1); |
2522 | 2667 | ||
2668 | m_host.TaskInventory.LockItemsForRead(true); | ||
2523 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2669 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2524 | 2670 | m_host.TaskInventory.LockItemsForRead(false); | |
2525 | lock (m_host.TaskInventory) | ||
2526 | { | ||
2527 | item = m_host.TaskInventory[invItemID]; | ||
2528 | } | ||
2529 | 2671 | ||
2530 | if (item.PermsGranter == UUID.Zero) | 2672 | if (item.PermsGranter == UUID.Zero) |
2531 | return 0; | 2673 | return 0; |
@@ -2600,6 +2742,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2600 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2742 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2601 | return; | 2743 | return; |
2602 | 2744 | ||
2745 | //Clone is thread-safe | ||
2603 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2746 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2604 | 2747 | ||
2605 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2748 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2685,6 +2828,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2685 | // Orient the object to the angle calculated | 2828 | // Orient the object to the angle calculated |
2686 | llSetRot(rot); | 2829 | llSetRot(rot); |
2687 | } | 2830 | } |
2831 | |||
2832 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2833 | { | ||
2834 | m_host.AddScriptLPS(1); | ||
2835 | // NotImplemented("llRotLookAt"); | ||
2836 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2837 | |||
2838 | } | ||
2688 | 2839 | ||
2689 | public void llStopLookAt() | 2840 | public void llStopLookAt() |
2690 | { | 2841 | { |
@@ -2732,13 +2883,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2732 | { | 2883 | { |
2733 | TaskInventoryItem item; | 2884 | TaskInventoryItem item; |
2734 | 2885 | ||
2735 | lock (m_host.TaskInventory) | 2886 | m_host.TaskInventory.LockItemsForRead(true); |
2887 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2736 | { | 2888 | { |
2737 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2889 | m_host.TaskInventory.LockItemsForRead(false); |
2738 | return; | 2890 | return; |
2739 | else | ||
2740 | item = m_host.TaskInventory[InventorySelf()]; | ||
2741 | } | 2891 | } |
2892 | else | ||
2893 | { | ||
2894 | item = m_host.TaskInventory[InventorySelf()]; | ||
2895 | } | ||
2896 | m_host.TaskInventory.LockItemsForRead(false); | ||
2742 | 2897 | ||
2743 | if (item.PermsGranter != UUID.Zero) | 2898 | if (item.PermsGranter != UUID.Zero) |
2744 | { | 2899 | { |
@@ -2760,13 +2915,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2760 | { | 2915 | { |
2761 | TaskInventoryItem item; | 2916 | TaskInventoryItem item; |
2762 | 2917 | ||
2918 | m_host.TaskInventory.LockItemsForRead(true); | ||
2763 | lock (m_host.TaskInventory) | 2919 | lock (m_host.TaskInventory) |
2764 | { | 2920 | { |
2921 | |||
2765 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2922 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2923 | { | ||
2924 | m_host.TaskInventory.LockItemsForRead(false); | ||
2766 | return; | 2925 | return; |
2926 | } | ||
2767 | else | 2927 | else |
2928 | { | ||
2768 | item = m_host.TaskInventory[InventorySelf()]; | 2929 | item = m_host.TaskInventory[InventorySelf()]; |
2930 | } | ||
2769 | } | 2931 | } |
2932 | m_host.TaskInventory.LockItemsForRead(false); | ||
2770 | 2933 | ||
2771 | m_host.AddScriptLPS(1); | 2934 | m_host.AddScriptLPS(1); |
2772 | 2935 | ||
@@ -2803,13 +2966,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2803 | 2966 | ||
2804 | TaskInventoryItem item; | 2967 | TaskInventoryItem item; |
2805 | 2968 | ||
2806 | lock (m_host.TaskInventory) | 2969 | m_host.TaskInventory.LockItemsForRead(true); |
2970 | |||
2971 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2807 | { | 2972 | { |
2808 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2973 | m_host.TaskInventory.LockItemsForRead(false); |
2809 | return; | 2974 | return; |
2810 | else | ||
2811 | item = m_host.TaskInventory[InventorySelf()]; | ||
2812 | } | 2975 | } |
2976 | else | ||
2977 | { | ||
2978 | item = m_host.TaskInventory[InventorySelf()]; | ||
2979 | } | ||
2980 | |||
2981 | m_host.TaskInventory.LockItemsForRead(false); | ||
2813 | 2982 | ||
2814 | if (item.PermsGranter != m_host.OwnerID) | 2983 | if (item.PermsGranter != m_host.OwnerID) |
2815 | return; | 2984 | return; |
@@ -2835,13 +3004,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | 3004 | ||
2836 | TaskInventoryItem item; | 3005 | TaskInventoryItem item; |
2837 | 3006 | ||
2838 | lock (m_host.TaskInventory) | 3007 | m_host.TaskInventory.LockItemsForRead(true); |
3008 | |||
3009 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2839 | { | 3010 | { |
2840 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3011 | m_host.TaskInventory.LockItemsForRead(false); |
2841 | return; | 3012 | return; |
2842 | else | ||
2843 | item = m_host.TaskInventory[InventorySelf()]; | ||
2844 | } | 3013 | } |
3014 | else | ||
3015 | { | ||
3016 | item = m_host.TaskInventory[InventorySelf()]; | ||
3017 | } | ||
3018 | m_host.TaskInventory.LockItemsForRead(false); | ||
3019 | |||
2845 | 3020 | ||
2846 | if (item.PermsGranter != m_host.OwnerID) | 3021 | if (item.PermsGranter != m_host.OwnerID) |
2847 | return; | 3022 | return; |
@@ -2877,8 +3052,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2877 | return m_host.OwnerID.ToString(); | 3052 | return m_host.OwnerID.ToString(); |
2878 | } | 3053 | } |
2879 | 3054 | ||
3055 | [DebuggerNonUserCode] | ||
2880 | public void llInstantMessage(string user, string message) | 3056 | public void llInstantMessage(string user, string message) |
2881 | { | 3057 | { |
3058 | UUID result; | ||
3059 | if (!UUID.TryParse(user, out result)) | ||
3060 | { | ||
3061 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3062 | return; | ||
3063 | } | ||
3064 | |||
3065 | |||
2882 | m_host.AddScriptLPS(1); | 3066 | m_host.AddScriptLPS(1); |
2883 | 3067 | ||
2884 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3068 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2893,7 +3077,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2893 | UUID friendTransactionID = UUID.Random(); | 3077 | UUID friendTransactionID = UUID.Random(); |
2894 | 3078 | ||
2895 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3079 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2896 | 3080 | ||
2897 | GridInstantMessage msg = new GridInstantMessage(); | 3081 | GridInstantMessage msg = new GridInstantMessage(); |
2898 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3082 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2899 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3083 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3042,13 +3226,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3042 | m_host.AddScriptLPS(1); | 3226 | m_host.AddScriptLPS(1); |
3043 | } | 3227 | } |
3044 | 3228 | ||
3045 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3046 | { | ||
3047 | m_host.AddScriptLPS(1); | ||
3048 | // NotImplemented("llRotLookAt"); | ||
3049 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3050 | } | ||
3051 | |||
3052 | public LSL_Integer llStringLength(string str) | 3229 | public LSL_Integer llStringLength(string str) |
3053 | { | 3230 | { |
3054 | m_host.AddScriptLPS(1); | 3231 | m_host.AddScriptLPS(1); |
@@ -3072,14 +3249,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3072 | 3249 | ||
3073 | TaskInventoryItem item; | 3250 | TaskInventoryItem item; |
3074 | 3251 | ||
3075 | lock (m_host.TaskInventory) | 3252 | m_host.TaskInventory.LockItemsForRead(true); |
3253 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3076 | { | 3254 | { |
3077 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3255 | m_host.TaskInventory.LockItemsForRead(false); |
3078 | return; | 3256 | return; |
3079 | else | ||
3080 | item = m_host.TaskInventory[InventorySelf()]; | ||
3081 | } | 3257 | } |
3082 | 3258 | else | |
3259 | { | ||
3260 | item = m_host.TaskInventory[InventorySelf()]; | ||
3261 | } | ||
3262 | m_host.TaskInventory.LockItemsForRead(false); | ||
3083 | if (item.PermsGranter == UUID.Zero) | 3263 | if (item.PermsGranter == UUID.Zero) |
3084 | return; | 3264 | return; |
3085 | 3265 | ||
@@ -3109,13 +3289,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3109 | 3289 | ||
3110 | TaskInventoryItem item; | 3290 | TaskInventoryItem item; |
3111 | 3291 | ||
3112 | lock (m_host.TaskInventory) | 3292 | m_host.TaskInventory.LockItemsForRead(true); |
3293 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3113 | { | 3294 | { |
3114 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3295 | m_host.TaskInventory.LockItemsForRead(false); |
3115 | return; | 3296 | return; |
3116 | else | 3297 | } |
3117 | item = m_host.TaskInventory[InventorySelf()]; | 3298 | else |
3299 | { | ||
3300 | item = m_host.TaskInventory[InventorySelf()]; | ||
3118 | } | 3301 | } |
3302 | m_host.TaskInventory.LockItemsForRead(false); | ||
3303 | |||
3119 | 3304 | ||
3120 | if (item.PermsGranter == UUID.Zero) | 3305 | if (item.PermsGranter == UUID.Zero) |
3121 | return; | 3306 | return; |
@@ -3188,10 +3373,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3188 | 3373 | ||
3189 | TaskInventoryItem item; | 3374 | TaskInventoryItem item; |
3190 | 3375 | ||
3191 | lock (m_host.TaskInventory) | 3376 | |
3377 | m_host.TaskInventory.LockItemsForRead(true); | ||
3378 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3379 | { | ||
3380 | m_host.TaskInventory.LockItemsForRead(false); | ||
3381 | return; | ||
3382 | } | ||
3383 | else | ||
3192 | { | 3384 | { |
3193 | item = m_host.TaskInventory[invItemID]; | 3385 | item = m_host.TaskInventory[invItemID]; |
3194 | } | 3386 | } |
3387 | m_host.TaskInventory.LockItemsForRead(false); | ||
3195 | 3388 | ||
3196 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3389 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3197 | { | 3390 | { |
@@ -3223,11 +3416,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3223 | 3416 | ||
3224 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3417 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3225 | { | 3418 | { |
3226 | lock (m_host.TaskInventory) | 3419 | m_host.TaskInventory.LockItemsForWrite(true); |
3227 | { | 3420 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3228 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3421 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3229 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3422 | m_host.TaskInventory.LockItemsForWrite(false); |
3230 | } | ||
3231 | 3423 | ||
3232 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3424 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3233 | "run_time_permissions", new Object[] { | 3425 | "run_time_permissions", new Object[] { |
@@ -3247,11 +3439,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3247 | 3439 | ||
3248 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3440 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3249 | { | 3441 | { |
3250 | lock (m_host.TaskInventory) | 3442 | m_host.TaskInventory.LockItemsForWrite(true); |
3251 | { | 3443 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3252 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3444 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3253 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3445 | m_host.TaskInventory.LockItemsForWrite(false); |
3254 | } | ||
3255 | 3446 | ||
3256 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3447 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3257 | "run_time_permissions", new Object[] { | 3448 | "run_time_permissions", new Object[] { |
@@ -3272,11 +3463,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3272 | 3463 | ||
3273 | if (!m_waitingForScriptAnswer) | 3464 | if (!m_waitingForScriptAnswer) |
3274 | { | 3465 | { |
3275 | lock (m_host.TaskInventory) | 3466 | m_host.TaskInventory.LockItemsForWrite(true); |
3276 | { | 3467 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3277 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3468 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3278 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3469 | m_host.TaskInventory.LockItemsForWrite(false); |
3279 | } | ||
3280 | 3470 | ||
3281 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3471 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3282 | m_waitingForScriptAnswer=true; | 3472 | m_waitingForScriptAnswer=true; |
@@ -3311,10 +3501,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3311 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3501 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3312 | llReleaseControls(); | 3502 | llReleaseControls(); |
3313 | 3503 | ||
3314 | lock (m_host.TaskInventory) | 3504 | |
3315 | { | 3505 | m_host.TaskInventory.LockItemsForWrite(true); |
3316 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3506 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3317 | } | 3507 | m_host.TaskInventory.LockItemsForWrite(false); |
3508 | |||
3318 | 3509 | ||
3319 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3510 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3320 | "run_time_permissions", new Object[] { | 3511 | "run_time_permissions", new Object[] { |
@@ -3326,16 +3517,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3326 | { | 3517 | { |
3327 | m_host.AddScriptLPS(1); | 3518 | m_host.AddScriptLPS(1); |
3328 | 3519 | ||
3329 | lock (m_host.TaskInventory) | 3520 | m_host.TaskInventory.LockItemsForRead(true); |
3521 | |||
3522 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3330 | { | 3523 | { |
3331 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3524 | if (item.Type == 10 && item.ItemID == m_itemID) |
3332 | { | 3525 | { |
3333 | if (item.Type == 10 && item.ItemID == m_itemID) | 3526 | m_host.TaskInventory.LockItemsForRead(false); |
3334 | { | 3527 | return item.PermsGranter.ToString(); |
3335 | return item.PermsGranter.ToString(); | ||
3336 | } | ||
3337 | } | 3528 | } |
3338 | } | 3529 | } |
3530 | m_host.TaskInventory.LockItemsForRead(false); | ||
3339 | 3531 | ||
3340 | return UUID.Zero.ToString(); | 3532 | return UUID.Zero.ToString(); |
3341 | } | 3533 | } |
@@ -3344,19 +3536,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3344 | { | 3536 | { |
3345 | m_host.AddScriptLPS(1); | 3537 | m_host.AddScriptLPS(1); |
3346 | 3538 | ||
3347 | lock (m_host.TaskInventory) | 3539 | m_host.TaskInventory.LockItemsForRead(true); |
3540 | |||
3541 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3348 | { | 3542 | { |
3349 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3543 | if (item.Type == 10 && item.ItemID == m_itemID) |
3350 | { | 3544 | { |
3351 | if (item.Type == 10 && item.ItemID == m_itemID) | 3545 | int perms = item.PermsMask; |
3352 | { | 3546 | if (m_automaticLinkPermission) |
3353 | int perms = item.PermsMask; | 3547 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3354 | if (m_automaticLinkPermission) | 3548 | m_host.TaskInventory.LockItemsForRead(false); |
3355 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3549 | return perms; |
3356 | return perms; | ||
3357 | } | ||
3358 | } | 3550 | } |
3359 | } | 3551 | } |
3552 | m_host.TaskInventory.LockItemsForRead(false); | ||
3360 | 3553 | ||
3361 | return 0; | 3554 | return 0; |
3362 | } | 3555 | } |
@@ -3389,11 +3582,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3389 | UUID invItemID = InventorySelf(); | 3582 | UUID invItemID = InventorySelf(); |
3390 | 3583 | ||
3391 | TaskInventoryItem item; | 3584 | TaskInventoryItem item; |
3392 | lock (m_host.TaskInventory) | 3585 | m_host.TaskInventory.LockItemsForRead(true); |
3393 | { | 3586 | item = m_host.TaskInventory[invItemID]; |
3394 | item = m_host.TaskInventory[invItemID]; | 3587 | m_host.TaskInventory.LockItemsForRead(false); |
3395 | } | 3588 | |
3396 | |||
3397 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3589 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3398 | && !m_automaticLinkPermission) | 3590 | && !m_automaticLinkPermission) |
3399 | { | 3591 | { |
@@ -3446,16 +3638,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3446 | m_host.AddScriptLPS(1); | 3638 | m_host.AddScriptLPS(1); |
3447 | UUID invItemID = InventorySelf(); | 3639 | UUID invItemID = InventorySelf(); |
3448 | 3640 | ||
3449 | lock (m_host.TaskInventory) | 3641 | m_host.TaskInventory.LockItemsForRead(true); |
3450 | { | ||
3451 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3642 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3452 | && !m_automaticLinkPermission) | 3643 | && !m_automaticLinkPermission) |
3453 | { | 3644 | { |
3454 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3645 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3646 | m_host.TaskInventory.LockItemsForRead(false); | ||
3455 | return; | 3647 | return; |
3456 | } | 3648 | } |
3457 | } | 3649 | m_host.TaskInventory.LockItemsForRead(false); |
3458 | 3650 | ||
3459 | if (linknum < ScriptBaseClass.LINK_THIS) | 3651 | if (linknum < ScriptBaseClass.LINK_THIS) |
3460 | return; | 3652 | return; |
3461 | 3653 | ||
@@ -3632,17 +3824,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3632 | m_host.AddScriptLPS(1); | 3824 | m_host.AddScriptLPS(1); |
3633 | int count = 0; | 3825 | int count = 0; |
3634 | 3826 | ||
3635 | lock (m_host.TaskInventory) | 3827 | m_host.TaskInventory.LockItemsForRead(true); |
3828 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3636 | { | 3829 | { |
3637 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3830 | if (inv.Value.Type == type || type == -1) |
3638 | { | 3831 | { |
3639 | if (inv.Value.Type == type || type == -1) | 3832 | count = count + 1; |
3640 | { | ||
3641 | count = count + 1; | ||
3642 | } | ||
3643 | } | 3833 | } |
3644 | } | 3834 | } |
3645 | 3835 | ||
3836 | m_host.TaskInventory.LockItemsForRead(false); | ||
3646 | return count; | 3837 | return count; |
3647 | } | 3838 | } |
3648 | 3839 | ||
@@ -3651,16 +3842,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3651 | m_host.AddScriptLPS(1); | 3842 | m_host.AddScriptLPS(1); |
3652 | ArrayList keys = new ArrayList(); | 3843 | ArrayList keys = new ArrayList(); |
3653 | 3844 | ||
3654 | lock (m_host.TaskInventory) | 3845 | m_host.TaskInventory.LockItemsForRead(true); |
3846 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3655 | { | 3847 | { |
3656 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3848 | if (inv.Value.Type == type || type == -1) |
3657 | { | 3849 | { |
3658 | if (inv.Value.Type == type || type == -1) | 3850 | keys.Add(inv.Value.Name); |
3659 | { | ||
3660 | keys.Add(inv.Value.Name); | ||
3661 | } | ||
3662 | } | 3851 | } |
3663 | } | 3852 | } |
3853 | m_host.TaskInventory.LockItemsForRead(false); | ||
3664 | 3854 | ||
3665 | if (keys.Count == 0) | 3855 | if (keys.Count == 0) |
3666 | { | 3856 | { |
@@ -3697,20 +3887,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3697 | } | 3887 | } |
3698 | 3888 | ||
3699 | // move the first object found with this inventory name | 3889 | // move the first object found with this inventory name |
3700 | lock (m_host.TaskInventory) | 3890 | m_host.TaskInventory.LockItemsForRead(true); |
3891 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3701 | { | 3892 | { |
3702 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3893 | if (inv.Value.Name == inventory) |
3703 | { | 3894 | { |
3704 | if (inv.Value.Name == inventory) | 3895 | found = true; |
3705 | { | 3896 | objId = inv.Key; |
3706 | found = true; | 3897 | assetType = inv.Value.Type; |
3707 | objId = inv.Key; | 3898 | objName = inv.Value.Name; |
3708 | assetType = inv.Value.Type; | 3899 | break; |
3709 | objName = inv.Value.Name; | ||
3710 | break; | ||
3711 | } | ||
3712 | } | 3900 | } |
3713 | } | 3901 | } |
3902 | m_host.TaskInventory.LockItemsForRead(false); | ||
3714 | 3903 | ||
3715 | if (!found) | 3904 | if (!found) |
3716 | { | 3905 | { |
@@ -3755,24 +3944,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3755 | ScriptSleep(3000); | 3944 | ScriptSleep(3000); |
3756 | } | 3945 | } |
3757 | 3946 | ||
3947 | [DebuggerNonUserCode] | ||
3758 | public void llRemoveInventory(string name) | 3948 | public void llRemoveInventory(string name) |
3759 | { | 3949 | { |
3760 | m_host.AddScriptLPS(1); | 3950 | m_host.AddScriptLPS(1); |
3761 | 3951 | ||
3762 | lock (m_host.TaskInventory) | 3952 | m_host.TaskInventory.LockItemsForRead(true); |
3953 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3763 | { | 3954 | { |
3764 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3955 | if (item.Name == name) |
3765 | { | 3956 | { |
3766 | if (item.Name == name) | 3957 | if (item.ItemID == m_itemID) |
3767 | { | 3958 | throw new ScriptDeleteException(); |
3768 | if (item.ItemID == m_itemID) | 3959 | else |
3769 | throw new ScriptDeleteException(); | 3960 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3770 | else | 3961 | |
3771 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3962 | m_host.TaskInventory.LockItemsForRead(false); |
3772 | return; | 3963 | return; |
3773 | } | ||
3774 | } | 3964 | } |
3775 | } | 3965 | } |
3966 | m_host.TaskInventory.LockItemsForRead(false); | ||
3776 | } | 3967 | } |
3777 | 3968 | ||
3778 | public void llSetText(string text, LSL_Vector color, double alpha) | 3969 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3862,6 +4053,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3862 | { | 4053 | { |
3863 | m_host.AddScriptLPS(1); | 4054 | m_host.AddScriptLPS(1); |
3864 | 4055 | ||
4056 | //Clone is thread safe | ||
3865 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4057 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3866 | 4058 | ||
3867 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4059 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3952,17 +4144,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3952 | UUID soundId = UUID.Zero; | 4144 | UUID soundId = UUID.Zero; |
3953 | if (!UUID.TryParse(impact_sound, out soundId)) | 4145 | if (!UUID.TryParse(impact_sound, out soundId)) |
3954 | { | 4146 | { |
3955 | lock (m_host.TaskInventory) | 4147 | m_host.TaskInventory.LockItemsForRead(true); |
4148 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3956 | { | 4149 | { |
3957 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4150 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3958 | { | 4151 | { |
3959 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4152 | soundId = item.AssetID; |
3960 | { | 4153 | break; |
3961 | soundId = item.AssetID; | ||
3962 | break; | ||
3963 | } | ||
3964 | } | 4154 | } |
3965 | } | 4155 | } |
4156 | m_host.TaskInventory.LockItemsForRead(false); | ||
3966 | } | 4157 | } |
3967 | m_host.CollisionSound = soundId; | 4158 | m_host.CollisionSound = soundId; |
3968 | m_host.CollisionSoundVolume = (float)impact_volume; | 4159 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4008,6 +4199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4008 | UUID partItemID; | 4199 | UUID partItemID; |
4009 | foreach (SceneObjectPart part in parts) | 4200 | foreach (SceneObjectPart part in parts) |
4010 | { | 4201 | { |
4202 | //Clone is thread safe | ||
4011 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4203 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4012 | 4204 | ||
4013 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4205 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4222,17 +4414,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4222 | 4414 | ||
4223 | m_host.AddScriptLPS(1); | 4415 | m_host.AddScriptLPS(1); |
4224 | 4416 | ||
4225 | lock (m_host.TaskInventory) | 4417 | m_host.TaskInventory.LockItemsForRead(true); |
4418 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4226 | { | 4419 | { |
4227 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4420 | if (item.Type == 10 && item.ItemID == m_itemID) |
4228 | { | 4421 | { |
4229 | if (item.Type == 10 && item.ItemID == m_itemID) | 4422 | result = item.Name!=null?item.Name:String.Empty; |
4230 | { | 4423 | break; |
4231 | result = item.Name != null ? item.Name : String.Empty; | ||
4232 | break; | ||
4233 | } | ||
4234 | } | 4424 | } |
4235 | } | 4425 | } |
4426 | m_host.TaskInventory.LockItemsForRead(false); | ||
4236 | 4427 | ||
4237 | return result; | 4428 | return result; |
4238 | } | 4429 | } |
@@ -4385,23 +4576,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4385 | { | 4576 | { |
4386 | m_host.AddScriptLPS(1); | 4577 | m_host.AddScriptLPS(1); |
4387 | 4578 | ||
4388 | lock (m_host.TaskInventory) | 4579 | m_host.TaskInventory.LockItemsForRead(true); |
4580 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4389 | { | 4581 | { |
4390 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4582 | if (inv.Value.Name == name) |
4391 | { | 4583 | { |
4392 | if (inv.Value.Name == name) | 4584 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4393 | { | 4585 | { |
4394 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4586 | m_host.TaskInventory.LockItemsForRead(false); |
4395 | { | 4587 | return inv.Value.AssetID.ToString(); |
4396 | return inv.Value.AssetID.ToString(); | 4588 | } |
4397 | } | 4589 | else |
4398 | else | 4590 | { |
4399 | { | 4591 | m_host.TaskInventory.LockItemsForRead(false); |
4400 | return UUID.Zero.ToString(); | 4592 | return UUID.Zero.ToString(); |
4401 | } | ||
4402 | } | 4593 | } |
4403 | } | 4594 | } |
4404 | } | 4595 | } |
4596 | m_host.TaskInventory.LockItemsForRead(false); | ||
4405 | 4597 | ||
4406 | return UUID.Zero.ToString(); | 4598 | return UUID.Zero.ToString(); |
4407 | } | 4599 | } |
@@ -5897,14 +6089,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5897 | 6089 | ||
5898 | protected UUID GetTaskInventoryItem(string name) | 6090 | protected UUID GetTaskInventoryItem(string name) |
5899 | { | 6091 | { |
5900 | lock (m_host.TaskInventory) | 6092 | m_host.TaskInventory.LockItemsForRead(true); |
6093 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
5901 | { | 6094 | { |
5902 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6095 | if (inv.Value.Name == name) |
5903 | { | 6096 | { |
5904 | if (inv.Value.Name == name) | 6097 | m_host.TaskInventory.LockItemsForRead(false); |
5905 | return inv.Key; | 6098 | return inv.Key; |
5906 | } | 6099 | } |
5907 | } | 6100 | } |
6101 | m_host.TaskInventory.LockItemsForRead(false); | ||
5908 | 6102 | ||
5909 | return UUID.Zero; | 6103 | return UUID.Zero; |
5910 | } | 6104 | } |
@@ -6021,13 +6215,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6021 | public void llSetVehicleFlags(int flags) | 6215 | public void llSetVehicleFlags(int flags) |
6022 | { | 6216 | { |
6023 | m_host.AddScriptLPS(1); | 6217 | m_host.AddScriptLPS(1); |
6024 | NotImplemented("llSetVehicleFlags"); | 6218 | if (m_host.ParentGroup != null) |
6219 | { | ||
6220 | if (!m_host.ParentGroup.IsDeleted) | ||
6221 | { | ||
6222 | m_host.ParentGroup.RootPart.SetVehicleFlags(flags); | ||
6223 | } | ||
6224 | } | ||
6025 | } | 6225 | } |
6026 | 6226 | ||
6027 | public void llRemoveVehicleFlags(int flags) | 6227 | public void llRemoveVehicleFlags(int flags) |
6028 | { | 6228 | { |
6029 | m_host.AddScriptLPS(1); | 6229 | m_host.AddScriptLPS(1); |
6030 | NotImplemented("llRemoveVehicleFlags"); | 6230 | if (m_host.ParentGroup != null) |
6231 | { | ||
6232 | if (!m_host.ParentGroup.IsDeleted) | ||
6233 | { | ||
6234 | m_host.ParentGroup.RootPart.RemoveVehicleFlags(flags); | ||
6235 | } | ||
6236 | } | ||
6031 | } | 6237 | } |
6032 | 6238 | ||
6033 | public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) | 6239 | public void llSitTarget(LSL_Vector offset, LSL_Rotation rot) |
@@ -6220,22 +6426,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6220 | } | 6426 | } |
6221 | 6427 | ||
6222 | // copy the first script found with this inventory name | 6428 | // copy the first script found with this inventory name |
6223 | lock (m_host.TaskInventory) | 6429 | m_host.TaskInventory.LockItemsForRead(true); |
6430 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6224 | { | 6431 | { |
6225 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6432 | if (inv.Value.Name == name) |
6226 | { | 6433 | { |
6227 | if (inv.Value.Name == name) | 6434 | // make sure the object is a script |
6435 | if (10 == inv.Value.Type) | ||
6228 | { | 6436 | { |
6229 | // make sure the object is a script | 6437 | found = true; |
6230 | if (10 == inv.Value.Type) | 6438 | srcId = inv.Key; |
6231 | { | 6439 | break; |
6232 | found = true; | ||
6233 | srcId = inv.Key; | ||
6234 | break; | ||
6235 | } | ||
6236 | } | 6440 | } |
6237 | } | 6441 | } |
6238 | } | 6442 | } |
6443 | m_host.TaskInventory.LockItemsForRead(false); | ||
6239 | 6444 | ||
6240 | if (!found) | 6445 | if (!found) |
6241 | { | 6446 | { |
@@ -6317,8 +6522,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6317 | } | 6522 | } |
6318 | 6523 | ||
6319 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6524 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6320 | { | 6525 | { |
6321 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6526 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6527 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6528 | return shapeBlock; | ||
6322 | 6529 | ||
6323 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6530 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6324 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6531 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6388,7 +6595,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6388 | } | 6595 | } |
6389 | 6596 | ||
6390 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6597 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6391 | { | 6598 | { |
6599 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6600 | return; | ||
6601 | |||
6392 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6602 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6393 | 6603 | ||
6394 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6604 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6437,7 +6647,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6437 | } | 6647 | } |
6438 | 6648 | ||
6439 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6649 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6440 | { | 6650 | { |
6651 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6652 | return; | ||
6653 | |||
6441 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6654 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6442 | 6655 | ||
6443 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6656 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6479,7 +6692,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6479 | } | 6692 | } |
6480 | 6693 | ||
6481 | 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) | 6694 | 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) |
6482 | { | 6695 | { |
6696 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6697 | return; | ||
6698 | |||
6483 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6699 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6484 | 6700 | ||
6485 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6701 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6600,7 +6816,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6600 | } | 6816 | } |
6601 | 6817 | ||
6602 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6818 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6603 | { | 6819 | { |
6820 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6821 | return; | ||
6822 | |||
6604 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6823 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6605 | UUID sculptId; | 6824 | UUID sculptId; |
6606 | 6825 | ||
@@ -6634,14 +6853,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6634 | } | 6853 | } |
6635 | 6854 | ||
6636 | public void llSetPrimitiveParams(LSL_List rules) | 6855 | public void llSetPrimitiveParams(LSL_List rules) |
6637 | { | 6856 | { |
6638 | m_host.AddScriptLPS(1); | 6857 | m_host.AddScriptLPS(1); |
6639 | SetPrimParams(m_host, rules); | 6858 | SetPrimParams(m_host, rules); |
6640 | } | 6859 | } |
6641 | 6860 | ||
6642 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 6861 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6643 | { | 6862 | { |
6644 | m_host.AddScriptLPS(1); | 6863 | m_host.AddScriptLPS(1); |
6645 | 6864 | ||
6646 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6865 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6647 | 6866 | ||
@@ -6650,7 +6869,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6650 | } | 6869 | } |
6651 | 6870 | ||
6652 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 6871 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6653 | { | 6872 | { |
6873 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6874 | return; | ||
6875 | |||
6654 | int idx = 0; | 6876 | int idx = 0; |
6655 | 6877 | ||
6656 | while (idx < rules.Length) | 6878 | while (idx < rules.Length) |
@@ -8052,28 +8274,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8052 | { | 8274 | { |
8053 | m_host.AddScriptLPS(1); | 8275 | m_host.AddScriptLPS(1); |
8054 | 8276 | ||
8055 | lock (m_host.TaskInventory) | 8277 | m_host.TaskInventory.LockItemsForRead(true); |
8278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8056 | { | 8279 | { |
8057 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8280 | if (inv.Value.Name == item) |
8058 | { | 8281 | { |
8059 | if (inv.Value.Name == item) | 8282 | m_host.TaskInventory.LockItemsForRead(false); |
8283 | switch (mask) | ||
8060 | { | 8284 | { |
8061 | switch (mask) | 8285 | case 0: |
8062 | { | 8286 | return (int)inv.Value.BasePermissions; |
8063 | case 0: | 8287 | case 1: |
8064 | return (int)inv.Value.BasePermissions; | 8288 | return (int)inv.Value.CurrentPermissions; |
8065 | case 1: | 8289 | case 2: |
8066 | return (int)inv.Value.CurrentPermissions; | 8290 | return (int)inv.Value.GroupPermissions; |
8067 | case 2: | 8291 | case 3: |
8068 | return (int)inv.Value.GroupPermissions; | 8292 | return (int)inv.Value.EveryonePermissions; |
8069 | case 3: | 8293 | case 4: |
8070 | return (int)inv.Value.EveryonePermissions; | 8294 | return (int)inv.Value.NextPermissions; |
8071 | case 4: | ||
8072 | return (int)inv.Value.NextPermissions; | ||
8073 | } | ||
8074 | } | 8295 | } |
8075 | } | 8296 | } |
8076 | } | 8297 | } |
8298 | m_host.TaskInventory.LockItemsForRead(false); | ||
8077 | 8299 | ||
8078 | return -1; | 8300 | return -1; |
8079 | } | 8301 | } |
@@ -8088,16 +8310,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8088 | { | 8310 | { |
8089 | m_host.AddScriptLPS(1); | 8311 | m_host.AddScriptLPS(1); |
8090 | 8312 | ||
8091 | lock (m_host.TaskInventory) | 8313 | m_host.TaskInventory.LockItemsForRead(true); |
8314 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8092 | { | 8315 | { |
8093 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8316 | if (inv.Value.Name == item) |
8094 | { | 8317 | { |
8095 | if (inv.Value.Name == item) | 8318 | m_host.TaskInventory.LockItemsForRead(false); |
8096 | { | 8319 | return inv.Value.CreatorID.ToString(); |
8097 | return inv.Value.CreatorID.ToString(); | ||
8098 | } | ||
8099 | } | 8320 | } |
8100 | } | 8321 | } |
8322 | m_host.TaskInventory.LockItemsForRead(false); | ||
8101 | 8323 | ||
8102 | llSay(0, "No item name '" + item + "'"); | 8324 | llSay(0, "No item name '" + item + "'"); |
8103 | 8325 | ||
@@ -8621,16 +8843,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8621 | { | 8843 | { |
8622 | m_host.AddScriptLPS(1); | 8844 | m_host.AddScriptLPS(1); |
8623 | 8845 | ||
8624 | lock (m_host.TaskInventory) | 8846 | m_host.TaskInventory.LockItemsForRead(true); |
8847 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8625 | { | 8848 | { |
8626 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8849 | if (inv.Value.Name == name) |
8627 | { | 8850 | { |
8628 | if (inv.Value.Name == name) | 8851 | m_host.TaskInventory.LockItemsForRead(false); |
8629 | { | 8852 | return inv.Value.Type; |
8630 | return inv.Value.Type; | ||
8631 | } | ||
8632 | } | 8853 | } |
8633 | } | 8854 | } |
8855 | m_host.TaskInventory.LockItemsForRead(false); | ||
8634 | 8856 | ||
8635 | return -1; | 8857 | return -1; |
8636 | } | 8858 | } |
@@ -8644,12 +8866,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8644 | LSLError("List must have at least 4 elements"); | 8866 | LSLError("List must have at least 4 elements"); |
8645 | return; | 8867 | return; |
8646 | } | 8868 | } |
8647 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 8869 | int[] nPrice = new int[5]; |
8648 | 8870 | nPrice[0]=price; | |
8649 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 8871 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8650 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 8872 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8651 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 8873 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8652 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 8874 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
8875 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8653 | m_host.ParentGroup.HasGroupChanged = true; | 8876 | m_host.ParentGroup.HasGroupChanged = true; |
8654 | } | 8877 | } |
8655 | 8878 | ||
@@ -8661,17 +8884,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8661 | if (invItemID == UUID.Zero) | 8884 | if (invItemID == UUID.Zero) |
8662 | return new LSL_Vector(); | 8885 | return new LSL_Vector(); |
8663 | 8886 | ||
8664 | lock (m_host.TaskInventory) | 8887 | m_host.TaskInventory.LockItemsForRead(true); |
8888 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8665 | { | 8889 | { |
8666 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8890 | m_host.TaskInventory.LockItemsForRead(false); |
8667 | return new LSL_Vector(); | 8891 | return new LSL_Vector(); |
8892 | } | ||
8668 | 8893 | ||
8669 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8894 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8670 | { | 8895 | { |
8671 | ShoutError("No permissions to track the camera"); | 8896 | ShoutError("No permissions to track the camera"); |
8672 | return new LSL_Vector(); | 8897 | m_host.TaskInventory.LockItemsForRead(false); |
8673 | } | 8898 | return new LSL_Vector(); |
8674 | } | 8899 | } |
8900 | m_host.TaskInventory.LockItemsForRead(false); | ||
8675 | 8901 | ||
8676 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8902 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8677 | if (presence != null) | 8903 | if (presence != null) |
@@ -8689,17 +8915,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8689 | if (invItemID == UUID.Zero) | 8915 | if (invItemID == UUID.Zero) |
8690 | return new LSL_Rotation(); | 8916 | return new LSL_Rotation(); |
8691 | 8917 | ||
8692 | lock (m_host.TaskInventory) | 8918 | m_host.TaskInventory.LockItemsForRead(true); |
8919 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8693 | { | 8920 | { |
8694 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8921 | m_host.TaskInventory.LockItemsForRead(false); |
8695 | return new LSL_Rotation(); | 8922 | return new LSL_Rotation(); |
8696 | 8923 | } | |
8697 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8924 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8698 | { | 8925 | { |
8699 | ShoutError("No permissions to track the camera"); | 8926 | ShoutError("No permissions to track the camera"); |
8700 | return new LSL_Rotation(); | 8927 | m_host.TaskInventory.LockItemsForRead(false); |
8701 | } | 8928 | return new LSL_Rotation(); |
8702 | } | 8929 | } |
8930 | m_host.TaskInventory.LockItemsForRead(false); | ||
8703 | 8931 | ||
8704 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8932 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8705 | if (presence != null) | 8933 | if (presence != null) |
@@ -8849,14 +9077,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8849 | if (objectID == UUID.Zero) return; | 9077 | if (objectID == UUID.Zero) return; |
8850 | 9078 | ||
8851 | UUID agentID; | 9079 | UUID agentID; |
8852 | lock (m_host.TaskInventory) | 9080 | m_host.TaskInventory.LockItemsForRead(true); |
8853 | { | 9081 | // we need the permission first, to know which avatar we want to set the camera for |
8854 | // we need the permission first, to know which avatar we want to set the camera for | 9082 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8855 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8856 | 9083 | ||
8857 | if (agentID == UUID.Zero) return; | 9084 | if (agentID == UUID.Zero) |
8858 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9085 | { |
9086 | m_host.TaskInventory.LockItemsForRead(false); | ||
9087 | return; | ||
8859 | } | 9088 | } |
9089 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9090 | { | ||
9091 | m_host.TaskInventory.LockItemsForRead(false); | ||
9092 | return; | ||
9093 | } | ||
9094 | m_host.TaskInventory.LockItemsForRead(false); | ||
8860 | 9095 | ||
8861 | ScenePresence presence = World.GetScenePresence(agentID); | 9096 | ScenePresence presence = World.GetScenePresence(agentID); |
8862 | 9097 | ||
@@ -8906,12 +9141,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8906 | 9141 | ||
8907 | // we need the permission first, to know which avatar we want to clear the camera for | 9142 | // we need the permission first, to know which avatar we want to clear the camera for |
8908 | UUID agentID; | 9143 | UUID agentID; |
8909 | lock (m_host.TaskInventory) | 9144 | m_host.TaskInventory.LockItemsForRead(true); |
9145 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9146 | if (agentID == UUID.Zero) | ||
9147 | { | ||
9148 | m_host.TaskInventory.LockItemsForRead(false); | ||
9149 | return; | ||
9150 | } | ||
9151 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
8910 | { | 9152 | { |
8911 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9153 | m_host.TaskInventory.LockItemsForRead(false); |
8912 | if (agentID == UUID.Zero) return; | 9154 | return; |
8913 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
8914 | } | 9155 | } |
9156 | m_host.TaskInventory.LockItemsForRead(false); | ||
8915 | 9157 | ||
8916 | ScenePresence presence = World.GetScenePresence(agentID); | 9158 | ScenePresence presence = World.GetScenePresence(agentID); |
8917 | 9159 | ||
@@ -9368,15 +9610,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9368 | 9610 | ||
9369 | internal UUID ScriptByName(string name) | 9611 | internal UUID ScriptByName(string name) |
9370 | { | 9612 | { |
9371 | lock (m_host.TaskInventory) | 9613 | m_host.TaskInventory.LockItemsForRead(true); |
9614 | |||
9615 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9372 | { | 9616 | { |
9373 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9617 | if (item.Type == 10 && item.Name == name) |
9374 | { | 9618 | { |
9375 | if (item.Type == 10 && item.Name == name) | 9619 | m_host.TaskInventory.LockItemsForRead(false); |
9376 | return item.ItemID; | 9620 | return item.ItemID; |
9377 | } | 9621 | } |
9378 | } | 9622 | } |
9379 | 9623 | ||
9624 | m_host.TaskInventory.LockItemsForRead(false); | ||
9625 | |||
9380 | return UUID.Zero; | 9626 | return UUID.Zero; |
9381 | } | 9627 | } |
9382 | 9628 | ||
@@ -9417,6 +9663,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9417 | { | 9663 | { |
9418 | m_host.AddScriptLPS(1); | 9664 | m_host.AddScriptLPS(1); |
9419 | 9665 | ||
9666 | //Clone is thread safe | ||
9420 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9667 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9421 | 9668 | ||
9422 | UUID assetID = UUID.Zero; | 9669 | UUID assetID = UUID.Zero; |
@@ -9479,6 +9726,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9479 | { | 9726 | { |
9480 | m_host.AddScriptLPS(1); | 9727 | m_host.AddScriptLPS(1); |
9481 | 9728 | ||
9729 | //Clone is thread safe | ||
9482 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9730 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9483 | 9731 | ||
9484 | UUID assetID = UUID.Zero; | 9732 | 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); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index d30d2dc..6ecafd4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -237,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
237 | 238 | ||
238 | if (part != null) | 239 | if (part != null) |
239 | { | 240 | { |
240 | lock (part.TaskInventory) | 241 | part.TaskInventory.LockItemsForRead(true); |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
241 | { | 243 | { |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
243 | { | ||
244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
245 | } | ||
246 | } | 245 | } |
246 | part.TaskInventory.LockItemsForRead(false); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
@@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
428 | { | 428 | { |
429 | int permsMask; | 429 | int permsMask; |
430 | UUID permsGranter; | 430 | UUID permsGranter; |
431 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
432 | { | 433 | { |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
434 | return; | 435 | return; |
435 | |||
436 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
437 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
438 | } | 436 | } |
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
439 | 440 | ||
440 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
441 | { | 442 | { |
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
544 | return true; | 545 | return true; |
545 | } | 546 | } |
546 | 547 | ||
548 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
547 | public void SetState(string state) | 549 | public void SetState(string state) |
548 | { | 550 | { |
549 | if (state == State) | 551 | if (state == State) |
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
555 | new DetectParams[0])); | 557 | new DetectParams[0])); |
556 | PostEvent(new EventParams("state_entry", new Object[0], | 558 | PostEvent(new EventParams("state_entry", new Object[0], |
557 | new DetectParams[0])); | 559 | new DetectParams[0])); |
558 | 560 | ||
559 | throw new EventAbortException(); | 561 | throw new EventAbortException(); |
560 | } | 562 | } |
561 | 563 | ||
@@ -638,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
638 | /// <returns></returns> | 640 | /// <returns></returns> |
639 | public object EventProcessor() | 641 | public object EventProcessor() |
640 | { | 642 | { |
643 | |||
644 | EventParams data = null; | ||
645 | |||
646 | lock (m_EventQueue) | ||
647 | { | ||
641 | lock (m_Script) | 648 | lock (m_Script) |
642 | { | 649 | { |
643 | EventParams data = null; | 650 | data = (EventParams) m_EventQueue.Dequeue(); |
644 | 651 | if (data == null) // Shouldn't happen | |
645 | lock (m_EventQueue) | ||
646 | { | 652 | { |
647 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
648 | if (data == null) // Shouldn't happen | ||
649 | { | 654 | { |
650 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
651 | { | ||
652 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_CurrentResult = null; | ||
657 | } | ||
658 | return 0; | ||
659 | } | 656 | } |
660 | 657 | else | |
661 | if (data.EventName == "timer") | ||
662 | m_TimerQueued = false; | ||
663 | if (data.EventName == "control") | ||
664 | { | 658 | { |
665 | if (m_ControlEventsInQueue > 0) | 659 | m_CurrentResult = null; |
666 | m_ControlEventsInQueue--; | ||
667 | } | 660 | } |
668 | if (data.EventName == "collision") | 661 | return 0; |
669 | m_CollisionInQueue = false; | ||
670 | } | 662 | } |
671 | |||
672 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
673 | 663 | ||
674 | m_DetectParams = data.DetectParams; | 664 | if (data.EventName == "timer") |
675 | 665 | m_TimerQueued = false; | |
676 | if (data.EventName == "state") // Hardcoded state change | 666 | if (data.EventName == "control") |
677 | { | 667 | { |
678 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 668 | if (m_ControlEventsInQueue > 0) |
679 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 669 | m_ControlEventsInQueue--; |
680 | m_State=data.Params[0].ToString(); | 670 | } |
681 | AsyncCommandManager.RemoveScript(m_Engine, | 671 | if (data.EventName == "collision") |
682 | m_LocalID, m_ItemID); | 672 | m_CollisionInQueue = false; |
673 | } | ||
674 | } | ||
675 | lock(m_Script) | ||
676 | { | ||
677 | |||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
683 | 679 | ||
684 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 680 | m_DetectParams = data.DetectParams; |
685 | m_LocalID); | 681 | |
686 | if (part != null) | 682 | if (data.EventName == "state") // Hardcoded state change |
687 | { | 683 | { |
688 | part.SetScriptEvents(m_ItemID, | 684 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
689 | (int)m_Script.GetStateEventFlags(State)); | 685 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
690 | } | 686 | m_State=data.Params[0].ToString(); |
687 | AsyncCommandManager.RemoveScript(m_Engine, | ||
688 | m_LocalID, m_ItemID); | ||
689 | |||
690 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | ||
691 | m_LocalID); | ||
692 | if (part != null) | ||
693 | { | ||
694 | part.SetScriptEvents(m_ItemID, | ||
695 | (int)m_Script.GetStateEventFlags(State)); | ||
691 | } | 696 | } |
692 | else | 697 | } |
698 | else | ||
699 | { | ||
700 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | ||
701 | data.EventName == "control") // Don't freeze avies! | ||
693 | { | 702 | { |
694 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 703 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
695 | data.EventName == "control") // Don't freeze avies! | 704 | m_LocalID); |
696 | { | 705 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
697 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 706 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
698 | m_LocalID); | ||
699 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | ||
700 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
701 | 707 | ||
702 | try | 708 | try |
703 | { | 709 | { |
704 | m_CurrentEvent = data.EventName; | 710 | m_CurrentEvent = data.EventName; |
705 | m_EventStart = DateTime.Now; | 711 | m_EventStart = DateTime.Now; |
706 | m_InEvent = true; | 712 | m_InEvent = true; |
707 | 713 | ||
708 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 714 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
709 | 715 | ||
710 | m_InEvent = false; | 716 | m_InEvent = false; |
711 | m_CurrentEvent = String.Empty; | 717 | m_CurrentEvent = String.Empty; |
712 | 718 | ||
713 | if (m_SaveState) | 719 | if (m_SaveState) |
714 | { | 720 | { |
715 | // This will be the very first event we deliver | 721 | // This will be the very first event we deliver |
716 | // (state_entry) in default state | 722 | // (state_entry) in default state |
717 | // | 723 | // |
718 | 724 | ||
719 | SaveState(m_Assembly); | 725 | SaveState(m_Assembly); |
720 | 726 | ||
721 | m_SaveState = false; | 727 | m_SaveState = false; |
722 | } | ||
723 | } | 728 | } |
724 | catch (Exception e) | 729 | } |
725 | { | 730 | catch (Exception e) |
726 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); | 731 | { |
727 | m_InEvent = false; | 732 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); |
728 | m_CurrentEvent = String.Empty; | 733 | m_InEvent = false; |
734 | m_CurrentEvent = String.Empty; | ||
729 | 735 | ||
730 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 736 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) |
731 | { | 737 | { |
732 | try | 738 | try |
733 | { | ||
734 | // DISPLAY ERROR INWORLD | ||
735 | string text = FormatException(e); | ||
736 | |||
737 | if (text.Length > 1000) | ||
738 | text = text.Substring(0, 1000); | ||
739 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
740 | ChatTypeEnum.DebugChannel, 2147483647, | ||
741 | part.AbsolutePosition, | ||
742 | part.Name, part.UUID, false); | ||
743 | } | ||
744 | catch (Exception) | ||
745 | { | ||
746 | } | ||
747 | // catch (Exception e2) // LEGIT: User Scripting | ||
748 | // { | ||
749 | // m_log.Error("[SCRIPT]: "+ | ||
750 | // "Error displaying error in-world: " + | ||
751 | // e2.ToString()); | ||
752 | // m_log.Error("[SCRIPT]: " + | ||
753 | // "Errormessage: Error compiling script:\r\n" + | ||
754 | // e.ToString()); | ||
755 | // } | ||
756 | } | ||
757 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
758 | { | 739 | { |
759 | m_InSelfDelete = true; | 740 | // DISPLAY ERROR INWORLD |
760 | if (part != null && part.ParentGroup != null) | 741 | string text = FormatException(e); |
761 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 742 | |
743 | if (text.Length > 1000) | ||
744 | text = text.Substring(0, 1000); | ||
745 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
746 | ChatTypeEnum.DebugChannel, 2147483647, | ||
747 | part.AbsolutePosition, | ||
748 | part.Name, part.UUID, false); | ||
762 | } | 749 | } |
763 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 750 | catch (Exception) |
764 | { | 751 | { |
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
768 | } | 752 | } |
753 | // catch (Exception e2) // LEGIT: User Scripting | ||
754 | // { | ||
755 | // m_log.Error("[SCRIPT]: "+ | ||
756 | // "Error displaying error in-world: " + | ||
757 | // e2.ToString()); | ||
758 | // m_log.Error("[SCRIPT]: " + | ||
759 | // "Errormessage: Error compiling script:\r\n" + | ||
760 | // e.ToString()); | ||
761 | // } | ||
762 | } | ||
763 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
764 | { | ||
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
768 | } | ||
769 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | ||
770 | { | ||
771 | m_InSelfDelete = true; | ||
772 | if (part != null && part.ParentGroup != null) | ||
773 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
769 | } | 774 | } |
770 | } | 775 | } |
771 | } | 776 | } |
777 | } | ||
772 | 778 | ||
773 | lock (m_EventQueue) | 779 | lock (m_EventQueue) |
780 | { | ||
781 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | ||
774 | { | 782 | { |
775 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 783 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
776 | { | 784 | } |
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 785 | else |
778 | } | 786 | { |
779 | else | 787 | m_CurrentResult = null; |
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 788 | } |
789 | } | ||
784 | 790 | ||
785 | m_DetectParams = null; | 791 | m_DetectParams = null; |
786 | 792 | ||
787 | return 0; | 793 | return 0; |
788 | } | 794 | } |
789 | } | 795 | } |
790 | 796 | ||
791 | public int EventTime() | 797 | public int EventTime() |
@@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
824 | new Object[0], new DetectParams[0])); | 830 | new Object[0], new DetectParams[0])); |
825 | } | 831 | } |
826 | 832 | ||
833 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
827 | public void ApiResetScript() | 834 | public void ApiResetScript() |
828 | { | 835 | { |
829 | // bool running = Running; | 836 | // bool running = Running; |