diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
13 files changed, 1735 insertions, 638 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..99973b4 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,477 @@ | |||
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_SUN_MOON_POSITION: | ||
248 | idx++; | ||
249 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | ||
250 | break; | ||
251 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
252 | idx++; | ||
253 | iQ = rules.GetQuaternionItem(idx); | ||
254 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
255 | break; | ||
256 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
257 | idx++; | ||
258 | iV = rules.GetVector3Item(idx); | ||
259 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
260 | break; | ||
261 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
262 | idx++; | ||
263 | iQ = rules.GetQuaternionItem(idx); | ||
264 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
265 | break; | ||
266 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
267 | idx++; | ||
268 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
269 | break; | ||
270 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
271 | idx++; | ||
272 | iQ = rules.GetQuaternionItem(idx); | ||
273 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
274 | break; | ||
275 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
276 | idx++; | ||
277 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
278 | break; | ||
279 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
280 | idx++; | ||
281 | iV = rules.GetVector3Item(idx); | ||
282 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
283 | break; | ||
284 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
285 | idx++; | ||
286 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
289 | idx++; | ||
290 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
291 | break; | ||
292 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
293 | idx++; | ||
294 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
295 | break; | ||
296 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
297 | idx++; | ||
298 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
299 | break; | ||
300 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
301 | idx++; | ||
302 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
303 | break; | ||
304 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
305 | idx++; | ||
306 | iV = rules.GetVector3Item(idx); | ||
307 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
308 | break; | ||
309 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
310 | idx++; | ||
311 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
312 | break; | ||
313 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
314 | idx++; | ||
315 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
316 | break; | ||
317 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
318 | idx++; | ||
319 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
320 | break; | ||
321 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
322 | idx++; | ||
323 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
324 | break; | ||
325 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
326 | idx++; | ||
327 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
328 | break; | ||
329 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
330 | idx++; | ||
331 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
332 | break; | ||
333 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
334 | idx++; | ||
335 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
336 | break; | ||
337 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
338 | idx++; | ||
339 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
340 | break; | ||
341 | case (int)ScriptBaseClass.WL_HORIZON: | ||
342 | idx++; | ||
343 | iQ = rules.GetQuaternionItem(idx); | ||
344 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
345 | break; | ||
346 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
347 | idx++; | ||
348 | iV = rules.GetVector3Item(idx); | ||
349 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
350 | break; | ||
351 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
352 | idx++; | ||
353 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
354 | break; | ||
355 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
356 | idx++; | ||
357 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
358 | break; | ||
359 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
360 | idx++; | ||
361 | iV = rules.GetVector3Item(idx); | ||
362 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
365 | idx++; | ||
366 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
369 | idx++; | ||
370 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
371 | break; | ||
372 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
373 | idx++; | ||
374 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
375 | break; | ||
376 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
377 | idx++; | ||
378 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
379 | break; | ||
380 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
381 | idx++; | ||
382 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
383 | break; | ||
384 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
385 | idx++; | ||
386 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
387 | break; | ||
388 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
389 | idx++; | ||
390 | iQ = rules.GetQuaternionItem(idx); | ||
391 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
392 | break; | ||
393 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
394 | idx++; | ||
395 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
396 | break; | ||
397 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
398 | idx++; | ||
399 | iV = rules.GetVector3Item(idx); | ||
400 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
401 | break; | ||
402 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
403 | idx++; | ||
404 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
405 | break; | ||
406 | } | ||
407 | idx++; | ||
408 | } | ||
409 | return wl; | ||
410 | } | ||
411 | /// <summary> | ||
412 | /// Set the current Windlight scene | ||
413 | /// </summary> | ||
414 | /// <param name="rules"></param> | ||
415 | /// <returns>success: true or false</returns> | ||
416 | public int cmSetWindlightScene(LSL_List rules) | ||
417 | { | ||
418 | if (!m_CMFunctionsEnabled) | ||
419 | { | ||
420 | CMShoutError("Careminster functions are not enabled."); | ||
421 | return 0; | ||
422 | } | ||
423 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
424 | { | ||
425 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
426 | return 0; | ||
427 | } | ||
428 | int success = 0; | ||
429 | m_host.AddScriptLPS(1); | ||
430 | if (Meta7WindlightModule.EnableWindlight) | ||
431 | { | ||
432 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
433 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
434 | success = 1; | ||
435 | } | ||
436 | else | ||
437 | { | ||
438 | CMShoutError("Windlight module is disabled"); | ||
439 | return 0; | ||
440 | } | ||
441 | return success; | ||
442 | } | ||
443 | /// <summary> | ||
444 | /// Set the current Windlight scene to a target avatar | ||
445 | /// </summary> | ||
446 | /// <param name="rules"></param> | ||
447 | /// <returns>success: true or false</returns> | ||
448 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
449 | { | ||
450 | if (!m_CMFunctionsEnabled) | ||
451 | { | ||
452 | CMShoutError("Careminster functions are not enabled."); | ||
453 | return 0; | ||
454 | } | ||
455 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
456 | { | ||
457 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
458 | return 0; | ||
459 | } | ||
460 | int success = 0; | ||
461 | m_host.AddScriptLPS(1); | ||
462 | if (Meta7WindlightModule.EnableWindlight) | ||
463 | { | ||
464 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
465 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
466 | success = 1; | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | CMShoutError("Windlight module is disabled"); | ||
471 | return 0; | ||
472 | } | ||
473 | return success; | ||
474 | } | ||
475 | |||
476 | } | ||
477 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0a871d9..4661488 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); |
@@ -1049,7 +1118,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1049 | public virtual void llDie() | 1118 | public virtual void llDie() |
1050 | { | 1119 | { |
1051 | m_host.AddScriptLPS(1); | 1120 | m_host.AddScriptLPS(1); |
1052 | throw new SelfDeleteException(); | 1121 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1053 | } | 1122 | } |
1054 | 1123 | ||
1055 | public LSL_Float llGround(LSL_Vector offset) | 1124 | public LSL_Float llGround(LSL_Vector offset) |
@@ -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; |
@@ -1296,7 +1367,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1296 | } | 1367 | } |
1297 | 1368 | ||
1298 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) | 1369 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) |
1299 | { | 1370 | { |
1300 | // TODO: this needs to trigger a persistance save as well | 1371 | // TODO: this needs to trigger a persistance save as well |
1301 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1372 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1302 | return; | 1373 | return; |
@@ -1351,6 +1422,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1351 | { | 1422 | { |
1352 | m_host.AddScriptLPS(1); | 1423 | m_host.AddScriptLPS(1); |
1353 | 1424 | ||
1425 | SetColor(m_host, color, face); | ||
1426 | } | ||
1427 | |||
1428 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1429 | { | ||
1430 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1431 | return; | ||
1432 | |||
1433 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1434 | Color4 texcolor; | ||
1435 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1436 | { | ||
1437 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1438 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1439 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1440 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1441 | tex.FaceTextures[face].RGBA = texcolor; | ||
1442 | part.UpdateTexture(tex); | ||
1443 | return; | ||
1444 | } | ||
1445 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1446 | { | ||
1447 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1448 | { | ||
1449 | if (tex.FaceTextures[i] != null) | ||
1450 | { | ||
1451 | texcolor = tex.FaceTextures[i].RGBA; | ||
1452 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1453 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1454 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1455 | tex.FaceTextures[i].RGBA = texcolor; | ||
1456 | } | ||
1457 | texcolor = tex.DefaultTexture.RGBA; | ||
1458 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1459 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1460 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1461 | tex.DefaultTexture.RGBA = texcolor; | ||
1462 | } | ||
1463 | part.UpdateTexture(tex); | ||
1464 | return; | ||
1465 | } | ||
1466 | |||
1354 | if (face == ScriptBaseClass.ALL_SIDES) | 1467 | if (face == ScriptBaseClass.ALL_SIDES) |
1355 | face = SceneObjectPart.ALL_SIDES; | 1468 | face = SceneObjectPart.ALL_SIDES; |
1356 | 1469 | ||
@@ -1358,7 +1471,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1358 | } | 1471 | } |
1359 | 1472 | ||
1360 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1473 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1361 | { | 1474 | { |
1475 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1476 | return; | ||
1477 | |||
1362 | Primitive.TextureEntry tex = part.Shape.Textures; | 1478 | Primitive.TextureEntry tex = part.Shape.Textures; |
1363 | MappingType textype; | 1479 | MappingType textype; |
1364 | textype = MappingType.Default; | 1480 | textype = MappingType.Default; |
@@ -1388,7 +1504,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1388 | } | 1504 | } |
1389 | 1505 | ||
1390 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1506 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1391 | { | 1507 | { |
1508 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1509 | return; | ||
1510 | |||
1392 | Primitive.TextureEntry tex = part.Shape.Textures; | 1511 | Primitive.TextureEntry tex = part.Shape.Textures; |
1393 | if (face >= 0 && face < GetNumberOfSides(part)) | 1512 | if (face >= 0 && face < GetNumberOfSides(part)) |
1394 | { | 1513 | { |
@@ -1413,7 +1532,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1413 | } | 1532 | } |
1414 | 1533 | ||
1415 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1534 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1416 | { | 1535 | { |
1536 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1537 | return; | ||
1417 | 1538 | ||
1418 | Shininess sval = new Shininess(); | 1539 | Shininess sval = new Shininess(); |
1419 | 1540 | ||
@@ -1463,7 +1584,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1463 | } | 1584 | } |
1464 | 1585 | ||
1465 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1586 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1466 | { | 1587 | { |
1588 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1589 | return; | ||
1590 | |||
1467 | Primitive.TextureEntry tex = part.Shape.Textures; | 1591 | Primitive.TextureEntry tex = part.Shape.Textures; |
1468 | if (face >= 0 && face < GetNumberOfSides(part)) | 1592 | if (face >= 0 && face < GetNumberOfSides(part)) |
1469 | { | 1593 | { |
@@ -1530,7 +1654,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1530 | } | 1654 | } |
1531 | 1655 | ||
1532 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1656 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1533 | { | 1657 | { |
1658 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1659 | return; | ||
1660 | |||
1534 | Primitive.TextureEntry tex = part.Shape.Textures; | 1661 | Primitive.TextureEntry tex = part.Shape.Textures; |
1535 | Color4 texcolor; | 1662 | Color4 texcolor; |
1536 | if (face >= 0 && face < GetNumberOfSides(part)) | 1663 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1575,8 +1702,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1575 | /// <param name="Force"></param> | 1702 | /// <param name="Force"></param> |
1576 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1703 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1577 | float wind, float tension, LSL_Vector Force) | 1704 | float wind, float tension, LSL_Vector Force) |
1578 | { | 1705 | { |
1579 | if (part == null) | 1706 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1580 | return; | 1707 | return; |
1581 | 1708 | ||
1582 | if (flexi) | 1709 | if (flexi) |
@@ -1610,8 +1737,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1610 | /// <param name="radius"></param> | 1737 | /// <param name="radius"></param> |
1611 | /// <param name="falloff"></param> | 1738 | /// <param name="falloff"></param> |
1612 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1739 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1613 | { | 1740 | { |
1614 | if (part == null) | 1741 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1615 | return; | 1742 | return; |
1616 | 1743 | ||
1617 | if (light) | 1744 | if (light) |
@@ -1696,7 +1823,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1696 | } | 1823 | } |
1697 | 1824 | ||
1698 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1825 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1699 | { | 1826 | { |
1827 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1828 | return; | ||
1829 | |||
1700 | UUID textureID=new UUID(); | 1830 | UUID textureID=new UUID(); |
1701 | 1831 | ||
1702 | if (!UUID.TryParse(texture, out textureID)) | 1832 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1741,7 +1871,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1741 | } | 1871 | } |
1742 | 1872 | ||
1743 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1873 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1744 | { | 1874 | { |
1875 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1876 | return; | ||
1877 | |||
1745 | Primitive.TextureEntry tex = part.Shape.Textures; | 1878 | Primitive.TextureEntry tex = part.Shape.Textures; |
1746 | if (face >= 0 && face < GetNumberOfSides(part)) | 1879 | if (face >= 0 && face < GetNumberOfSides(part)) |
1747 | { | 1880 | { |
@@ -1777,7 +1910,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1777 | } | 1910 | } |
1778 | 1911 | ||
1779 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1912 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1780 | { | 1913 | { |
1914 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1915 | return; | ||
1916 | |||
1781 | Primitive.TextureEntry tex = part.Shape.Textures; | 1917 | Primitive.TextureEntry tex = part.Shape.Textures; |
1782 | if (face >= 0 && face < GetNumberOfSides(part)) | 1918 | if (face >= 0 && face < GetNumberOfSides(part)) |
1783 | { | 1919 | { |
@@ -1813,7 +1949,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1813 | } | 1949 | } |
1814 | 1950 | ||
1815 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1951 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1816 | { | 1952 | { |
1953 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1954 | return; | ||
1955 | |||
1817 | Primitive.TextureEntry tex = part.Shape.Textures; | 1956 | Primitive.TextureEntry tex = part.Shape.Textures; |
1818 | if (face >= 0 && face < GetNumberOfSides(part)) | 1957 | if (face >= 0 && face < GetNumberOfSides(part)) |
1819 | { | 1958 | { |
@@ -1883,7 +2022,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1883 | } | 2022 | } |
1884 | 2023 | ||
1885 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2024 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1886 | { | 2025 | { |
2026 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2027 | return; | ||
2028 | |||
1887 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2029 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1888 | LSL_Vector currentPos = llGetLocalPos(); | 2030 | LSL_Vector currentPos = llGetLocalPos(); |
1889 | 2031 | ||
@@ -1977,7 +2119,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1977 | } | 2119 | } |
1978 | 2120 | ||
1979 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2121 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1980 | { | 2122 | { |
2123 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2124 | return; | ||
2125 | |||
1981 | part.UpdateRotation(rot); | 2126 | part.UpdateRotation(rot); |
1982 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2127 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1983 | 2128 | ||
@@ -2597,12 +2742,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2597 | 2742 | ||
2598 | m_host.AddScriptLPS(1); | 2743 | m_host.AddScriptLPS(1); |
2599 | 2744 | ||
2745 | m_host.TaskInventory.LockItemsForRead(true); | ||
2600 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2746 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2601 | 2747 | m_host.TaskInventory.LockItemsForRead(false); | |
2602 | lock (m_host.TaskInventory) | ||
2603 | { | ||
2604 | item = m_host.TaskInventory[invItemID]; | ||
2605 | } | ||
2606 | 2748 | ||
2607 | if (item.PermsGranter == UUID.Zero) | 2749 | if (item.PermsGranter == UUID.Zero) |
2608 | return 0; | 2750 | return 0; |
@@ -2677,6 +2819,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2677 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2819 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2678 | return; | 2820 | return; |
2679 | 2821 | ||
2822 | //Clone is thread-safe | ||
2680 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2823 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2681 | 2824 | ||
2682 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2825 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2761,6 +2904,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2761 | // Orient the object to the angle calculated | 2904 | // Orient the object to the angle calculated |
2762 | //llSetRot(rot); | 2905 | //llSetRot(rot); |
2763 | } | 2906 | } |
2907 | |||
2908 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2909 | { | ||
2910 | m_host.AddScriptLPS(1); | ||
2911 | // NotImplemented("llRotLookAt"); | ||
2912 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2913 | |||
2914 | } | ||
2764 | 2915 | ||
2765 | public void llStopLookAt() | 2916 | public void llStopLookAt() |
2766 | { | 2917 | { |
@@ -2808,13 +2959,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2808 | { | 2959 | { |
2809 | TaskInventoryItem item; | 2960 | TaskInventoryItem item; |
2810 | 2961 | ||
2811 | lock (m_host.TaskInventory) | 2962 | m_host.TaskInventory.LockItemsForRead(true); |
2963 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2812 | { | 2964 | { |
2813 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2965 | m_host.TaskInventory.LockItemsForRead(false); |
2814 | return; | 2966 | return; |
2815 | else | 2967 | } |
2816 | item = m_host.TaskInventory[InventorySelf()]; | 2968 | else |
2969 | { | ||
2970 | item = m_host.TaskInventory[InventorySelf()]; | ||
2817 | } | 2971 | } |
2972 | m_host.TaskInventory.LockItemsForRead(false); | ||
2818 | 2973 | ||
2819 | if (item.PermsGranter != UUID.Zero) | 2974 | if (item.PermsGranter != UUID.Zero) |
2820 | { | 2975 | { |
@@ -2836,13 +2991,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2836 | { | 2991 | { |
2837 | TaskInventoryItem item; | 2992 | TaskInventoryItem item; |
2838 | 2993 | ||
2994 | m_host.TaskInventory.LockItemsForRead(true); | ||
2839 | lock (m_host.TaskInventory) | 2995 | lock (m_host.TaskInventory) |
2840 | { | 2996 | { |
2997 | |||
2841 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2998 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2999 | { | ||
3000 | m_host.TaskInventory.LockItemsForRead(false); | ||
2842 | return; | 3001 | return; |
3002 | } | ||
2843 | else | 3003 | else |
3004 | { | ||
2844 | item = m_host.TaskInventory[InventorySelf()]; | 3005 | item = m_host.TaskInventory[InventorySelf()]; |
3006 | } | ||
2845 | } | 3007 | } |
3008 | m_host.TaskInventory.LockItemsForRead(false); | ||
2846 | 3009 | ||
2847 | m_host.AddScriptLPS(1); | 3010 | m_host.AddScriptLPS(1); |
2848 | 3011 | ||
@@ -2879,13 +3042,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2879 | 3042 | ||
2880 | TaskInventoryItem item; | 3043 | TaskInventoryItem item; |
2881 | 3044 | ||
2882 | lock (m_host.TaskInventory) | 3045 | m_host.TaskInventory.LockItemsForRead(true); |
3046 | |||
3047 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2883 | { | 3048 | { |
2884 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3049 | m_host.TaskInventory.LockItemsForRead(false); |
2885 | return; | 3050 | return; |
2886 | else | ||
2887 | item = m_host.TaskInventory[InventorySelf()]; | ||
2888 | } | 3051 | } |
3052 | else | ||
3053 | { | ||
3054 | item = m_host.TaskInventory[InventorySelf()]; | ||
3055 | } | ||
3056 | |||
3057 | m_host.TaskInventory.LockItemsForRead(false); | ||
2889 | 3058 | ||
2890 | if (item.PermsGranter != m_host.OwnerID) | 3059 | if (item.PermsGranter != m_host.OwnerID) |
2891 | return; | 3060 | return; |
@@ -2913,13 +3082,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2913 | 3082 | ||
2914 | TaskInventoryItem item; | 3083 | TaskInventoryItem item; |
2915 | 3084 | ||
2916 | lock (m_host.TaskInventory) | 3085 | m_host.TaskInventory.LockItemsForRead(true); |
3086 | |||
3087 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2917 | { | 3088 | { |
2918 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3089 | m_host.TaskInventory.LockItemsForRead(false); |
2919 | return; | 3090 | return; |
2920 | else | ||
2921 | item = m_host.TaskInventory[InventorySelf()]; | ||
2922 | } | 3091 | } |
3092 | else | ||
3093 | { | ||
3094 | item = m_host.TaskInventory[InventorySelf()]; | ||
3095 | } | ||
3096 | m_host.TaskInventory.LockItemsForRead(false); | ||
3097 | |||
2923 | 3098 | ||
2924 | if (item.PermsGranter != m_host.OwnerID) | 3099 | if (item.PermsGranter != m_host.OwnerID) |
2925 | return; | 3100 | return; |
@@ -2956,8 +3131,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2956 | return m_host.OwnerID.ToString(); | 3131 | return m_host.OwnerID.ToString(); |
2957 | } | 3132 | } |
2958 | 3133 | ||
3134 | [DebuggerNonUserCode] | ||
2959 | public void llInstantMessage(string user, string message) | 3135 | public void llInstantMessage(string user, string message) |
2960 | { | 3136 | { |
3137 | UUID result; | ||
3138 | if (!UUID.TryParse(user, out result)) | ||
3139 | { | ||
3140 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3141 | return; | ||
3142 | } | ||
3143 | |||
3144 | |||
2961 | m_host.AddScriptLPS(1); | 3145 | m_host.AddScriptLPS(1); |
2962 | 3146 | ||
2963 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3147 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2972,7 +3156,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2972 | UUID friendTransactionID = UUID.Random(); | 3156 | UUID friendTransactionID = UUID.Random(); |
2973 | 3157 | ||
2974 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3158 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2975 | 3159 | ||
2976 | GridInstantMessage msg = new GridInstantMessage(); | 3160 | GridInstantMessage msg = new GridInstantMessage(); |
2977 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3161 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2978 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3162 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3121,13 +3305,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3121 | m_host.AddScriptLPS(1); | 3305 | m_host.AddScriptLPS(1); |
3122 | } | 3306 | } |
3123 | 3307 | ||
3124 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3125 | { | ||
3126 | m_host.AddScriptLPS(1); | ||
3127 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3128 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3129 | } | ||
3130 | |||
3131 | public LSL_Integer llStringLength(string str) | 3308 | public LSL_Integer llStringLength(string str) |
3132 | { | 3309 | { |
3133 | m_host.AddScriptLPS(1); | 3310 | m_host.AddScriptLPS(1); |
@@ -3151,14 +3328,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3151 | 3328 | ||
3152 | TaskInventoryItem item; | 3329 | TaskInventoryItem item; |
3153 | 3330 | ||
3154 | lock (m_host.TaskInventory) | 3331 | m_host.TaskInventory.LockItemsForRead(true); |
3332 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3155 | { | 3333 | { |
3156 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3334 | m_host.TaskInventory.LockItemsForRead(false); |
3157 | return; | 3335 | return; |
3158 | else | ||
3159 | item = m_host.TaskInventory[InventorySelf()]; | ||
3160 | } | 3336 | } |
3161 | 3337 | else | |
3338 | { | ||
3339 | item = m_host.TaskInventory[InventorySelf()]; | ||
3340 | } | ||
3341 | m_host.TaskInventory.LockItemsForRead(false); | ||
3162 | if (item.PermsGranter == UUID.Zero) | 3342 | if (item.PermsGranter == UUID.Zero) |
3163 | return; | 3343 | return; |
3164 | 3344 | ||
@@ -3188,13 +3368,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3188 | 3368 | ||
3189 | TaskInventoryItem item; | 3369 | TaskInventoryItem item; |
3190 | 3370 | ||
3191 | lock (m_host.TaskInventory) | 3371 | m_host.TaskInventory.LockItemsForRead(true); |
3372 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3192 | { | 3373 | { |
3193 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3374 | m_host.TaskInventory.LockItemsForRead(false); |
3194 | return; | 3375 | return; |
3195 | else | ||
3196 | item = m_host.TaskInventory[InventorySelf()]; | ||
3197 | } | 3376 | } |
3377 | else | ||
3378 | { | ||
3379 | item = m_host.TaskInventory[InventorySelf()]; | ||
3380 | } | ||
3381 | m_host.TaskInventory.LockItemsForRead(false); | ||
3382 | |||
3198 | 3383 | ||
3199 | if (item.PermsGranter == UUID.Zero) | 3384 | if (item.PermsGranter == UUID.Zero) |
3200 | return; | 3385 | return; |
@@ -3271,10 +3456,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3271 | 3456 | ||
3272 | TaskInventoryItem item; | 3457 | TaskInventoryItem item; |
3273 | 3458 | ||
3274 | lock (m_host.TaskInventory) | 3459 | |
3460 | m_host.TaskInventory.LockItemsForRead(true); | ||
3461 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3462 | { | ||
3463 | m_host.TaskInventory.LockItemsForRead(false); | ||
3464 | return; | ||
3465 | } | ||
3466 | else | ||
3275 | { | 3467 | { |
3276 | item = m_host.TaskInventory[invItemID]; | 3468 | item = m_host.TaskInventory[invItemID]; |
3277 | } | 3469 | } |
3470 | m_host.TaskInventory.LockItemsForRead(false); | ||
3278 | 3471 | ||
3279 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3472 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3280 | { | 3473 | { |
@@ -3306,11 +3499,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3306 | 3499 | ||
3307 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3500 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3308 | { | 3501 | { |
3309 | lock (m_host.TaskInventory) | 3502 | m_host.TaskInventory.LockItemsForWrite(true); |
3310 | { | 3503 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3504 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3312 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3505 | m_host.TaskInventory.LockItemsForWrite(false); |
3313 | } | ||
3314 | 3506 | ||
3315 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3507 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3316 | "run_time_permissions", new Object[] { | 3508 | "run_time_permissions", new Object[] { |
@@ -3330,11 +3522,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3330 | 3522 | ||
3331 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3523 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3332 | { | 3524 | { |
3333 | lock (m_host.TaskInventory) | 3525 | m_host.TaskInventory.LockItemsForWrite(true); |
3334 | { | 3526 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3335 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3527 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3336 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3528 | m_host.TaskInventory.LockItemsForWrite(false); |
3337 | } | ||
3338 | 3529 | ||
3339 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3530 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3340 | "run_time_permissions", new Object[] { | 3531 | "run_time_permissions", new Object[] { |
@@ -3355,11 +3546,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3355 | 3546 | ||
3356 | if (!m_waitingForScriptAnswer) | 3547 | if (!m_waitingForScriptAnswer) |
3357 | { | 3548 | { |
3358 | lock (m_host.TaskInventory) | 3549 | m_host.TaskInventory.LockItemsForWrite(true); |
3359 | { | 3550 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3360 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3551 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3361 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3552 | m_host.TaskInventory.LockItemsForWrite(false); |
3362 | } | ||
3363 | 3553 | ||
3364 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3554 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3365 | m_waitingForScriptAnswer=true; | 3555 | m_waitingForScriptAnswer=true; |
@@ -3394,10 +3584,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3394 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3584 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3395 | llReleaseControls(); | 3585 | llReleaseControls(); |
3396 | 3586 | ||
3397 | lock (m_host.TaskInventory) | 3587 | |
3398 | { | 3588 | m_host.TaskInventory.LockItemsForWrite(true); |
3399 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3589 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3400 | } | 3590 | m_host.TaskInventory.LockItemsForWrite(false); |
3591 | |||
3401 | 3592 | ||
3402 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3593 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3403 | "run_time_permissions", new Object[] { | 3594 | "run_time_permissions", new Object[] { |
@@ -3409,16 +3600,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3409 | { | 3600 | { |
3410 | m_host.AddScriptLPS(1); | 3601 | m_host.AddScriptLPS(1); |
3411 | 3602 | ||
3412 | lock (m_host.TaskInventory) | 3603 | m_host.TaskInventory.LockItemsForRead(true); |
3604 | |||
3605 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3413 | { | 3606 | { |
3414 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3607 | if (item.Type == 10 && item.ItemID == m_itemID) |
3415 | { | 3608 | { |
3416 | if (item.Type == 10 && item.ItemID == m_itemID) | 3609 | m_host.TaskInventory.LockItemsForRead(false); |
3417 | { | 3610 | return item.PermsGranter.ToString(); |
3418 | return item.PermsGranter.ToString(); | ||
3419 | } | ||
3420 | } | 3611 | } |
3421 | } | 3612 | } |
3613 | m_host.TaskInventory.LockItemsForRead(false); | ||
3422 | 3614 | ||
3423 | return UUID.Zero.ToString(); | 3615 | return UUID.Zero.ToString(); |
3424 | } | 3616 | } |
@@ -3427,19 +3619,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3427 | { | 3619 | { |
3428 | m_host.AddScriptLPS(1); | 3620 | m_host.AddScriptLPS(1); |
3429 | 3621 | ||
3430 | lock (m_host.TaskInventory) | 3622 | m_host.TaskInventory.LockItemsForRead(true); |
3623 | |||
3624 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3431 | { | 3625 | { |
3432 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3626 | if (item.Type == 10 && item.ItemID == m_itemID) |
3433 | { | 3627 | { |
3434 | if (item.Type == 10 && item.ItemID == m_itemID) | 3628 | int perms = item.PermsMask; |
3435 | { | 3629 | if (m_automaticLinkPermission) |
3436 | int perms = item.PermsMask; | 3630 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3437 | if (m_automaticLinkPermission) | 3631 | m_host.TaskInventory.LockItemsForRead(false); |
3438 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3632 | return perms; |
3439 | return perms; | ||
3440 | } | ||
3441 | } | 3633 | } |
3442 | } | 3634 | } |
3635 | m_host.TaskInventory.LockItemsForRead(false); | ||
3443 | 3636 | ||
3444 | return 0; | 3637 | return 0; |
3445 | } | 3638 | } |
@@ -3472,11 +3665,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3472 | UUID invItemID = InventorySelf(); | 3665 | UUID invItemID = InventorySelf(); |
3473 | 3666 | ||
3474 | TaskInventoryItem item; | 3667 | TaskInventoryItem item; |
3475 | lock (m_host.TaskInventory) | 3668 | m_host.TaskInventory.LockItemsForRead(true); |
3476 | { | 3669 | item = m_host.TaskInventory[invItemID]; |
3477 | item = m_host.TaskInventory[invItemID]; | 3670 | m_host.TaskInventory.LockItemsForRead(false); |
3478 | } | 3671 | |
3479 | |||
3480 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3672 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3481 | && !m_automaticLinkPermission) | 3673 | && !m_automaticLinkPermission) |
3482 | { | 3674 | { |
@@ -3529,16 +3721,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3529 | m_host.AddScriptLPS(1); | 3721 | m_host.AddScriptLPS(1); |
3530 | UUID invItemID = InventorySelf(); | 3722 | UUID invItemID = InventorySelf(); |
3531 | 3723 | ||
3532 | lock (m_host.TaskInventory) | 3724 | m_host.TaskInventory.LockItemsForRead(true); |
3533 | { | ||
3534 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3725 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3535 | && !m_automaticLinkPermission) | 3726 | && !m_automaticLinkPermission) |
3536 | { | 3727 | { |
3537 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3728 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3729 | m_host.TaskInventory.LockItemsForRead(false); | ||
3538 | return; | 3730 | return; |
3539 | } | 3731 | } |
3540 | } | 3732 | m_host.TaskInventory.LockItemsForRead(false); |
3541 | 3733 | ||
3542 | if (linknum < ScriptBaseClass.LINK_THIS) | 3734 | if (linknum < ScriptBaseClass.LINK_THIS) |
3543 | return; | 3735 | return; |
3544 | 3736 | ||
@@ -3715,17 +3907,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3715 | m_host.AddScriptLPS(1); | 3907 | m_host.AddScriptLPS(1); |
3716 | int count = 0; | 3908 | int count = 0; |
3717 | 3909 | ||
3718 | lock (m_host.TaskInventory) | 3910 | m_host.TaskInventory.LockItemsForRead(true); |
3911 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3719 | { | 3912 | { |
3720 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3913 | if (inv.Value.Type == type || type == -1) |
3721 | { | 3914 | { |
3722 | if (inv.Value.Type == type || type == -1) | 3915 | count = count + 1; |
3723 | { | ||
3724 | count = count + 1; | ||
3725 | } | ||
3726 | } | 3916 | } |
3727 | } | 3917 | } |
3728 | 3918 | ||
3919 | m_host.TaskInventory.LockItemsForRead(false); | ||
3729 | return count; | 3920 | return count; |
3730 | } | 3921 | } |
3731 | 3922 | ||
@@ -3734,16 +3925,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3734 | m_host.AddScriptLPS(1); | 3925 | m_host.AddScriptLPS(1); |
3735 | ArrayList keys = new ArrayList(); | 3926 | ArrayList keys = new ArrayList(); |
3736 | 3927 | ||
3737 | lock (m_host.TaskInventory) | 3928 | m_host.TaskInventory.LockItemsForRead(true); |
3929 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3738 | { | 3930 | { |
3739 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3931 | if (inv.Value.Type == type || type == -1) |
3740 | { | 3932 | { |
3741 | if (inv.Value.Type == type || type == -1) | 3933 | keys.Add(inv.Value.Name); |
3742 | { | ||
3743 | keys.Add(inv.Value.Name); | ||
3744 | } | ||
3745 | } | 3934 | } |
3746 | } | 3935 | } |
3936 | m_host.TaskInventory.LockItemsForRead(false); | ||
3747 | 3937 | ||
3748 | if (keys.Count == 0) | 3938 | if (keys.Count == 0) |
3749 | { | 3939 | { |
@@ -3780,20 +3970,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3780 | } | 3970 | } |
3781 | 3971 | ||
3782 | // move the first object found with this inventory name | 3972 | // move the first object found with this inventory name |
3783 | lock (m_host.TaskInventory) | 3973 | m_host.TaskInventory.LockItemsForRead(true); |
3974 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3784 | { | 3975 | { |
3785 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3976 | if (inv.Value.Name == inventory) |
3786 | { | 3977 | { |
3787 | if (inv.Value.Name == inventory) | 3978 | found = true; |
3788 | { | 3979 | objId = inv.Key; |
3789 | found = true; | 3980 | assetType = inv.Value.Type; |
3790 | objId = inv.Key; | 3981 | objName = inv.Value.Name; |
3791 | assetType = inv.Value.Type; | 3982 | break; |
3792 | objName = inv.Value.Name; | ||
3793 | break; | ||
3794 | } | ||
3795 | } | 3983 | } |
3796 | } | 3984 | } |
3985 | m_host.TaskInventory.LockItemsForRead(false); | ||
3797 | 3986 | ||
3798 | if (!found) | 3987 | if (!found) |
3799 | { | 3988 | { |
@@ -3838,24 +4027,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3838 | ScriptSleep(3000); | 4027 | ScriptSleep(3000); |
3839 | } | 4028 | } |
3840 | 4029 | ||
4030 | [DebuggerNonUserCode] | ||
3841 | public void llRemoveInventory(string name) | 4031 | public void llRemoveInventory(string name) |
3842 | { | 4032 | { |
3843 | m_host.AddScriptLPS(1); | 4033 | m_host.AddScriptLPS(1); |
3844 | 4034 | ||
3845 | lock (m_host.TaskInventory) | 4035 | m_host.TaskInventory.LockItemsForRead(true); |
4036 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3846 | { | 4037 | { |
3847 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4038 | if (item.Name == name) |
3848 | { | 4039 | { |
3849 | if (item.Name == name) | 4040 | if (item.ItemID == m_itemID) |
3850 | { | 4041 | throw new ScriptDeleteException(); |
3851 | if (item.ItemID == m_itemID) | 4042 | else |
3852 | throw new ScriptDeleteException(); | 4043 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3853 | else | 4044 | |
3854 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4045 | m_host.TaskInventory.LockItemsForRead(false); |
3855 | return; | 4046 | return; |
3856 | } | ||
3857 | } | 4047 | } |
3858 | } | 4048 | } |
4049 | m_host.TaskInventory.LockItemsForRead(false); | ||
3859 | } | 4050 | } |
3860 | 4051 | ||
3861 | public void llSetText(string text, LSL_Vector color, double alpha) | 4052 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3944,6 +4135,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3944 | { | 4135 | { |
3945 | m_host.AddScriptLPS(1); | 4136 | m_host.AddScriptLPS(1); |
3946 | 4137 | ||
4138 | //Clone is thread safe | ||
3947 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4139 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3948 | 4140 | ||
3949 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4141 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -4032,17 +4224,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4032 | UUID soundId = UUID.Zero; | 4224 | UUID soundId = UUID.Zero; |
4033 | if (!UUID.TryParse(impact_sound, out soundId)) | 4225 | if (!UUID.TryParse(impact_sound, out soundId)) |
4034 | { | 4226 | { |
4035 | lock (m_host.TaskInventory) | 4227 | m_host.TaskInventory.LockItemsForRead(true); |
4228 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4036 | { | 4229 | { |
4037 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4230 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4038 | { | 4231 | { |
4039 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4232 | soundId = item.AssetID; |
4040 | { | 4233 | break; |
4041 | soundId = item.AssetID; | ||
4042 | break; | ||
4043 | } | ||
4044 | } | 4234 | } |
4045 | } | 4235 | } |
4236 | m_host.TaskInventory.LockItemsForRead(false); | ||
4046 | } | 4237 | } |
4047 | m_host.CollisionSound = soundId; | 4238 | m_host.CollisionSound = soundId; |
4048 | m_host.CollisionSoundVolume = (float)impact_volume; | 4239 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4088,6 +4279,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4088 | UUID partItemID; | 4279 | UUID partItemID; |
4089 | foreach (SceneObjectPart part in parts) | 4280 | foreach (SceneObjectPart part in parts) |
4090 | { | 4281 | { |
4282 | //Clone is thread safe | ||
4091 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4283 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4092 | 4284 | ||
4093 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4285 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4302,17 +4494,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4302 | 4494 | ||
4303 | m_host.AddScriptLPS(1); | 4495 | m_host.AddScriptLPS(1); |
4304 | 4496 | ||
4305 | lock (m_host.TaskInventory) | 4497 | m_host.TaskInventory.LockItemsForRead(true); |
4498 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4306 | { | 4499 | { |
4307 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4500 | if (item.Type == 10 && item.ItemID == m_itemID) |
4308 | { | 4501 | { |
4309 | if (item.Type == 10 && item.ItemID == m_itemID) | 4502 | result = item.Name!=null?item.Name:String.Empty; |
4310 | { | 4503 | break; |
4311 | result = item.Name != null ? item.Name : String.Empty; | ||
4312 | break; | ||
4313 | } | ||
4314 | } | 4504 | } |
4315 | } | 4505 | } |
4506 | m_host.TaskInventory.LockItemsForRead(false); | ||
4316 | 4507 | ||
4317 | return result; | 4508 | return result; |
4318 | } | 4509 | } |
@@ -4465,23 +4656,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4465 | { | 4656 | { |
4466 | m_host.AddScriptLPS(1); | 4657 | m_host.AddScriptLPS(1); |
4467 | 4658 | ||
4468 | lock (m_host.TaskInventory) | 4659 | m_host.TaskInventory.LockItemsForRead(true); |
4660 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4469 | { | 4661 | { |
4470 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4662 | if (inv.Value.Name == name) |
4471 | { | 4663 | { |
4472 | if (inv.Value.Name == name) | 4664 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4473 | { | 4665 | { |
4474 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4666 | m_host.TaskInventory.LockItemsForRead(false); |
4475 | { | 4667 | return inv.Value.AssetID.ToString(); |
4476 | return inv.Value.AssetID.ToString(); | 4668 | } |
4477 | } | 4669 | else |
4478 | else | 4670 | { |
4479 | { | 4671 | m_host.TaskInventory.LockItemsForRead(false); |
4480 | return UUID.Zero.ToString(); | 4672 | return UUID.Zero.ToString(); |
4481 | } | ||
4482 | } | 4673 | } |
4483 | } | 4674 | } |
4484 | } | 4675 | } |
4676 | m_host.TaskInventory.LockItemsForRead(false); | ||
4485 | 4677 | ||
4486 | return UUID.Zero.ToString(); | 4678 | return UUID.Zero.ToString(); |
4487 | } | 4679 | } |
@@ -6034,14 +6226,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6034 | 6226 | ||
6035 | protected UUID GetTaskInventoryItem(string name) | 6227 | protected UUID GetTaskInventoryItem(string name) |
6036 | { | 6228 | { |
6037 | lock (m_host.TaskInventory) | 6229 | m_host.TaskInventory.LockItemsForRead(true); |
6230 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6038 | { | 6231 | { |
6039 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6232 | if (inv.Value.Name == name) |
6040 | { | 6233 | { |
6041 | if (inv.Value.Name == name) | 6234 | m_host.TaskInventory.LockItemsForRead(false); |
6042 | return inv.Key; | 6235 | return inv.Key; |
6043 | } | 6236 | } |
6044 | } | 6237 | } |
6238 | m_host.TaskInventory.LockItemsForRead(false); | ||
6045 | 6239 | ||
6046 | return UUID.Zero; | 6240 | return UUID.Zero; |
6047 | } | 6241 | } |
@@ -6369,22 +6563,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6369 | } | 6563 | } |
6370 | 6564 | ||
6371 | // copy the first script found with this inventory name | 6565 | // copy the first script found with this inventory name |
6372 | lock (m_host.TaskInventory) | 6566 | m_host.TaskInventory.LockItemsForRead(true); |
6567 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6373 | { | 6568 | { |
6374 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6569 | if (inv.Value.Name == name) |
6375 | { | 6570 | { |
6376 | if (inv.Value.Name == name) | 6571 | // make sure the object is a script |
6572 | if (10 == inv.Value.Type) | ||
6377 | { | 6573 | { |
6378 | // make sure the object is a script | 6574 | found = true; |
6379 | if (10 == inv.Value.Type) | 6575 | srcId = inv.Key; |
6380 | { | 6576 | break; |
6381 | found = true; | ||
6382 | srcId = inv.Key; | ||
6383 | break; | ||
6384 | } | ||
6385 | } | 6577 | } |
6386 | } | 6578 | } |
6387 | } | 6579 | } |
6580 | m_host.TaskInventory.LockItemsForRead(false); | ||
6388 | 6581 | ||
6389 | if (!found) | 6582 | if (!found) |
6390 | { | 6583 | { |
@@ -6466,8 +6659,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6466 | } | 6659 | } |
6467 | 6660 | ||
6468 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6661 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6469 | { | 6662 | { |
6470 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6663 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6664 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6665 | return shapeBlock; | ||
6471 | 6666 | ||
6472 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6667 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6473 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6668 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6537,7 +6732,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6537 | } | 6732 | } |
6538 | 6733 | ||
6539 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6734 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6540 | { | 6735 | { |
6736 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6737 | return; | ||
6738 | |||
6541 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6739 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6542 | 6740 | ||
6543 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6741 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6586,7 +6784,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6586 | } | 6784 | } |
6587 | 6785 | ||
6588 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6786 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6589 | { | 6787 | { |
6788 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6789 | return; | ||
6790 | |||
6590 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6791 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6591 | 6792 | ||
6592 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6793 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6628,7 +6829,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6628 | } | 6829 | } |
6629 | 6830 | ||
6630 | 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) | 6831 | 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) |
6631 | { | 6832 | { |
6833 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6834 | return; | ||
6835 | |||
6632 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6836 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6633 | 6837 | ||
6634 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6838 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6749,7 +6953,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6749 | } | 6953 | } |
6750 | 6954 | ||
6751 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6955 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6752 | { | 6956 | { |
6957 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6958 | return; | ||
6959 | |||
6753 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6960 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6754 | UUID sculptId; | 6961 | UUID sculptId; |
6755 | 6962 | ||
@@ -6783,14 +6990,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6783 | } | 6990 | } |
6784 | 6991 | ||
6785 | public void llSetPrimitiveParams(LSL_List rules) | 6992 | public void llSetPrimitiveParams(LSL_List rules) |
6786 | { | 6993 | { |
6787 | m_host.AddScriptLPS(1); | 6994 | m_host.AddScriptLPS(1); |
6788 | SetPrimParams(m_host, rules); | 6995 | SetPrimParams(m_host, rules); |
6789 | } | 6996 | } |
6790 | 6997 | ||
6791 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 6998 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6792 | { | 6999 | { |
6793 | m_host.AddScriptLPS(1); | 7000 | m_host.AddScriptLPS(1); |
6794 | 7001 | ||
6795 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7002 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6796 | 7003 | ||
@@ -6804,7 +7011,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6804 | } | 7011 | } |
6805 | 7012 | ||
6806 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7013 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6807 | { | 7014 | { |
7015 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7016 | return; | ||
7017 | |||
6808 | int idx = 0; | 7018 | int idx = 0; |
6809 | 7019 | ||
6810 | while (idx < rules.Length) | 7020 | while (idx < rules.Length) |
@@ -7635,25 +7845,96 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7635 | } | 7845 | } |
7636 | break; | 7846 | break; |
7637 | 7847 | ||
7638 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7848 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7639 | // TODO-------------- | 7849 | if (remain < 1) |
7640 | if (remain < 1) | 7850 | return res; |
7641 | return res; | 7851 | face = (int)rules.GetLSLIntegerItem(idx++); |
7642 | 7852 | ||
7643 | face=(int)rules.GetLSLIntegerItem(idx++); | 7853 | tex = part.Shape.Textures; |
7644 | 7854 | int shiny; | |
7645 | res.Add(new LSL_Integer(0)); | 7855 | if (face == ScriptBaseClass.ALL_SIDES) |
7646 | res.Add(new LSL_Integer(0)); | 7856 | { |
7857 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7858 | { | ||
7859 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7860 | if (shinyness == Shininess.High) | ||
7861 | { | ||
7862 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7863 | } | ||
7864 | else if (shinyness == Shininess.Medium) | ||
7865 | { | ||
7866 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7867 | } | ||
7868 | else if (shinyness == Shininess.Low) | ||
7869 | { | ||
7870 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7871 | } | ||
7872 | else | ||
7873 | { | ||
7874 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7875 | } | ||
7876 | res.Add(new LSL_Integer(shiny)); | ||
7877 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7878 | } | ||
7879 | } | ||
7880 | else | ||
7881 | { | ||
7882 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7883 | if (shinyness == Shininess.High) | ||
7884 | { | ||
7885 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7886 | } | ||
7887 | else if (shinyness == Shininess.Medium) | ||
7888 | { | ||
7889 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7890 | } | ||
7891 | else if (shinyness == Shininess.Low) | ||
7892 | { | ||
7893 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7894 | } | ||
7895 | else | ||
7896 | { | ||
7897 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7898 | } | ||
7899 | res.Add(new LSL_Integer(shiny)); | ||
7900 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7901 | } | ||
7647 | break; | 7902 | break; |
7648 | 7903 | ||
7649 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7904 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7650 | // TODO-------------- | 7905 | if (remain < 1) |
7651 | if (remain < 1) | 7906 | return res; |
7652 | return res; | 7907 | face = (int)rules.GetLSLIntegerItem(idx++); |
7653 | 7908 | ||
7654 | face=(int)rules.GetLSLIntegerItem(idx++); | 7909 | tex = part.Shape.Textures; |
7655 | 7910 | int fullbright; | |
7656 | res.Add(new LSL_Integer(0)); | 7911 | if (face == ScriptBaseClass.ALL_SIDES) |
7912 | { | ||
7913 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7914 | { | ||
7915 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7916 | { | ||
7917 | fullbright = ScriptBaseClass.TRUE; | ||
7918 | } | ||
7919 | else | ||
7920 | { | ||
7921 | fullbright = ScriptBaseClass.FALSE; | ||
7922 | } | ||
7923 | res.Add(new LSL_Integer(fullbright)); | ||
7924 | } | ||
7925 | } | ||
7926 | else | ||
7927 | { | ||
7928 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7929 | { | ||
7930 | fullbright = ScriptBaseClass.TRUE; | ||
7931 | } | ||
7932 | else | ||
7933 | { | ||
7934 | fullbright = ScriptBaseClass.FALSE; | ||
7935 | } | ||
7936 | res.Add(new LSL_Integer(fullbright)); | ||
7937 | } | ||
7657 | break; | 7938 | break; |
7658 | 7939 | ||
7659 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7940 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7674,14 +7955,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7674 | break; | 7955 | break; |
7675 | 7956 | ||
7676 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 7957 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7677 | // TODO-------------- | 7958 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7678 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 7959 | if (remain < 1) |
7679 | if (remain < 1) | 7960 | return res; |
7680 | return res; | 7961 | face = (int)rules.GetLSLIntegerItem(idx++); |
7681 | 7962 | ||
7682 | face=(int)rules.GetLSLIntegerItem(idx++); | 7963 | tex = part.Shape.Textures; |
7683 | 7964 | if (face == ScriptBaseClass.ALL_SIDES) | |
7684 | res.Add(new LSL_Integer(0)); | 7965 | { |
7966 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7967 | { | ||
7968 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
7969 | { | ||
7970 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
7971 | } | ||
7972 | else | ||
7973 | { | ||
7974 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
7975 | } | ||
7976 | } | ||
7977 | } | ||
7978 | else | ||
7979 | { | ||
7980 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
7981 | { | ||
7982 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
7983 | } | ||
7984 | else | ||
7985 | { | ||
7986 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
7987 | } | ||
7988 | } | ||
7685 | break; | 7989 | break; |
7686 | 7990 | ||
7687 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 7991 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7699,14 +8003,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7699 | res.Add(new LSL_Float(shape.LightFalloff)); // falloff | 8003 | res.Add(new LSL_Float(shape.LightFalloff)); // falloff |
7700 | break; | 8004 | break; |
7701 | 8005 | ||
7702 | case (int)ScriptBaseClass.PRIM_GLOW: | 8006 | case (int)ScriptBaseClass.PRIM_GLOW: |
7703 | // TODO-------------- | 8007 | if (remain < 1) |
7704 | if (remain < 1) | ||
7705 | return res; | 8008 | return res; |
7706 | 8009 | face = (int)rules.GetLSLIntegerItem(idx++); | |
7707 | face=(int)rules.GetLSLIntegerItem(idx++); | 8010 | |
7708 | 8011 | tex = part.Shape.Textures; | |
7709 | res.Add(new LSL_Float(0)); | 8012 | float primglow; |
8013 | if (face == ScriptBaseClass.ALL_SIDES) | ||
8014 | { | ||
8015 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8016 | { | ||
8017 | primglow = tex.GetFace((uint)face).Glow; | ||
8018 | res.Add(new LSL_Float(primglow)); | ||
8019 | } | ||
8020 | } | ||
8021 | else | ||
8022 | { | ||
8023 | primglow = tex.GetFace((uint)face).Glow; | ||
8024 | res.Add(new LSL_Float(primglow)); | ||
8025 | } | ||
7710 | break; | 8026 | break; |
7711 | case (int)ScriptBaseClass.PRIM_TEXT: | 8027 | case (int)ScriptBaseClass.PRIM_TEXT: |
7712 | Color4 textColor = part.GetTextColor(); | 8028 | Color4 textColor = part.GetTextColor(); |
@@ -8243,28 +8559,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8243 | { | 8559 | { |
8244 | m_host.AddScriptLPS(1); | 8560 | m_host.AddScriptLPS(1); |
8245 | 8561 | ||
8246 | lock (m_host.TaskInventory) | 8562 | m_host.TaskInventory.LockItemsForRead(true); |
8563 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8247 | { | 8564 | { |
8248 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8565 | if (inv.Value.Name == item) |
8249 | { | 8566 | { |
8250 | if (inv.Value.Name == item) | 8567 | m_host.TaskInventory.LockItemsForRead(false); |
8568 | switch (mask) | ||
8251 | { | 8569 | { |
8252 | switch (mask) | 8570 | case 0: |
8253 | { | 8571 | return (int)inv.Value.BasePermissions; |
8254 | case 0: | 8572 | case 1: |
8255 | return (int)inv.Value.BasePermissions; | 8573 | return (int)inv.Value.CurrentPermissions; |
8256 | case 1: | 8574 | case 2: |
8257 | return (int)inv.Value.CurrentPermissions; | 8575 | return (int)inv.Value.GroupPermissions; |
8258 | case 2: | 8576 | case 3: |
8259 | return (int)inv.Value.GroupPermissions; | 8577 | return (int)inv.Value.EveryonePermissions; |
8260 | case 3: | 8578 | case 4: |
8261 | return (int)inv.Value.EveryonePermissions; | 8579 | return (int)inv.Value.NextPermissions; |
8262 | case 4: | ||
8263 | return (int)inv.Value.NextPermissions; | ||
8264 | } | ||
8265 | } | 8580 | } |
8266 | } | 8581 | } |
8267 | } | 8582 | } |
8583 | m_host.TaskInventory.LockItemsForRead(false); | ||
8268 | 8584 | ||
8269 | return -1; | 8585 | return -1; |
8270 | } | 8586 | } |
@@ -8311,16 +8627,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8311 | { | 8627 | { |
8312 | m_host.AddScriptLPS(1); | 8628 | m_host.AddScriptLPS(1); |
8313 | 8629 | ||
8314 | lock (m_host.TaskInventory) | 8630 | m_host.TaskInventory.LockItemsForRead(true); |
8631 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8315 | { | 8632 | { |
8316 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8633 | if (inv.Value.Name == item) |
8317 | { | 8634 | { |
8318 | if (inv.Value.Name == item) | 8635 | m_host.TaskInventory.LockItemsForRead(false); |
8319 | { | 8636 | return inv.Value.CreatorID.ToString(); |
8320 | return inv.Value.CreatorID.ToString(); | ||
8321 | } | ||
8322 | } | 8637 | } |
8323 | } | 8638 | } |
8639 | m_host.TaskInventory.LockItemsForRead(false); | ||
8324 | 8640 | ||
8325 | llSay(0, "No item name '" + item + "'"); | 8641 | llSay(0, "No item name '" + item + "'"); |
8326 | 8642 | ||
@@ -8849,16 +9165,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8849 | { | 9165 | { |
8850 | m_host.AddScriptLPS(1); | 9166 | m_host.AddScriptLPS(1); |
8851 | 9167 | ||
8852 | lock (m_host.TaskInventory) | 9168 | m_host.TaskInventory.LockItemsForRead(true); |
9169 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8853 | { | 9170 | { |
8854 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9171 | if (inv.Value.Name == name) |
8855 | { | 9172 | { |
8856 | if (inv.Value.Name == name) | 9173 | m_host.TaskInventory.LockItemsForRead(false); |
8857 | { | 9174 | return inv.Value.Type; |
8858 | return inv.Value.Type; | ||
8859 | } | ||
8860 | } | 9175 | } |
8861 | } | 9176 | } |
9177 | m_host.TaskInventory.LockItemsForRead(false); | ||
8862 | 9178 | ||
8863 | return -1; | 9179 | return -1; |
8864 | } | 9180 | } |
@@ -8868,16 +9184,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8868 | m_host.AddScriptLPS(1); | 9184 | m_host.AddScriptLPS(1); |
8869 | 9185 | ||
8870 | if (quick_pay_buttons.Data.Length < 4) | 9186 | if (quick_pay_buttons.Data.Length < 4) |
8871 | { | 9187 | { |
8872 | LSLError("List must have at least 4 elements"); | 9188 | int x; |
8873 | return; | 9189 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9190 | { | ||
9191 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9192 | } | ||
8874 | } | 9193 | } |
8875 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9194 | int[] nPrice = new int[5]; |
8876 | 9195 | nPrice[0]=price; | |
8877 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9196 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8878 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9197 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8879 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9198 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8880 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9199 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9200 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8881 | m_host.ParentGroup.HasGroupChanged = true; | 9201 | m_host.ParentGroup.HasGroupChanged = true; |
8882 | } | 9202 | } |
8883 | 9203 | ||
@@ -8889,17 +9209,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8889 | if (invItemID == UUID.Zero) | 9209 | if (invItemID == UUID.Zero) |
8890 | return new LSL_Vector(); | 9210 | return new LSL_Vector(); |
8891 | 9211 | ||
8892 | lock (m_host.TaskInventory) | 9212 | m_host.TaskInventory.LockItemsForRead(true); |
9213 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8893 | { | 9214 | { |
8894 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9215 | m_host.TaskInventory.LockItemsForRead(false); |
8895 | return new LSL_Vector(); | 9216 | return new LSL_Vector(); |
9217 | } | ||
8896 | 9218 | ||
8897 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9219 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8898 | { | 9220 | { |
8899 | ShoutError("No permissions to track the camera"); | 9221 | ShoutError("No permissions to track the camera"); |
8900 | return new LSL_Vector(); | 9222 | m_host.TaskInventory.LockItemsForRead(false); |
8901 | } | 9223 | return new LSL_Vector(); |
8902 | } | 9224 | } |
9225 | m_host.TaskInventory.LockItemsForRead(false); | ||
8903 | 9226 | ||
8904 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9227 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8905 | if (presence != null) | 9228 | if (presence != null) |
@@ -8917,17 +9240,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8917 | if (invItemID == UUID.Zero) | 9240 | if (invItemID == UUID.Zero) |
8918 | return new LSL_Rotation(); | 9241 | return new LSL_Rotation(); |
8919 | 9242 | ||
8920 | lock (m_host.TaskInventory) | 9243 | m_host.TaskInventory.LockItemsForRead(true); |
9244 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8921 | { | 9245 | { |
8922 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9246 | m_host.TaskInventory.LockItemsForRead(false); |
8923 | return new LSL_Rotation(); | 9247 | return new LSL_Rotation(); |
8924 | 9248 | } | |
8925 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9249 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8926 | { | 9250 | { |
8927 | ShoutError("No permissions to track the camera"); | 9251 | ShoutError("No permissions to track the camera"); |
8928 | return new LSL_Rotation(); | 9252 | m_host.TaskInventory.LockItemsForRead(false); |
8929 | } | 9253 | return new LSL_Rotation(); |
8930 | } | 9254 | } |
9255 | m_host.TaskInventory.LockItemsForRead(false); | ||
8931 | 9256 | ||
8932 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9257 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8933 | if (presence != null) | 9258 | if (presence != null) |
@@ -9077,14 +9402,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9077 | if (objectID == UUID.Zero) return; | 9402 | if (objectID == UUID.Zero) return; |
9078 | 9403 | ||
9079 | UUID agentID; | 9404 | UUID agentID; |
9080 | lock (m_host.TaskInventory) | 9405 | m_host.TaskInventory.LockItemsForRead(true); |
9081 | { | 9406 | // we need the permission first, to know which avatar we want to set the camera for |
9082 | // we need the permission first, to know which avatar we want to set the camera for | 9407 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9083 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9084 | 9408 | ||
9085 | if (agentID == UUID.Zero) return; | 9409 | if (agentID == UUID.Zero) |
9086 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9410 | { |
9411 | m_host.TaskInventory.LockItemsForRead(false); | ||
9412 | return; | ||
9413 | } | ||
9414 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9415 | { | ||
9416 | m_host.TaskInventory.LockItemsForRead(false); | ||
9417 | return; | ||
9087 | } | 9418 | } |
9419 | m_host.TaskInventory.LockItemsForRead(false); | ||
9088 | 9420 | ||
9089 | ScenePresence presence = World.GetScenePresence(agentID); | 9421 | ScenePresence presence = World.GetScenePresence(agentID); |
9090 | 9422 | ||
@@ -9134,12 +9466,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9134 | 9466 | ||
9135 | // we need the permission first, to know which avatar we want to clear the camera for | 9467 | // we need the permission first, to know which avatar we want to clear the camera for |
9136 | UUID agentID; | 9468 | UUID agentID; |
9137 | lock (m_host.TaskInventory) | 9469 | m_host.TaskInventory.LockItemsForRead(true); |
9470 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9471 | if (agentID == UUID.Zero) | ||
9138 | { | 9472 | { |
9139 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9473 | m_host.TaskInventory.LockItemsForRead(false); |
9140 | if (agentID == UUID.Zero) return; | 9474 | return; |
9141 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9142 | } | 9475 | } |
9476 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9477 | { | ||
9478 | m_host.TaskInventory.LockItemsForRead(false); | ||
9479 | return; | ||
9480 | } | ||
9481 | m_host.TaskInventory.LockItemsForRead(false); | ||
9143 | 9482 | ||
9144 | ScenePresence presence = World.GetScenePresence(agentID); | 9483 | ScenePresence presence = World.GetScenePresence(agentID); |
9145 | 9484 | ||
@@ -9596,15 +9935,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9596 | 9935 | ||
9597 | internal UUID ScriptByName(string name) | 9936 | internal UUID ScriptByName(string name) |
9598 | { | 9937 | { |
9599 | lock (m_host.TaskInventory) | 9938 | m_host.TaskInventory.LockItemsForRead(true); |
9939 | |||
9940 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9600 | { | 9941 | { |
9601 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9942 | if (item.Type == 10 && item.Name == name) |
9602 | { | 9943 | { |
9603 | if (item.Type == 10 && item.Name == name) | 9944 | m_host.TaskInventory.LockItemsForRead(false); |
9604 | return item.ItemID; | 9945 | return item.ItemID; |
9605 | } | 9946 | } |
9606 | } | 9947 | } |
9607 | 9948 | ||
9949 | m_host.TaskInventory.LockItemsForRead(false); | ||
9950 | |||
9608 | return UUID.Zero; | 9951 | return UUID.Zero; |
9609 | } | 9952 | } |
9610 | 9953 | ||
@@ -9645,6 +9988,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9645 | { | 9988 | { |
9646 | m_host.AddScriptLPS(1); | 9989 | m_host.AddScriptLPS(1); |
9647 | 9990 | ||
9991 | //Clone is thread safe | ||
9648 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9992 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9649 | 9993 | ||
9650 | UUID assetID = UUID.Zero; | 9994 | UUID assetID = UUID.Zero; |
@@ -9707,6 +10051,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9707 | { | 10051 | { |
9708 | m_host.AddScriptLPS(1); | 10052 | m_host.AddScriptLPS(1); |
9709 | 10053 | ||
10054 | //Clone is thread safe | ||
9710 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10055 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9711 | 10056 | ||
9712 | UUID assetID = UUID.Zero; | 10057 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 85ee29d..845834e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -718,18 +718,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
718 | if (target != null) | 718 | if (target != null) |
719 | { | 719 | { |
720 | UUID animID=UUID.Zero; | 720 | UUID animID=UUID.Zero; |
721 | lock (m_host.TaskInventory) | 721 | m_host.TaskInventory.LockItemsForRead(true); |
722 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
722 | { | 723 | { |
723 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 724 | if (inv.Value.Name == animation) |
724 | { | 725 | { |
725 | if (inv.Value.Name == animation) | 726 | if (inv.Value.Type == (int)AssetType.Animation) |
726 | { | 727 | animID = inv.Value.AssetID; |
727 | if (inv.Value.Type == (int)AssetType.Animation) | 728 | continue; |
728 | animID = inv.Value.AssetID; | ||
729 | continue; | ||
730 | } | ||
731 | } | 729 | } |
732 | } | 730 | } |
731 | m_host.TaskInventory.LockItemsForRead(false); | ||
733 | if (animID == UUID.Zero) | 732 | if (animID == UUID.Zero) |
734 | target.Animator.AddAnimation(animation, m_host.UUID); | 733 | target.Animator.AddAnimation(animation, m_host.UUID); |
735 | else | 734 | else |
@@ -751,18 +750,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
751 | if (target != null) | 750 | if (target != null) |
752 | { | 751 | { |
753 | UUID animID=UUID.Zero; | 752 | UUID animID=UUID.Zero; |
754 | lock (m_host.TaskInventory) | 753 | m_host.TaskInventory.LockItemsForRead(true); |
754 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
755 | { | 755 | { |
756 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 756 | if (inv.Value.Name == animation) |
757 | { | 757 | { |
758 | if (inv.Value.Name == animation) | 758 | if (inv.Value.Type == (int)AssetType.Animation) |
759 | { | 759 | animID = inv.Value.AssetID; |
760 | if (inv.Value.Type == (int)AssetType.Animation) | 760 | continue; |
761 | animID = inv.Value.AssetID; | ||
762 | continue; | ||
763 | } | ||
764 | } | 761 | } |
765 | } | 762 | } |
763 | m_host.TaskInventory.LockItemsForRead(false); | ||
766 | 764 | ||
767 | if (animID == UUID.Zero) | 765 | if (animID == UUID.Zero) |
768 | target.Animator.RemoveAnimation(animation); | 766 | target.Animator.RemoveAnimation(animation); |
@@ -1531,6 +1529,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1531 | 1529 | ||
1532 | if (!UUID.TryParse(name, out assetID)) | 1530 | if (!UUID.TryParse(name, out assetID)) |
1533 | { | 1531 | { |
1532 | m_host.TaskInventory.LockItemsForRead(true); | ||
1534 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1533 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1535 | { | 1534 | { |
1536 | if (item.Type == 7 && item.Name == name) | 1535 | if (item.Type == 7 && item.Name == name) |
@@ -1538,6 +1537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1538 | assetID = item.AssetID; | 1537 | assetID = item.AssetID; |
1539 | } | 1538 | } |
1540 | } | 1539 | } |
1540 | m_host.TaskInventory.LockItemsForRead(false); | ||
1541 | } | 1541 | } |
1542 | 1542 | ||
1543 | if (assetID == UUID.Zero) | 1543 | if (assetID == UUID.Zero) |
@@ -1584,6 +1584,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1584 | 1584 | ||
1585 | if (!UUID.TryParse(name, out assetID)) | 1585 | if (!UUID.TryParse(name, out assetID)) |
1586 | { | 1586 | { |
1587 | m_host.TaskInventory.LockItemsForRead(true); | ||
1587 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1588 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1588 | { | 1589 | { |
1589 | if (item.Type == 7 && item.Name == name) | 1590 | if (item.Type == 7 && item.Name == name) |
@@ -1591,6 +1592,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1591 | assetID = item.AssetID; | 1592 | assetID = item.AssetID; |
1592 | } | 1593 | } |
1593 | } | 1594 | } |
1595 | m_host.TaskInventory.LockItemsForRead(false); | ||
1594 | } | 1596 | } |
1595 | 1597 | ||
1596 | if (assetID == UUID.Zero) | 1598 | if (assetID == UUID.Zero) |
@@ -1641,6 +1643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1641 | 1643 | ||
1642 | if (!UUID.TryParse(name, out assetID)) | 1644 | if (!UUID.TryParse(name, out assetID)) |
1643 | { | 1645 | { |
1646 | m_host.TaskInventory.LockItemsForRead(true); | ||
1644 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1647 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1645 | { | 1648 | { |
1646 | if (item.Type == 7 && item.Name == name) | 1649 | if (item.Type == 7 && item.Name == name) |
@@ -1648,6 +1651,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1648 | assetID = item.AssetID; | 1651 | assetID = item.AssetID; |
1649 | } | 1652 | } |
1650 | } | 1653 | } |
1654 | m_host.TaskInventory.LockItemsForRead(false); | ||
1651 | } | 1655 | } |
1652 | 1656 | ||
1653 | if (assetID == UUID.Zero) | 1657 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ef990a1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,21 @@ | |||
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..522c020 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
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 | public const int WL_SUN_MOON_POSITION = 36; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..5bc3a88 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
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; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 98e77c0..35d57d8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -102,6 +103,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
102 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 103 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
103 | new Dictionary<UUID, IScriptInstance>(); | 104 | new Dictionary<UUID, IScriptInstance>(); |
104 | 105 | ||
106 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
107 | |||
105 | // Maps the asset ID to the assembly | 108 | // Maps the asset ID to the assembly |
106 | 109 | ||
107 | private Dictionary<UUID, string> m_Assemblies = | 110 | private Dictionary<UUID, string> m_Assemblies = |
@@ -123,6 +126,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
123 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); | 126 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
124 | IWorkItemResult m_CurrentCompile = null; | 127 | IWorkItemResult m_CurrentCompile = null; |
125 | 128 | ||
129 | private void lockScriptsForRead(bool locked) | ||
130 | { | ||
131 | if (locked) | ||
132 | { | ||
133 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
134 | { | ||
135 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
136 | m_scriptsLock.ExitReadLock(); | ||
137 | } | ||
138 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
139 | { | ||
140 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
141 | m_scriptsLock.ExitWriteLock(); | ||
142 | } | ||
143 | |||
144 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
145 | { | ||
146 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire READ lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
147 | if (m_scriptsLock.IsWriteLockHeld) | ||
148 | { | ||
149 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
156 | { | ||
157 | m_scriptsLock.ExitReadLock(); | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | private void lockScriptsForWrite(bool locked) | ||
162 | { | ||
163 | if (locked) | ||
164 | { | ||
165 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
166 | { | ||
167 | m_log.Error("[XEngine.m_Scripts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
168 | m_scriptsLock.ExitReadLock(); | ||
169 | } | ||
170 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
171 | { | ||
172 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
173 | m_scriptsLock.ExitWriteLock(); | ||
174 | } | ||
175 | |||
176 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
177 | { | ||
178 | m_log.Error("[XEngine.m_Scripts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
179 | if (m_scriptsLock.IsWriteLockHeld) | ||
180 | { | ||
181 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
188 | { | ||
189 | m_scriptsLock.ExitWriteLock(); | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | |||
126 | public string ScriptEngineName | 194 | public string ScriptEngineName |
127 | { | 195 | { |
128 | get { return "XEngine"; } | 196 | get { return "XEngine"; } |
@@ -262,43 +330,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
262 | 330 | ||
263 | public void RemoveRegion(Scene scene) | 331 | public void RemoveRegion(Scene scene) |
264 | { | 332 | { |
265 | lock (m_Scripts) | 333 | lockScriptsForRead(true); |
334 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
266 | { | 335 | { |
267 | foreach (IScriptInstance instance in m_Scripts.Values) | 336 | // Force a final state save |
337 | // | ||
338 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
268 | { | 339 | { |
269 | // Force a final state save | 340 | string assembly = m_Assemblies[instance.AssetID]; |
270 | // | 341 | instance.SaveState(assembly); |
271 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 342 | } |
272 | { | ||
273 | string assembly = m_Assemblies[instance.AssetID]; | ||
274 | instance.SaveState(assembly); | ||
275 | } | ||
276 | 343 | ||
277 | // Clear the event queue and abort the instance thread | 344 | // Clear the event queue and abort the instance thread |
278 | // | 345 | // |
279 | instance.ClearQueue(); | 346 | instance.ClearQueue(); |
280 | instance.Stop(0); | 347 | instance.Stop(0); |
281 | 348 | ||
282 | // Release events, timer, etc | 349 | // Release events, timer, etc |
283 | // | 350 | // |
284 | instance.DestroyScriptInstance(); | 351 | instance.DestroyScriptInstance(); |
285 | 352 | ||
286 | // Unload scripts and app domains | 353 | // Unload scripts and app domains |
287 | // Must be done explicitly because they have infinite | 354 | // Must be done explicitly because they have infinite |
288 | // lifetime | 355 | // lifetime |
289 | // | 356 | // |
290 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 357 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
291 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 358 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
292 | { | 359 | { |
293 | m_DomainScripts.Remove(instance.AppDomain); | 360 | m_DomainScripts.Remove(instance.AppDomain); |
294 | UnloadAppDomain(instance.AppDomain); | 361 | UnloadAppDomain(instance.AppDomain); |
295 | } | ||
296 | } | 362 | } |
297 | m_Scripts.Clear(); | ||
298 | m_PrimObjects.Clear(); | ||
299 | m_Assemblies.Clear(); | ||
300 | m_DomainScripts.Clear(); | ||
301 | } | 363 | } |
364 | lockScriptsForRead(false); | ||
365 | lockScriptsForWrite(true); | ||
366 | m_Scripts.Clear(); | ||
367 | lockScriptsForWrite(false); | ||
368 | m_PrimObjects.Clear(); | ||
369 | m_Assemblies.Clear(); | ||
370 | m_DomainScripts.Clear(); | ||
371 | |||
302 | lock (m_ScriptEngines) | 372 | lock (m_ScriptEngines) |
303 | { | 373 | { |
304 | m_ScriptEngines.Remove(this); | 374 | m_ScriptEngines.Remove(this); |
@@ -357,22 +427,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
357 | 427 | ||
358 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 428 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
359 | 429 | ||
360 | lock (m_Scripts) | 430 | lockScriptsForRead(true); |
361 | { | 431 | foreach (IScriptInstance instance in m_Scripts.Values) |
362 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
363 | instances.Add(instance); | 432 | instances.Add(instance); |
364 | } | 433 | lockScriptsForRead(false); |
365 | 434 | ||
366 | foreach (IScriptInstance i in instances) | 435 | foreach (IScriptInstance i in instances) |
367 | { | 436 | { |
368 | string assembly = String.Empty; | 437 | string assembly = String.Empty; |
369 | 438 | ||
370 | lock (m_Scripts) | 439 | |
371 | { | ||
372 | if (!m_Assemblies.ContainsKey(i.AssetID)) | 440 | if (!m_Assemblies.ContainsKey(i.AssetID)) |
373 | continue; | 441 | continue; |
374 | assembly = m_Assemblies[i.AssetID]; | 442 | assembly = m_Assemblies[i.AssetID]; |
375 | } | 443 | |
376 | 444 | ||
377 | i.SaveState(assembly); | 445 | i.SaveState(assembly); |
378 | } | 446 | } |
@@ -684,170 +752,181 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
684 | } | 752 | } |
685 | } | 753 | } |
686 | 754 | ||
687 | lock (m_Scripts) | 755 | |
756 | |||
757 | ScriptInstance instance = null; | ||
758 | // Create the object record | ||
759 | lockScriptsForRead(true); | ||
760 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
761 | (m_Scripts[itemID].AssetID != assetID)) | ||
688 | { | 762 | { |
689 | ScriptInstance instance = null; | 763 | lockScriptsForRead(false); |
690 | // Create the object record | ||
691 | 764 | ||
692 | if ((!m_Scripts.ContainsKey(itemID)) || | 765 | UUID appDomain = assetID; |
693 | (m_Scripts[itemID].AssetID != assetID)) | ||
694 | { | ||
695 | UUID appDomain = assetID; | ||
696 | 766 | ||
697 | if (part.ParentGroup.IsAttachment) | 767 | if (part.ParentGroup.IsAttachment) |
698 | appDomain = part.ParentGroup.RootPart.UUID; | 768 | appDomain = part.ParentGroup.RootPart.UUID; |
699 | 769 | ||
700 | if (!m_AppDomains.ContainsKey(appDomain)) | 770 | if (!m_AppDomains.ContainsKey(appDomain)) |
771 | { | ||
772 | try | ||
701 | { | 773 | { |
702 | try | 774 | AppDomainSetup appSetup = new AppDomainSetup(); |
703 | { | 775 | // appSetup.ApplicationBase = Path.Combine( |
704 | AppDomainSetup appSetup = new AppDomainSetup(); | 776 | // "ScriptEngines", |
705 | // appSetup.ApplicationBase = Path.Combine( | 777 | // m_Scene.RegionInfo.RegionID.ToString()); |
706 | // "ScriptEngines", | 778 | |
707 | // m_Scene.RegionInfo.RegionID.ToString()); | 779 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
708 | 780 | Evidence evidence = new Evidence(baseEvidence); | |
709 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 781 | |
710 | Evidence evidence = new Evidence(baseEvidence); | 782 | AppDomain sandbox; |
711 | 783 | if (m_AppDomainLoading) | |
712 | AppDomain sandbox; | 784 | sandbox = AppDomain.CreateDomain( |
713 | if (m_AppDomainLoading) | 785 | m_Scene.RegionInfo.RegionID.ToString(), |
714 | sandbox = AppDomain.CreateDomain( | 786 | evidence, appSetup); |
715 | m_Scene.RegionInfo.RegionID.ToString(), | 787 | else |
716 | evidence, appSetup); | 788 | sandbox = AppDomain.CurrentDomain; |
717 | else | 789 | |
718 | sandbox = AppDomain.CurrentDomain; | 790 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
719 | 791 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | |
720 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 792 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
721 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 793 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
722 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 794 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
723 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 795 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; |
724 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 796 | //sandbox.SetAppDomainPolicy(sandboxPolicy); |
725 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 797 | |
726 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | 798 | m_AppDomains[appDomain] = sandbox; |
727 | 799 | ||
728 | m_AppDomains[appDomain] = sandbox; | 800 | m_AppDomains[appDomain].AssemblyResolve += |
729 | 801 | new ResolveEventHandler( | |
730 | m_AppDomains[appDomain].AssemblyResolve += | 802 | AssemblyResolver.OnAssemblyResolve); |
731 | new ResolveEventHandler( | 803 | m_DomainScripts[appDomain] = new List<UUID>(); |
732 | AssemblyResolver.OnAssemblyResolve); | ||
733 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
734 | } | ||
735 | catch (Exception e) | ||
736 | { | ||
737 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | ||
738 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
739 | m_ScriptFailCount++; | ||
740 | lock (m_AddingAssemblies) | ||
741 | { | ||
742 | m_AddingAssemblies[assembly]--; | ||
743 | } | ||
744 | return false; | ||
745 | } | ||
746 | } | 804 | } |
747 | m_DomainScripts[appDomain].Add(itemID); | 805 | catch (Exception e) |
748 | |||
749 | instance = new ScriptInstance(this, part, | ||
750 | itemID, assetID, assembly, | ||
751 | m_AppDomains[appDomain], | ||
752 | part.ParentGroup.RootPart.Name, | ||
753 | item.Name, startParam, postOnRez, | ||
754 | stateSource, m_MaxScriptQueue); | ||
755 | |||
756 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", | ||
757 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); | ||
758 | |||
759 | if (presence != null) | ||
760 | { | 806 | { |
761 | ShowScriptSaveResponse(item.OwnerID, | 807 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
762 | assetID, "Compile successful", true); | 808 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
809 | m_ScriptFailCount++; | ||
810 | lock (m_AddingAssemblies) | ||
811 | { | ||
812 | m_AddingAssemblies[assembly]--; | ||
813 | } | ||
814 | return false; | ||
763 | } | 815 | } |
816 | } | ||
817 | m_DomainScripts[appDomain].Add(itemID); | ||
764 | 818 | ||
765 | instance.AppDomain = appDomain; | 819 | instance = new ScriptInstance(this, part, |
766 | instance.LineMap = linemap; | 820 | itemID, assetID, assembly, |
821 | m_AppDomains[appDomain], | ||
822 | part.ParentGroup.RootPart.Name, | ||
823 | item.Name, startParam, postOnRez, | ||
824 | stateSource, m_MaxScriptQueue); | ||
767 | 825 | ||
768 | m_Scripts[itemID] = instance; | 826 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", |
769 | } | 827 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); |
770 | 828 | ||
771 | lock (m_PrimObjects) | 829 | if (presence != null) |
772 | { | 830 | { |
773 | if (!m_PrimObjects.ContainsKey(localID)) | 831 | ShowScriptSaveResponse(item.OwnerID, |
774 | m_PrimObjects[localID] = new List<UUID>(); | 832 | assetID, "Compile successful", true); |
833 | } | ||
775 | 834 | ||
776 | if (!m_PrimObjects[localID].Contains(itemID)) | 835 | instance.AppDomain = appDomain; |
777 | m_PrimObjects[localID].Add(itemID); | 836 | instance.LineMap = linemap; |
837 | lockScriptsForWrite(true); | ||
838 | m_Scripts[itemID] = instance; | ||
839 | lockScriptsForWrite(false); | ||
840 | } | ||
841 | else | ||
842 | { | ||
843 | lockScriptsForRead(false); | ||
844 | } | ||
845 | lock (m_PrimObjects) | ||
846 | { | ||
847 | if (!m_PrimObjects.ContainsKey(localID)) | ||
848 | m_PrimObjects[localID] = new List<UUID>(); | ||
778 | 849 | ||
779 | } | 850 | if (!m_PrimObjects[localID].Contains(itemID)) |
851 | m_PrimObjects[localID].Add(itemID); | ||
780 | 852 | ||
781 | if (!m_Assemblies.ContainsKey(assetID)) | 853 | } |
782 | m_Assemblies[assetID] = assembly; | ||
783 | 854 | ||
784 | lock (m_AddingAssemblies) | 855 | if (!m_Assemblies.ContainsKey(assetID)) |
785 | { | 856 | m_Assemblies[assetID] = assembly; |
786 | m_AddingAssemblies[assembly]--; | ||
787 | } | ||
788 | 857 | ||
789 | if (instance!=null) | 858 | lock (m_AddingAssemblies) |
790 | instance.Init(); | 859 | { |
860 | m_AddingAssemblies[assembly]--; | ||
791 | } | 861 | } |
862 | |||
863 | if (instance!=null) | ||
864 | instance.Init(); | ||
865 | |||
792 | return true; | 866 | return true; |
793 | } | 867 | } |
794 | 868 | ||
795 | public void OnRemoveScript(uint localID, UUID itemID) | 869 | public void OnRemoveScript(uint localID, UUID itemID) |
796 | { | 870 | { |
797 | lock (m_Scripts) | 871 | lockScriptsForRead(true); |
872 | // Do we even have it? | ||
873 | if (!m_Scripts.ContainsKey(itemID)) | ||
798 | { | 874 | { |
799 | // Do we even have it? | 875 | lockScriptsForRead(false); |
800 | if (!m_Scripts.ContainsKey(itemID)) | 876 | return; |
801 | return; | 877 | } |
802 | 878 | ||
803 | IScriptInstance instance=m_Scripts[itemID]; | ||
804 | m_Scripts.Remove(itemID); | ||
805 | 879 | ||
806 | instance.ClearQueue(); | 880 | IScriptInstance instance=m_Scripts[itemID]; |
807 | instance.Stop(0); | 881 | lockScriptsForRead(false); |
882 | lockScriptsForWrite(true); | ||
883 | m_Scripts.Remove(itemID); | ||
884 | lockScriptsForWrite(false); | ||
885 | instance.ClearQueue(); | ||
886 | instance.Stop(0); | ||
808 | 887 | ||
809 | // bool objectRemoved = false; | 888 | // bool objectRemoved = false; |
810 | 889 | ||
811 | lock (m_PrimObjects) | 890 | lock (m_PrimObjects) |
891 | { | ||
892 | // Remove the script from it's prim | ||
893 | if (m_PrimObjects.ContainsKey(localID)) | ||
812 | { | 894 | { |
813 | // Remove the script from it's prim | 895 | // Remove inventory item record |
814 | if (m_PrimObjects.ContainsKey(localID)) | 896 | if (m_PrimObjects[localID].Contains(itemID)) |
815 | { | 897 | m_PrimObjects[localID].Remove(itemID); |
816 | // Remove inventory item record | ||
817 | if (m_PrimObjects[localID].Contains(itemID)) | ||
818 | m_PrimObjects[localID].Remove(itemID); | ||
819 | 898 | ||
820 | // If there are no more scripts, remove prim | 899 | // If there are no more scripts, remove prim |
821 | if (m_PrimObjects[localID].Count == 0) | 900 | if (m_PrimObjects[localID].Count == 0) |
822 | { | 901 | { |
823 | m_PrimObjects.Remove(localID); | 902 | m_PrimObjects.Remove(localID); |
824 | // objectRemoved = true; | 903 | // objectRemoved = true; |
825 | } | ||
826 | } | 904 | } |
827 | } | 905 | } |
906 | } | ||
828 | 907 | ||
829 | instance.RemoveState(); | 908 | instance.RemoveState(); |
830 | instance.DestroyScriptInstance(); | 909 | instance.DestroyScriptInstance(); |
831 | |||
832 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | ||
833 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
834 | { | ||
835 | m_DomainScripts.Remove(instance.AppDomain); | ||
836 | UnloadAppDomain(instance.AppDomain); | ||
837 | } | ||
838 | 910 | ||
839 | instance = null; | 911 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
912 | if (m_DomainScripts[instance.AppDomain].Count == 0) | ||
913 | { | ||
914 | m_DomainScripts.Remove(instance.AppDomain); | ||
915 | UnloadAppDomain(instance.AppDomain); | ||
916 | } | ||
840 | 917 | ||
841 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 918 | instance = null; |
842 | if (handlerObjectRemoved != null) | ||
843 | { | ||
844 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
845 | handlerObjectRemoved(part.UUID); | ||
846 | } | ||
847 | 919 | ||
848 | CleanAssemblies(); | 920 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
921 | if (handlerObjectRemoved != null) | ||
922 | { | ||
923 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
924 | handlerObjectRemoved(part.UUID); | ||
849 | } | 925 | } |
850 | 926 | ||
927 | CleanAssemblies(); | ||
928 | |||
929 | |||
851 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 930 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
852 | if (handlerScriptRemoved != null) | 931 | if (handlerScriptRemoved != null) |
853 | handlerScriptRemoved(itemID); | 932 | handlerScriptRemoved(itemID); |
@@ -1099,12 +1178,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1099 | private IScriptInstance GetInstance(UUID itemID) | 1178 | private IScriptInstance GetInstance(UUID itemID) |
1100 | { | 1179 | { |
1101 | IScriptInstance instance; | 1180 | IScriptInstance instance; |
1102 | lock (m_Scripts) | 1181 | lockScriptsForRead(true); |
1182 | if (!m_Scripts.ContainsKey(itemID)) | ||
1103 | { | 1183 | { |
1104 | if (!m_Scripts.ContainsKey(itemID)) | 1184 | lockScriptsForRead(false); |
1105 | return null; | 1185 | return null; |
1106 | instance = m_Scripts[itemID]; | ||
1107 | } | 1186 | } |
1187 | instance = m_Scripts[itemID]; | ||
1188 | lockScriptsForRead(false); | ||
1108 | return instance; | 1189 | return instance; |
1109 | } | 1190 | } |
1110 | 1191 | ||
@@ -1128,6 +1209,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1128 | return false; | 1209 | return false; |
1129 | } | 1210 | } |
1130 | 1211 | ||
1212 | [DebuggerNonUserCode] | ||
1131 | public void ApiResetScript(UUID itemID) | 1213 | public void ApiResetScript(UUID itemID) |
1132 | { | 1214 | { |
1133 | IScriptInstance instance = GetInstance(itemID); | 1215 | IScriptInstance instance = GetInstance(itemID); |
@@ -1179,6 +1261,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1179 | return UUID.Zero; | 1261 | return UUID.Zero; |
1180 | } | 1262 | } |
1181 | 1263 | ||
1264 | [DebuggerNonUserCode] | ||
1182 | public void SetState(UUID itemID, string newState) | 1265 | public void SetState(UUID itemID, string newState) |
1183 | { | 1266 | { |
1184 | IScriptInstance instance = GetInstance(itemID); | 1267 | IScriptInstance instance = GetInstance(itemID); |
@@ -1199,11 +1282,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1199 | { | 1282 | { |
1200 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1283 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1201 | 1284 | ||
1202 | lock (m_Scripts) | 1285 | lockScriptsForRead(true); |
1203 | { | 1286 | foreach (IScriptInstance instance in m_Scripts.Values) |
1204 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1205 | instances.Add(instance); | 1287 | instances.Add(instance); |
1206 | } | 1288 | lockScriptsForRead(false); |
1207 | 1289 | ||
1208 | foreach (IScriptInstance i in instances) | 1290 | foreach (IScriptInstance i in instances) |
1209 | { | 1291 | { |