diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
13 files changed, 1393 insertions, 552 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..d4250c1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,473 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using System.Collections; | ||
4 | using System.Collections.Generic; | ||
5 | using System.Runtime.Remoting.Lifetime; | ||
6 | using OpenMetaverse; | ||
7 | using Nini.Config; | ||
8 | using OpenSim; | ||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Region.CoreModules.World.Meta7Windlight; | ||
11 | using OpenSim.Region.Framework.Interfaces; | ||
12 | using OpenSim.Region.Framework.Scenes; | ||
13 | using OpenSim.Region.ScriptEngine.Shared; | ||
14 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
15 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
16 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
17 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
18 | |||
19 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
20 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
21 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
22 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
23 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
24 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
25 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
26 | |||
27 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
28 | { | ||
29 | [Serializable] | ||
30 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
31 | { | ||
32 | internal IScriptEngine m_ScriptEngine; | ||
33 | internal SceneObjectPart m_host; | ||
34 | internal uint m_localID; | ||
35 | internal UUID m_itemID; | ||
36 | internal bool m_CMFunctionsEnabled = false; | ||
37 | internal IScriptModuleComms m_comms = null; | ||
38 | |||
39 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
40 | { | ||
41 | m_ScriptEngine = ScriptEngine; | ||
42 | m_host = host; | ||
43 | m_localID = localID; | ||
44 | m_itemID = itemID; | ||
45 | |||
46 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
47 | m_CMFunctionsEnabled = true; | ||
48 | |||
49 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
50 | if (m_comms == null) | ||
51 | m_CMFunctionsEnabled = false; | ||
52 | } | ||
53 | |||
54 | public override Object InitializeLifetimeService() | ||
55 | { | ||
56 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
57 | |||
58 | if (lease.CurrentState == LeaseState.Initial) | ||
59 | { | ||
60 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
61 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
62 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
63 | } | ||
64 | return lease; | ||
65 | } | ||
66 | |||
67 | public Scene World | ||
68 | { | ||
69 | get { return m_ScriptEngine.World; } | ||
70 | } | ||
71 | |||
72 | // | ||
73 | //Dumps an error message on the debug console. | ||
74 | // | ||
75 | |||
76 | internal void CMShoutError(string message) | ||
77 | { | ||
78 | if (message.Length > 1023) | ||
79 | message = message.Substring(0, 1023); | ||
80 | |||
81 | World.SimChat(Utils.StringToBytes(message), | ||
82 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
83 | |||
84 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
85 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// Get the current Windlight scene | ||
90 | /// </summary> | ||
91 | /// <returns>List of windlight parameters</returns> | ||
92 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
93 | { | ||
94 | if (!m_CMFunctionsEnabled) | ||
95 | { | ||
96 | CMShoutError("Careminster functions are not enabled."); | ||
97 | return new LSL_List(); | ||
98 | } | ||
99 | m_host.AddScriptLPS(1); | ||
100 | RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
101 | |||
102 | LSL_List values = new LSL_List(); | ||
103 | int idx = 0; | ||
104 | while (idx < rules.Length) | ||
105 | { | ||
106 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
107 | LSL_List toadd = new LSL_List(); | ||
108 | |||
109 | switch (rule) | ||
110 | { | ||
111 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
112 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
113 | break; | ||
114 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
115 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
116 | break; | ||
117 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
118 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
119 | break; | ||
120 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
121 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
122 | break; | ||
123 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
124 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
125 | break; | ||
126 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
127 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
128 | break; | ||
129 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
130 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
131 | break; | ||
132 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
133 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
134 | break; | ||
135 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
136 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
137 | break; | ||
138 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
139 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
140 | break; | ||
141 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
142 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
143 | break; | ||
144 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
145 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
146 | break; | ||
147 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
148 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
149 | break; | ||
150 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
151 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
152 | break; | ||
153 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
154 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
155 | break; | ||
156 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
157 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
158 | break; | ||
159 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
160 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
161 | break; | ||
162 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
163 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
164 | break; | ||
165 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
166 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
167 | break; | ||
168 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
169 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
170 | break; | ||
171 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
172 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
173 | break; | ||
174 | case (int)ScriptBaseClass.WL_HORIZON: | ||
175 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
176 | break; | ||
177 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
178 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
179 | break; | ||
180 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
181 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
182 | break; | ||
183 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
184 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
185 | break; | ||
186 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
187 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
188 | break; | ||
189 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
190 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
191 | break; | ||
192 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
193 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
194 | break; | ||
195 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
196 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
197 | break; | ||
198 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
199 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
200 | break; | ||
201 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
202 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
203 | break; | ||
204 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
205 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
206 | break; | ||
207 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
208 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
209 | break; | ||
210 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
211 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
212 | break; | ||
213 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
214 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
215 | break; | ||
216 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
217 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
218 | break; | ||
219 | } | ||
220 | |||
221 | if (toadd.Length > 0) | ||
222 | { | ||
223 | values.Add(rule); | ||
224 | values.Add(toadd.Data[0]); | ||
225 | } | ||
226 | idx++; | ||
227 | } | ||
228 | |||
229 | |||
230 | return values; | ||
231 | |||
232 | } | ||
233 | |||
234 | private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) | ||
235 | { | ||
236 | RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
237 | |||
238 | LSL_List values = new LSL_List(); | ||
239 | int idx = 0; | ||
240 | while (idx < rules.Length) | ||
241 | { | ||
242 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
243 | LSL_Types.Quaternion iQ; | ||
244 | LSL_Types.Vector3 iV; | ||
245 | switch (rule) | ||
246 | { | ||
247 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
248 | idx++; | ||
249 | iQ = rules.GetQuaternionItem(idx); | ||
250 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
251 | break; | ||
252 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
253 | idx++; | ||
254 | iV = rules.GetVector3Item(idx); | ||
255 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
256 | break; | ||
257 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
258 | idx++; | ||
259 | iQ = rules.GetQuaternionItem(idx); | ||
260 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
261 | break; | ||
262 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
263 | idx++; | ||
264 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
265 | break; | ||
266 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
267 | idx++; | ||
268 | iQ = rules.GetQuaternionItem(idx); | ||
269 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
270 | break; | ||
271 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
272 | idx++; | ||
273 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
274 | break; | ||
275 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
276 | idx++; | ||
277 | iV = rules.GetVector3Item(idx); | ||
278 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
279 | break; | ||
280 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
281 | idx++; | ||
282 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
283 | break; | ||
284 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
285 | idx++; | ||
286 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
289 | idx++; | ||
290 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
291 | break; | ||
292 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
293 | idx++; | ||
294 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
295 | break; | ||
296 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
297 | idx++; | ||
298 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
299 | break; | ||
300 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
301 | idx++; | ||
302 | iV = rules.GetVector3Item(idx); | ||
303 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
304 | break; | ||
305 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
306 | idx++; | ||
307 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
308 | break; | ||
309 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
310 | idx++; | ||
311 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
312 | break; | ||
313 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
314 | idx++; | ||
315 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
316 | break; | ||
317 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
318 | idx++; | ||
319 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
320 | break; | ||
321 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
322 | idx++; | ||
323 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
324 | break; | ||
325 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
326 | idx++; | ||
327 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
328 | break; | ||
329 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
330 | idx++; | ||
331 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
332 | break; | ||
333 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
334 | idx++; | ||
335 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
336 | break; | ||
337 | case (int)ScriptBaseClass.WL_HORIZON: | ||
338 | idx++; | ||
339 | iQ = rules.GetQuaternionItem(idx); | ||
340 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
341 | break; | ||
342 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
343 | idx++; | ||
344 | iV = rules.GetVector3Item(idx); | ||
345 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
346 | break; | ||
347 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
348 | idx++; | ||
349 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
350 | break; | ||
351 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
352 | idx++; | ||
353 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
354 | break; | ||
355 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
356 | idx++; | ||
357 | iV = rules.GetVector3Item(idx); | ||
358 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
359 | break; | ||
360 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
361 | idx++; | ||
362 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
365 | idx++; | ||
366 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
369 | idx++; | ||
370 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
371 | break; | ||
372 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
373 | idx++; | ||
374 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
375 | break; | ||
376 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
377 | idx++; | ||
378 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
379 | break; | ||
380 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
381 | idx++; | ||
382 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
383 | break; | ||
384 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
385 | idx++; | ||
386 | iQ = rules.GetQuaternionItem(idx); | ||
387 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
388 | break; | ||
389 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
390 | idx++; | ||
391 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
392 | break; | ||
393 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
394 | idx++; | ||
395 | iV = rules.GetVector3Item(idx); | ||
396 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
397 | break; | ||
398 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
399 | idx++; | ||
400 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
401 | break; | ||
402 | } | ||
403 | idx++; | ||
404 | } | ||
405 | return wl; | ||
406 | } | ||
407 | /// <summary> | ||
408 | /// Set the current Windlight scene | ||
409 | /// </summary> | ||
410 | /// <param name="rules"></param> | ||
411 | /// <returns>success: true or false</returns> | ||
412 | public int cmSetWindlightScene(LSL_List rules) | ||
413 | { | ||
414 | if (!m_CMFunctionsEnabled) | ||
415 | { | ||
416 | CMShoutError("Careminster functions are not enabled."); | ||
417 | return 0; | ||
418 | } | ||
419 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
420 | { | ||
421 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
422 | return 0; | ||
423 | } | ||
424 | int success = 0; | ||
425 | m_host.AddScriptLPS(1); | ||
426 | if (Meta7WindlightModule.EnableWindlight) | ||
427 | { | ||
428 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
429 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
430 | success = 1; | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | CMShoutError("Windlight module is disabled"); | ||
435 | return 0; | ||
436 | } | ||
437 | return success; | ||
438 | } | ||
439 | /// <summary> | ||
440 | /// Set the current Windlight scene to a target avatar | ||
441 | /// </summary> | ||
442 | /// <param name="rules"></param> | ||
443 | /// <returns>success: true or false</returns> | ||
444 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
445 | { | ||
446 | if (!m_CMFunctionsEnabled) | ||
447 | { | ||
448 | CMShoutError("Careminster functions are not enabled."); | ||
449 | return 0; | ||
450 | } | ||
451 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
452 | { | ||
453 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
454 | return 0; | ||
455 | } | ||
456 | int success = 0; | ||
457 | m_host.AddScriptLPS(1); | ||
458 | if (Meta7WindlightModule.EnableWindlight) | ||
459 | { | ||
460 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
461 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
462 | success = 1; | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | CMShoutError("Windlight module is disabled"); | ||
467 | return 0; | ||
468 | } | ||
469 | return success; | ||
470 | } | ||
471 | |||
472 | } | ||
473 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 79b2391..c3edaef 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); |
@@ -272,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 275 | protected UUID InventorySelf() |
273 | { | 276 | { |
274 | UUID invItemID = new UUID(); | 277 | UUID invItemID = new UUID(); |
275 | 278 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 279 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
280 | { | ||
281 | m_host.TaskInventory.LockItemsForRead(true); | ||
282 | unlock = true; | ||
283 | } | ||
284 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
277 | { | 285 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 286 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) |
279 | { | 287 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 288 | invItemID = inv.Key; |
281 | { | 289 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 290 | } |
286 | } | 291 | } |
287 | 292 | if (unlock) | |
293 | { | ||
294 | m_host.TaskInventory.LockItemsForRead(false); | ||
295 | } | ||
288 | return invItemID; | 296 | return invItemID; |
289 | } | 297 | } |
290 | 298 | ||
291 | protected UUID InventoryKey(string name, int type) | 299 | protected UUID InventoryKey(string name, int type) |
292 | { | 300 | { |
293 | m_host.AddScriptLPS(1); | 301 | m_host.AddScriptLPS(1); |
294 | 302 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 303 | |
304 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 305 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 306 | if (inv.Value.Name == name) |
298 | { | 307 | { |
299 | if (inv.Value.Name == name) | 308 | m_host.TaskInventory.LockItemsForRead(false); |
309 | |||
310 | if (inv.Value.Type != type) | ||
300 | { | 311 | { |
301 | if (inv.Value.Type != type) | 312 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 313 | } |
314 | |||
315 | return inv.Value.AssetID; | ||
306 | } | 316 | } |
307 | } | 317 | } |
308 | 318 | ||
319 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 320 | return UUID.Zero; |
310 | } | 321 | } |
311 | 322 | ||
@@ -313,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 324 | { |
314 | m_host.AddScriptLPS(1); | 325 | m_host.AddScriptLPS(1); |
315 | 326 | ||
316 | lock (m_host.TaskInventory) | 327 | |
328 | m_host.TaskInventory.LockItemsForRead(true); | ||
329 | |||
330 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 331 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 332 | if (inv.Value.Name == name) |
319 | { | 333 | { |
320 | if (inv.Value.Name == name) | 334 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 335 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 336 | } |
325 | } | 337 | } |
326 | 338 | ||
339 | m_host.TaskInventory.LockItemsForRead(false); | ||
340 | |||
341 | |||
327 | return UUID.Zero; | 342 | return UUID.Zero; |
328 | } | 343 | } |
329 | 344 | ||
@@ -2555,12 +2570,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2570 | ||
2556 | m_host.AddScriptLPS(1); | 2571 | m_host.AddScriptLPS(1); |
2557 | 2572 | ||
2573 | m_host.TaskInventory.LockItemsForRead(true); | ||
2558 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2574 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2559 | 2575 | m_host.TaskInventory.LockItemsForRead(false); | |
2560 | lock (m_host.TaskInventory) | ||
2561 | { | ||
2562 | item = m_host.TaskInventory[invItemID]; | ||
2563 | } | ||
2564 | 2576 | ||
2565 | if (item.PermsGranter == UUID.Zero) | 2577 | if (item.PermsGranter == UUID.Zero) |
2566 | return 0; | 2578 | return 0; |
@@ -2635,6 +2647,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2635 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2647 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2636 | return; | 2648 | return; |
2637 | 2649 | ||
2650 | //Clone is thread-safe | ||
2638 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2651 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2639 | 2652 | ||
2640 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2653 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2720,11 +2733,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2720 | // Orient the object to the angle calculated | 2733 | // Orient the object to the angle calculated |
2721 | llSetRot(rot); | 2734 | llSetRot(rot); |
2722 | } | 2735 | } |
2736 | |||
2737 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2738 | { | ||
2739 | m_host.AddScriptLPS(1); | ||
2740 | // NotImplemented("llRotLookAt"); | ||
2741 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2742 | |||
2743 | } | ||
2744 | |||
2723 | 2745 | ||
2724 | public void llStopLookAt() | 2746 | public void llStopLookAt() |
2725 | { | 2747 | { |
2726 | m_host.AddScriptLPS(1); | 2748 | m_host.AddScriptLPS(1); |
2727 | NotImplemented("llStopLookAt"); | 2749 | // NotImplemented("llStopLookAt"); |
2750 | m_host.StopLookAt(); | ||
2728 | } | 2751 | } |
2729 | 2752 | ||
2730 | public void llSetTimerEvent(double sec) | 2753 | public void llSetTimerEvent(double sec) |
@@ -2758,13 +2781,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2758 | { | 2781 | { |
2759 | TaskInventoryItem item; | 2782 | TaskInventoryItem item; |
2760 | 2783 | ||
2761 | lock (m_host.TaskInventory) | 2784 | m_host.TaskInventory.LockItemsForRead(true); |
2785 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2762 | { | 2786 | { |
2763 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2787 | m_host.TaskInventory.LockItemsForRead(false); |
2764 | return; | 2788 | return; |
2765 | else | 2789 | } |
2766 | item = m_host.TaskInventory[InventorySelf()]; | 2790 | else |
2791 | { | ||
2792 | item = m_host.TaskInventory[InventorySelf()]; | ||
2767 | } | 2793 | } |
2794 | m_host.TaskInventory.LockItemsForRead(false); | ||
2768 | 2795 | ||
2769 | if (item.PermsGranter != UUID.Zero) | 2796 | if (item.PermsGranter != UUID.Zero) |
2770 | { | 2797 | { |
@@ -2786,13 +2813,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2786 | { | 2813 | { |
2787 | TaskInventoryItem item; | 2814 | TaskInventoryItem item; |
2788 | 2815 | ||
2816 | m_host.TaskInventory.LockItemsForRead(true); | ||
2789 | lock (m_host.TaskInventory) | 2817 | lock (m_host.TaskInventory) |
2790 | { | 2818 | { |
2819 | |||
2791 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2820 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
2821 | { | ||
2822 | m_host.TaskInventory.LockItemsForRead(false); | ||
2792 | return; | 2823 | return; |
2824 | } | ||
2793 | else | 2825 | else |
2826 | { | ||
2794 | item = m_host.TaskInventory[InventorySelf()]; | 2827 | item = m_host.TaskInventory[InventorySelf()]; |
2828 | } | ||
2795 | } | 2829 | } |
2830 | m_host.TaskInventory.LockItemsForRead(false); | ||
2796 | 2831 | ||
2797 | m_host.AddScriptLPS(1); | 2832 | m_host.AddScriptLPS(1); |
2798 | 2833 | ||
@@ -2829,14 +2864,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2829 | 2864 | ||
2830 | TaskInventoryItem item; | 2865 | TaskInventoryItem item; |
2831 | 2866 | ||
2832 | lock (m_host.TaskInventory) | 2867 | m_host.TaskInventory.LockItemsForRead(true); |
2868 | |||
2869 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2833 | { | 2870 | { |
2834 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2871 | m_host.TaskInventory.LockItemsForRead(false); |
2835 | return; | 2872 | return; |
2836 | else | 2873 | } |
2837 | item = m_host.TaskInventory[InventorySelf()]; | 2874 | else |
2875 | { | ||
2876 | item = m_host.TaskInventory[InventorySelf()]; | ||
2838 | } | 2877 | } |
2839 | 2878 | ||
2879 | m_host.TaskInventory.LockItemsForRead(false); | ||
2880 | |||
2840 | if (item.PermsGranter != m_host.OwnerID) | 2881 | if (item.PermsGranter != m_host.OwnerID) |
2841 | return; | 2882 | return; |
2842 | 2883 | ||
@@ -2861,13 +2902,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2861 | 2902 | ||
2862 | TaskInventoryItem item; | 2903 | TaskInventoryItem item; |
2863 | 2904 | ||
2864 | lock (m_host.TaskInventory) | 2905 | m_host.TaskInventory.LockItemsForRead(true); |
2906 | |||
2907 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2865 | { | 2908 | { |
2866 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2909 | m_host.TaskInventory.LockItemsForRead(false); |
2867 | return; | 2910 | return; |
2868 | else | ||
2869 | item = m_host.TaskInventory[InventorySelf()]; | ||
2870 | } | 2911 | } |
2912 | else | ||
2913 | { | ||
2914 | item = m_host.TaskInventory[InventorySelf()]; | ||
2915 | } | ||
2916 | m_host.TaskInventory.LockItemsForRead(false); | ||
2917 | |||
2871 | 2918 | ||
2872 | if (item.PermsGranter != m_host.OwnerID) | 2919 | if (item.PermsGranter != m_host.OwnerID) |
2873 | return; | 2920 | return; |
@@ -2903,8 +2950,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2903 | return m_host.OwnerID.ToString(); | 2950 | return m_host.OwnerID.ToString(); |
2904 | } | 2951 | } |
2905 | 2952 | ||
2953 | [DebuggerNonUserCode] | ||
2906 | public void llInstantMessage(string user, string message) | 2954 | public void llInstantMessage(string user, string message) |
2907 | { | 2955 | { |
2956 | UUID result; | ||
2957 | if (!UUID.TryParse(user, out result)) | ||
2958 | { | ||
2959 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
2960 | return; | ||
2961 | } | ||
2962 | |||
2963 | |||
2908 | m_host.AddScriptLPS(1); | 2964 | m_host.AddScriptLPS(1); |
2909 | 2965 | ||
2910 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 2966 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2919,7 +2975,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2919 | UUID friendTransactionID = UUID.Random(); | 2975 | UUID friendTransactionID = UUID.Random(); |
2920 | 2976 | ||
2921 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 2977 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2922 | 2978 | ||
2923 | GridInstantMessage msg = new GridInstantMessage(); | 2979 | GridInstantMessage msg = new GridInstantMessage(); |
2924 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 2980 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2925 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 2981 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3068,12 +3124,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3068 | m_host.AddScriptLPS(1); | 3124 | m_host.AddScriptLPS(1); |
3069 | } | 3125 | } |
3070 | 3126 | ||
3071 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3072 | { | ||
3073 | m_host.AddScriptLPS(1); | ||
3074 | NotImplemented("llRotLookAt"); | ||
3075 | } | ||
3076 | |||
3077 | public LSL_Integer llStringLength(string str) | 3127 | public LSL_Integer llStringLength(string str) |
3078 | { | 3128 | { |
3079 | m_host.AddScriptLPS(1); | 3129 | m_host.AddScriptLPS(1); |
@@ -3097,14 +3147,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3097 | 3147 | ||
3098 | TaskInventoryItem item; | 3148 | TaskInventoryItem item; |
3099 | 3149 | ||
3100 | lock (m_host.TaskInventory) | 3150 | m_host.TaskInventory.LockItemsForRead(true); |
3151 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3101 | { | 3152 | { |
3102 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3153 | m_host.TaskInventory.LockItemsForRead(false); |
3103 | return; | 3154 | return; |
3104 | else | ||
3105 | item = m_host.TaskInventory[InventorySelf()]; | ||
3106 | } | 3155 | } |
3107 | 3156 | else | |
3157 | { | ||
3158 | item = m_host.TaskInventory[InventorySelf()]; | ||
3159 | } | ||
3160 | m_host.TaskInventory.LockItemsForRead(false); | ||
3108 | if (item.PermsGranter == UUID.Zero) | 3161 | if (item.PermsGranter == UUID.Zero) |
3109 | return; | 3162 | return; |
3110 | 3163 | ||
@@ -3134,13 +3187,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3134 | 3187 | ||
3135 | TaskInventoryItem item; | 3188 | TaskInventoryItem item; |
3136 | 3189 | ||
3137 | lock (m_host.TaskInventory) | 3190 | m_host.TaskInventory.LockItemsForRead(true); |
3191 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3138 | { | 3192 | { |
3139 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3193 | m_host.TaskInventory.LockItemsForRead(false); |
3140 | return; | 3194 | return; |
3141 | else | ||
3142 | item = m_host.TaskInventory[InventorySelf()]; | ||
3143 | } | 3195 | } |
3196 | else | ||
3197 | { | ||
3198 | item = m_host.TaskInventory[InventorySelf()]; | ||
3199 | } | ||
3200 | m_host.TaskInventory.LockItemsForRead(false); | ||
3201 | |||
3144 | 3202 | ||
3145 | if (item.PermsGranter == UUID.Zero) | 3203 | if (item.PermsGranter == UUID.Zero) |
3146 | return; | 3204 | return; |
@@ -3213,10 +3271,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3213 | 3271 | ||
3214 | TaskInventoryItem item; | 3272 | TaskInventoryItem item; |
3215 | 3273 | ||
3216 | lock (m_host.TaskInventory) | 3274 | |
3275 | m_host.TaskInventory.LockItemsForRead(true); | ||
3276 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3277 | { | ||
3278 | m_host.TaskInventory.LockItemsForRead(false); | ||
3279 | return; | ||
3280 | } | ||
3281 | else | ||
3217 | { | 3282 | { |
3218 | item = m_host.TaskInventory[invItemID]; | 3283 | item = m_host.TaskInventory[invItemID]; |
3219 | } | 3284 | } |
3285 | m_host.TaskInventory.LockItemsForRead(false); | ||
3220 | 3286 | ||
3221 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3287 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3222 | { | 3288 | { |
@@ -3248,11 +3314,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3248 | 3314 | ||
3249 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3315 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3250 | { | 3316 | { |
3251 | lock (m_host.TaskInventory) | 3317 | m_host.TaskInventory.LockItemsForWrite(true); |
3252 | { | 3318 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3253 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3319 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3254 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3320 | m_host.TaskInventory.LockItemsForWrite(false); |
3255 | } | ||
3256 | 3321 | ||
3257 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3322 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3258 | "run_time_permissions", new Object[] { | 3323 | "run_time_permissions", new Object[] { |
@@ -3272,11 +3337,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3272 | 3337 | ||
3273 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3338 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3274 | { | 3339 | { |
3275 | lock (m_host.TaskInventory) | 3340 | m_host.TaskInventory.LockItemsForWrite(true); |
3276 | { | 3341 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3277 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3342 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3278 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3343 | m_host.TaskInventory.LockItemsForWrite(false); |
3279 | } | ||
3280 | 3344 | ||
3281 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3345 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3282 | "run_time_permissions", new Object[] { | 3346 | "run_time_permissions", new Object[] { |
@@ -3297,11 +3361,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3297 | 3361 | ||
3298 | if (!m_waitingForScriptAnswer) | 3362 | if (!m_waitingForScriptAnswer) |
3299 | { | 3363 | { |
3300 | lock (m_host.TaskInventory) | 3364 | m_host.TaskInventory.LockItemsForWrite(true); |
3301 | { | 3365 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3302 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3366 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3303 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3367 | m_host.TaskInventory.LockItemsForWrite(false); |
3304 | } | ||
3305 | 3368 | ||
3306 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3369 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3307 | m_waitingForScriptAnswer=true; | 3370 | m_waitingForScriptAnswer=true; |
@@ -3336,10 +3399,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3336 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3399 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3337 | llReleaseControls(); | 3400 | llReleaseControls(); |
3338 | 3401 | ||
3339 | lock (m_host.TaskInventory) | 3402 | |
3340 | { | 3403 | m_host.TaskInventory.LockItemsForWrite(true); |
3341 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3404 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3342 | } | 3405 | m_host.TaskInventory.LockItemsForWrite(false); |
3406 | |||
3343 | 3407 | ||
3344 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3408 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3345 | "run_time_permissions", new Object[] { | 3409 | "run_time_permissions", new Object[] { |
@@ -3351,16 +3415,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3351 | { | 3415 | { |
3352 | m_host.AddScriptLPS(1); | 3416 | m_host.AddScriptLPS(1); |
3353 | 3417 | ||
3354 | lock (m_host.TaskInventory) | 3418 | m_host.TaskInventory.LockItemsForRead(true); |
3419 | |||
3420 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3355 | { | 3421 | { |
3356 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3422 | if (item.Type == 10 && item.ItemID == m_itemID) |
3357 | { | 3423 | { |
3358 | if (item.Type == 10 && item.ItemID == m_itemID) | 3424 | m_host.TaskInventory.LockItemsForRead(false); |
3359 | { | 3425 | return item.PermsGranter.ToString(); |
3360 | return item.PermsGranter.ToString(); | ||
3361 | } | ||
3362 | } | 3426 | } |
3363 | } | 3427 | } |
3428 | m_host.TaskInventory.LockItemsForRead(false); | ||
3364 | 3429 | ||
3365 | return UUID.Zero.ToString(); | 3430 | return UUID.Zero.ToString(); |
3366 | } | 3431 | } |
@@ -3369,19 +3434,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3369 | { | 3434 | { |
3370 | m_host.AddScriptLPS(1); | 3435 | m_host.AddScriptLPS(1); |
3371 | 3436 | ||
3372 | lock (m_host.TaskInventory) | 3437 | m_host.TaskInventory.LockItemsForRead(true); |
3438 | |||
3439 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3373 | { | 3440 | { |
3374 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3441 | if (item.Type == 10 && item.ItemID == m_itemID) |
3375 | { | 3442 | { |
3376 | if (item.Type == 10 && item.ItemID == m_itemID) | 3443 | int perms = item.PermsMask; |
3377 | { | 3444 | if (m_automaticLinkPermission) |
3378 | int perms = item.PermsMask; | 3445 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3379 | if (m_automaticLinkPermission) | 3446 | m_host.TaskInventory.LockItemsForRead(false); |
3380 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3447 | return perms; |
3381 | return perms; | ||
3382 | } | ||
3383 | } | 3448 | } |
3384 | } | 3449 | } |
3450 | m_host.TaskInventory.LockItemsForRead(false); | ||
3385 | 3451 | ||
3386 | return 0; | 3452 | return 0; |
3387 | } | 3453 | } |
@@ -3414,11 +3480,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3414 | UUID invItemID = InventorySelf(); | 3480 | UUID invItemID = InventorySelf(); |
3415 | 3481 | ||
3416 | TaskInventoryItem item; | 3482 | TaskInventoryItem item; |
3417 | lock (m_host.TaskInventory) | 3483 | m_host.TaskInventory.LockItemsForRead(true); |
3418 | { | 3484 | item = m_host.TaskInventory[invItemID]; |
3419 | item = m_host.TaskInventory[invItemID]; | 3485 | m_host.TaskInventory.LockItemsForRead(false); |
3420 | } | 3486 | |
3421 | |||
3422 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3487 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3423 | && !m_automaticLinkPermission) | 3488 | && !m_automaticLinkPermission) |
3424 | { | 3489 | { |
@@ -3471,16 +3536,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3471 | m_host.AddScriptLPS(1); | 3536 | m_host.AddScriptLPS(1); |
3472 | UUID invItemID = InventorySelf(); | 3537 | UUID invItemID = InventorySelf(); |
3473 | 3538 | ||
3474 | lock (m_host.TaskInventory) | 3539 | m_host.TaskInventory.LockItemsForRead(true); |
3475 | { | ||
3476 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3540 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3477 | && !m_automaticLinkPermission) | 3541 | && !m_automaticLinkPermission) |
3478 | { | 3542 | { |
3479 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3543 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3544 | m_host.TaskInventory.LockItemsForRead(false); | ||
3480 | return; | 3545 | return; |
3481 | } | 3546 | } |
3482 | } | 3547 | m_host.TaskInventory.LockItemsForRead(false); |
3483 | 3548 | ||
3484 | if (linknum < ScriptBaseClass.LINK_THIS) | 3549 | if (linknum < ScriptBaseClass.LINK_THIS) |
3485 | return; | 3550 | return; |
3486 | 3551 | ||
@@ -3657,17 +3722,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3657 | m_host.AddScriptLPS(1); | 3722 | m_host.AddScriptLPS(1); |
3658 | int count = 0; | 3723 | int count = 0; |
3659 | 3724 | ||
3660 | lock (m_host.TaskInventory) | 3725 | m_host.TaskInventory.LockItemsForRead(true); |
3726 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3661 | { | 3727 | { |
3662 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3728 | if (inv.Value.Type == type || type == -1) |
3663 | { | 3729 | { |
3664 | if (inv.Value.Type == type || type == -1) | 3730 | count = count + 1; |
3665 | { | ||
3666 | count = count + 1; | ||
3667 | } | ||
3668 | } | 3731 | } |
3669 | } | 3732 | } |
3670 | 3733 | ||
3734 | m_host.TaskInventory.LockItemsForRead(false); | ||
3671 | return count; | 3735 | return count; |
3672 | } | 3736 | } |
3673 | 3737 | ||
@@ -3676,16 +3740,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3676 | m_host.AddScriptLPS(1); | 3740 | m_host.AddScriptLPS(1); |
3677 | ArrayList keys = new ArrayList(); | 3741 | ArrayList keys = new ArrayList(); |
3678 | 3742 | ||
3679 | lock (m_host.TaskInventory) | 3743 | m_host.TaskInventory.LockItemsForRead(true); |
3744 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3680 | { | 3745 | { |
3681 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3746 | if (inv.Value.Type == type || type == -1) |
3682 | { | 3747 | { |
3683 | if (inv.Value.Type == type || type == -1) | 3748 | keys.Add(inv.Value.Name); |
3684 | { | ||
3685 | keys.Add(inv.Value.Name); | ||
3686 | } | ||
3687 | } | 3749 | } |
3688 | } | 3750 | } |
3751 | m_host.TaskInventory.LockItemsForRead(false); | ||
3689 | 3752 | ||
3690 | if (keys.Count == 0) | 3753 | if (keys.Count == 0) |
3691 | { | 3754 | { |
@@ -3722,20 +3785,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3722 | } | 3785 | } |
3723 | 3786 | ||
3724 | // move the first object found with this inventory name | 3787 | // move the first object found with this inventory name |
3725 | lock (m_host.TaskInventory) | 3788 | m_host.TaskInventory.LockItemsForRead(true); |
3789 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3726 | { | 3790 | { |
3727 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3791 | if (inv.Value.Name == inventory) |
3728 | { | 3792 | { |
3729 | if (inv.Value.Name == inventory) | 3793 | found = true; |
3730 | { | 3794 | objId = inv.Key; |
3731 | found = true; | 3795 | assetType = inv.Value.Type; |
3732 | objId = inv.Key; | 3796 | objName = inv.Value.Name; |
3733 | assetType = inv.Value.Type; | 3797 | break; |
3734 | objName = inv.Value.Name; | ||
3735 | break; | ||
3736 | } | ||
3737 | } | 3798 | } |
3738 | } | 3799 | } |
3800 | m_host.TaskInventory.LockItemsForRead(false); | ||
3739 | 3801 | ||
3740 | if (!found) | 3802 | if (!found) |
3741 | { | 3803 | { |
@@ -3780,24 +3842,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3780 | ScriptSleep(3000); | 3842 | ScriptSleep(3000); |
3781 | } | 3843 | } |
3782 | 3844 | ||
3845 | [DebuggerNonUserCode] | ||
3783 | public void llRemoveInventory(string name) | 3846 | public void llRemoveInventory(string name) |
3784 | { | 3847 | { |
3785 | m_host.AddScriptLPS(1); | 3848 | m_host.AddScriptLPS(1); |
3786 | 3849 | ||
3787 | lock (m_host.TaskInventory) | 3850 | m_host.TaskInventory.LockItemsForRead(true); |
3851 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3788 | { | 3852 | { |
3789 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3853 | if (item.Name == name) |
3790 | { | 3854 | { |
3791 | if (item.Name == name) | 3855 | if (item.ItemID == m_itemID) |
3792 | { | 3856 | throw new ScriptDeleteException(); |
3793 | if (item.ItemID == m_itemID) | 3857 | else |
3794 | throw new ScriptDeleteException(); | 3858 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3795 | else | 3859 | |
3796 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 3860 | m_host.TaskInventory.LockItemsForRead(false); |
3797 | return; | 3861 | return; |
3798 | } | ||
3799 | } | 3862 | } |
3800 | } | 3863 | } |
3864 | m_host.TaskInventory.LockItemsForRead(false); | ||
3801 | } | 3865 | } |
3802 | 3866 | ||
3803 | public void llSetText(string text, LSL_Vector color, double alpha) | 3867 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3886,6 +3950,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3886 | { | 3950 | { |
3887 | m_host.AddScriptLPS(1); | 3951 | m_host.AddScriptLPS(1); |
3888 | 3952 | ||
3953 | //Clone is thread safe | ||
3889 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 3954 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3890 | 3955 | ||
3891 | foreach (TaskInventoryItem item in itemDictionary.Values) | 3956 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3976,17 +4041,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3976 | UUID soundId = UUID.Zero; | 4041 | UUID soundId = UUID.Zero; |
3977 | if (!UUID.TryParse(impact_sound, out soundId)) | 4042 | if (!UUID.TryParse(impact_sound, out soundId)) |
3978 | { | 4043 | { |
3979 | lock (m_host.TaskInventory) | 4044 | m_host.TaskInventory.LockItemsForRead(true); |
4045 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3980 | { | 4046 | { |
3981 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4047 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
3982 | { | 4048 | { |
3983 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4049 | soundId = item.AssetID; |
3984 | { | 4050 | break; |
3985 | soundId = item.AssetID; | ||
3986 | break; | ||
3987 | } | ||
3988 | } | 4051 | } |
3989 | } | 4052 | } |
4053 | m_host.TaskInventory.LockItemsForRead(false); | ||
3990 | } | 4054 | } |
3991 | m_host.CollisionSound = soundId; | 4055 | m_host.CollisionSound = soundId; |
3992 | m_host.CollisionSoundVolume = (float)impact_volume; | 4056 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4032,6 +4096,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4032 | UUID partItemID; | 4096 | UUID partItemID; |
4033 | foreach (SceneObjectPart part in parts) | 4097 | foreach (SceneObjectPart part in parts) |
4034 | { | 4098 | { |
4099 | //Clone is thread safe | ||
4035 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4100 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4036 | 4101 | ||
4037 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4102 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4239,17 +4304,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4239 | 4304 | ||
4240 | m_host.AddScriptLPS(1); | 4305 | m_host.AddScriptLPS(1); |
4241 | 4306 | ||
4242 | lock (m_host.TaskInventory) | 4307 | m_host.TaskInventory.LockItemsForRead(true); |
4308 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4243 | { | 4309 | { |
4244 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4310 | if (item.Type == 10 && item.ItemID == m_itemID) |
4245 | { | 4311 | { |
4246 | if (item.Type == 10 && item.ItemID == m_itemID) | 4312 | result = item.Name!=null?item.Name:String.Empty; |
4247 | { | 4313 | break; |
4248 | result = item.Name!=null?item.Name:String.Empty; | ||
4249 | break; | ||
4250 | } | ||
4251 | } | 4314 | } |
4252 | } | 4315 | } |
4316 | m_host.TaskInventory.LockItemsForRead(false); | ||
4253 | 4317 | ||
4254 | return result; | 4318 | return result; |
4255 | } | 4319 | } |
@@ -4507,23 +4571,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4507 | { | 4571 | { |
4508 | m_host.AddScriptLPS(1); | 4572 | m_host.AddScriptLPS(1); |
4509 | 4573 | ||
4510 | lock (m_host.TaskInventory) | 4574 | m_host.TaskInventory.LockItemsForRead(true); |
4575 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4511 | { | 4576 | { |
4512 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4577 | if (inv.Value.Name == name) |
4513 | { | 4578 | { |
4514 | if (inv.Value.Name == name) | 4579 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4515 | { | 4580 | { |
4516 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4581 | m_host.TaskInventory.LockItemsForRead(false); |
4517 | { | 4582 | return inv.Value.AssetID.ToString(); |
4518 | return inv.Value.AssetID.ToString(); | 4583 | } |
4519 | } | 4584 | else |
4520 | else | 4585 | { |
4521 | { | 4586 | m_host.TaskInventory.LockItemsForRead(false); |
4522 | return UUID.Zero.ToString(); | 4587 | return UUID.Zero.ToString(); |
4523 | } | ||
4524 | } | 4588 | } |
4525 | } | 4589 | } |
4526 | } | 4590 | } |
4591 | m_host.TaskInventory.LockItemsForRead(false); | ||
4527 | 4592 | ||
4528 | return UUID.Zero.ToString(); | 4593 | return UUID.Zero.ToString(); |
4529 | } | 4594 | } |
@@ -6019,14 +6084,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6019 | 6084 | ||
6020 | protected UUID GetTaskInventoryItem(string name) | 6085 | protected UUID GetTaskInventoryItem(string name) |
6021 | { | 6086 | { |
6022 | lock (m_host.TaskInventory) | 6087 | m_host.TaskInventory.LockItemsForRead(true); |
6088 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6023 | { | 6089 | { |
6024 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6090 | if (inv.Value.Name == name) |
6025 | { | 6091 | { |
6026 | if (inv.Value.Name == name) | 6092 | m_host.TaskInventory.LockItemsForRead(false); |
6027 | return inv.Key; | 6093 | return inv.Key; |
6028 | } | 6094 | } |
6029 | } | 6095 | } |
6096 | m_host.TaskInventory.LockItemsForRead(false); | ||
6030 | 6097 | ||
6031 | return UUID.Zero; | 6098 | return UUID.Zero; |
6032 | } | 6099 | } |
@@ -6337,22 +6404,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6337 | } | 6404 | } |
6338 | 6405 | ||
6339 | // copy the first script found with this inventory name | 6406 | // copy the first script found with this inventory name |
6340 | lock (m_host.TaskInventory) | 6407 | m_host.TaskInventory.LockItemsForRead(true); |
6408 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6341 | { | 6409 | { |
6342 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6410 | if (inv.Value.Name == name) |
6343 | { | 6411 | { |
6344 | if (inv.Value.Name == name) | 6412 | // make sure the object is a script |
6413 | if (10 == inv.Value.Type) | ||
6345 | { | 6414 | { |
6346 | // make sure the object is a script | 6415 | found = true; |
6347 | if (10 == inv.Value.Type) | 6416 | srcId = inv.Key; |
6348 | { | 6417 | break; |
6349 | found = true; | ||
6350 | srcId = inv.Key; | ||
6351 | break; | ||
6352 | } | ||
6353 | } | 6418 | } |
6354 | } | 6419 | } |
6355 | } | 6420 | } |
6421 | m_host.TaskInventory.LockItemsForRead(false); | ||
6356 | 6422 | ||
6357 | if (!found) | 6423 | if (!found) |
6358 | { | 6424 | { |
@@ -8168,28 +8234,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8168 | { | 8234 | { |
8169 | m_host.AddScriptLPS(1); | 8235 | m_host.AddScriptLPS(1); |
8170 | 8236 | ||
8171 | lock (m_host.TaskInventory) | 8237 | m_host.TaskInventory.LockItemsForRead(true); |
8238 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8172 | { | 8239 | { |
8173 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8240 | if (inv.Value.Name == item) |
8174 | { | 8241 | { |
8175 | if (inv.Value.Name == item) | 8242 | m_host.TaskInventory.LockItemsForRead(false); |
8243 | switch (mask) | ||
8176 | { | 8244 | { |
8177 | switch (mask) | 8245 | case 0: |
8178 | { | 8246 | return (int)inv.Value.BasePermissions; |
8179 | case 0: | 8247 | case 1: |
8180 | return (int)inv.Value.BasePermissions; | 8248 | return (int)inv.Value.CurrentPermissions; |
8181 | case 1: | 8249 | case 2: |
8182 | return (int)inv.Value.CurrentPermissions; | 8250 | return (int)inv.Value.GroupPermissions; |
8183 | case 2: | 8251 | case 3: |
8184 | return (int)inv.Value.GroupPermissions; | 8252 | return (int)inv.Value.EveryonePermissions; |
8185 | case 3: | 8253 | case 4: |
8186 | return (int)inv.Value.EveryonePermissions; | 8254 | return (int)inv.Value.NextPermissions; |
8187 | case 4: | ||
8188 | return (int)inv.Value.NextPermissions; | ||
8189 | } | ||
8190 | } | 8255 | } |
8191 | } | 8256 | } |
8192 | } | 8257 | } |
8258 | m_host.TaskInventory.LockItemsForRead(false); | ||
8193 | 8259 | ||
8194 | return -1; | 8260 | return -1; |
8195 | } | 8261 | } |
@@ -8204,16 +8270,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8204 | { | 8270 | { |
8205 | m_host.AddScriptLPS(1); | 8271 | m_host.AddScriptLPS(1); |
8206 | 8272 | ||
8207 | lock (m_host.TaskInventory) | 8273 | m_host.TaskInventory.LockItemsForRead(true); |
8274 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8208 | { | 8275 | { |
8209 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8276 | if (inv.Value.Name == item) |
8210 | { | 8277 | { |
8211 | if (inv.Value.Name == item) | 8278 | m_host.TaskInventory.LockItemsForRead(false); |
8212 | { | 8279 | return inv.Value.CreatorID.ToString(); |
8213 | return inv.Value.CreatorID.ToString(); | ||
8214 | } | ||
8215 | } | 8280 | } |
8216 | } | 8281 | } |
8282 | m_host.TaskInventory.LockItemsForRead(false); | ||
8217 | 8283 | ||
8218 | llSay(0, "No item name '" + item + "'"); | 8284 | llSay(0, "No item name '" + item + "'"); |
8219 | 8285 | ||
@@ -8737,16 +8803,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8737 | { | 8803 | { |
8738 | m_host.AddScriptLPS(1); | 8804 | m_host.AddScriptLPS(1); |
8739 | 8805 | ||
8740 | lock (m_host.TaskInventory) | 8806 | m_host.TaskInventory.LockItemsForRead(true); |
8807 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8741 | { | 8808 | { |
8742 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8809 | if (inv.Value.Name == name) |
8743 | { | 8810 | { |
8744 | if (inv.Value.Name == name) | 8811 | m_host.TaskInventory.LockItemsForRead(false); |
8745 | { | 8812 | return inv.Value.Type; |
8746 | return inv.Value.Type; | ||
8747 | } | ||
8748 | } | 8813 | } |
8749 | } | 8814 | } |
8815 | m_host.TaskInventory.LockItemsForRead(false); | ||
8750 | 8816 | ||
8751 | return -1; | 8817 | return -1; |
8752 | } | 8818 | } |
@@ -8777,17 +8843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8777 | if (invItemID == UUID.Zero) | 8843 | if (invItemID == UUID.Zero) |
8778 | return new LSL_Vector(); | 8844 | return new LSL_Vector(); |
8779 | 8845 | ||
8780 | lock (m_host.TaskInventory) | 8846 | m_host.TaskInventory.LockItemsForRead(true); |
8847 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8781 | { | 8848 | { |
8782 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8849 | m_host.TaskInventory.LockItemsForRead(false); |
8783 | return new LSL_Vector(); | 8850 | return new LSL_Vector(); |
8851 | } | ||
8784 | 8852 | ||
8785 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 8853 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8786 | { | 8854 | { |
8787 | ShoutError("No permissions to track the camera"); | 8855 | ShoutError("No permissions to track the camera"); |
8788 | return new LSL_Vector(); | 8856 | m_host.TaskInventory.LockItemsForRead(false); |
8789 | } | 8857 | return new LSL_Vector(); |
8790 | } | 8858 | } |
8859 | m_host.TaskInventory.LockItemsForRead(false); | ||
8791 | 8860 | ||
8792 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8861 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8793 | if (presence != null) | 8862 | if (presence != null) |
@@ -8805,17 +8874,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8805 | if (invItemID == UUID.Zero) | 8874 | if (invItemID == UUID.Zero) |
8806 | return new LSL_Rotation(); | 8875 | return new LSL_Rotation(); |
8807 | 8876 | ||
8808 | lock (m_host.TaskInventory) | 8877 | m_host.TaskInventory.LockItemsForRead(true); |
8878 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8809 | { | 8879 | { |
8810 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 8880 | m_host.TaskInventory.LockItemsForRead(false); |
8811 | return new LSL_Rotation(); | 8881 | return new LSL_Rotation(); |
8812 | |||
8813 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8814 | { | ||
8815 | ShoutError("No permissions to track the camera"); | ||
8816 | return new LSL_Rotation(); | ||
8817 | } | ||
8818 | } | 8882 | } |
8883 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8884 | { | ||
8885 | ShoutError("No permissions to track the camera"); | ||
8886 | m_host.TaskInventory.LockItemsForRead(false); | ||
8887 | return new LSL_Rotation(); | ||
8888 | } | ||
8889 | m_host.TaskInventory.LockItemsForRead(false); | ||
8819 | 8890 | ||
8820 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 8891 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8821 | if (presence != null) | 8892 | if (presence != null) |
@@ -8965,14 +9036,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8965 | if (objectID == UUID.Zero) return; | 9036 | if (objectID == UUID.Zero) return; |
8966 | 9037 | ||
8967 | UUID agentID; | 9038 | UUID agentID; |
8968 | lock (m_host.TaskInventory) | 9039 | m_host.TaskInventory.LockItemsForRead(true); |
8969 | { | 9040 | // we need the permission first, to know which avatar we want to set the camera for |
8970 | // we need the permission first, to know which avatar we want to set the camera for | 9041 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
8971 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
8972 | 9042 | ||
8973 | if (agentID == UUID.Zero) return; | 9043 | if (agentID == UUID.Zero) |
8974 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9044 | { |
9045 | m_host.TaskInventory.LockItemsForRead(false); | ||
9046 | return; | ||
8975 | } | 9047 | } |
9048 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9049 | { | ||
9050 | m_host.TaskInventory.LockItemsForRead(false); | ||
9051 | return; | ||
9052 | } | ||
9053 | m_host.TaskInventory.LockItemsForRead(false); | ||
8976 | 9054 | ||
8977 | ScenePresence presence = World.GetScenePresence(agentID); | 9055 | ScenePresence presence = World.GetScenePresence(agentID); |
8978 | 9056 | ||
@@ -9022,12 +9100,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9022 | 9100 | ||
9023 | // we need the permission first, to know which avatar we want to clear the camera for | 9101 | // we need the permission first, to know which avatar we want to clear the camera for |
9024 | UUID agentID; | 9102 | UUID agentID; |
9025 | lock (m_host.TaskInventory) | 9103 | m_host.TaskInventory.LockItemsForRead(true); |
9104 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9105 | if (agentID == UUID.Zero) | ||
9106 | { | ||
9107 | m_host.TaskInventory.LockItemsForRead(false); | ||
9108 | return; | ||
9109 | } | ||
9110 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9026 | { | 9111 | { |
9027 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9112 | m_host.TaskInventory.LockItemsForRead(false); |
9028 | if (agentID == UUID.Zero) return; | 9113 | return; |
9029 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9030 | } | 9114 | } |
9115 | m_host.TaskInventory.LockItemsForRead(false); | ||
9031 | 9116 | ||
9032 | ScenePresence presence = World.GetScenePresence(agentID); | 9117 | ScenePresence presence = World.GetScenePresence(agentID); |
9033 | 9118 | ||
@@ -9484,15 +9569,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9484 | 9569 | ||
9485 | internal UUID ScriptByName(string name) | 9570 | internal UUID ScriptByName(string name) |
9486 | { | 9571 | { |
9487 | lock (m_host.TaskInventory) | 9572 | m_host.TaskInventory.LockItemsForRead(true); |
9573 | |||
9574 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9488 | { | 9575 | { |
9489 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9576 | if (item.Type == 10 && item.Name == name) |
9490 | { | 9577 | { |
9491 | if (item.Type == 10 && item.Name == name) | 9578 | m_host.TaskInventory.LockItemsForRead(false); |
9492 | return item.ItemID; | 9579 | return item.ItemID; |
9493 | } | 9580 | } |
9494 | } | 9581 | } |
9495 | 9582 | ||
9583 | m_host.TaskInventory.LockItemsForRead(false); | ||
9584 | |||
9496 | return UUID.Zero; | 9585 | return UUID.Zero; |
9497 | } | 9586 | } |
9498 | 9587 | ||
@@ -9533,6 +9622,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9533 | { | 9622 | { |
9534 | m_host.AddScriptLPS(1); | 9623 | m_host.AddScriptLPS(1); |
9535 | 9624 | ||
9625 | //Clone is thread safe | ||
9536 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9626 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9537 | 9627 | ||
9538 | UUID assetID = UUID.Zero; | 9628 | UUID assetID = UUID.Zero; |
@@ -9595,6 +9685,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9595 | { | 9685 | { |
9596 | m_host.AddScriptLPS(1); | 9686 | m_host.AddScriptLPS(1); |
9597 | 9687 | ||
9688 | //Clone is thread safe | ||
9598 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 9689 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9599 | 9690 | ||
9600 | UUID assetID = UUID.Zero; | 9691 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 9c7604b..bd09534 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ef990a1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,21 @@ | |||
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 580c354..d943b59 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs new file mode 100644 index 0000000..7b67fa3 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | |||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..5bc3a88 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public ICM_Api m_CM_Functions; | ||
52 | |||
53 | public void ApiTypeCM(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is ICM_Api)) | ||
56 | return; | ||
57 | |||
58 | m_CM_Functions = (ICM_Api)api; | ||
59 | } | ||
60 | |||
61 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
62 | { | ||
63 | return m_CM_Functions.cmGetWindlightScene(rules); | ||
64 | } | ||
65 | |||
66 | public int cmSetWindlightScene(LSL_List rules) | ||
67 | { | ||
68 | return m_CM_Functions.cmSetWindlightScene(rules); | ||
69 | } | ||
70 | |||
71 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
72 | { | ||
73 | return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..15e0408 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
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; |
@@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
131 | return (eventFlags); | 132 | return (eventFlags); |
132 | } | 133 | } |
133 | 134 | ||
135 | [DebuggerNonUserCode] | ||
134 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 136 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
135 | { | 137 | { |
136 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 138 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index 98bbc68..23138ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -17,6 +17,8 @@ | |||
17 | <excludeFiles /> | 17 | <excludeFiles /> |
18 | </DeploymentInformation> | 18 | </DeploymentInformation> |
19 | <Contents> | 19 | <Contents> |
20 | <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
21 | <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 23 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 121159c..a44abb0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
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 5c5d57e..8333a27 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/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 3f38bb6..1fc31c5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 | ||
432 | public int Size | ||
433 | { | ||
434 | get { return 0; } | ||
435 | } | ||
436 | |||
432 | public object[] Data | 437 | public object[] Data |
433 | { | 438 | { |
434 | get { | 439 | get { |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 25a4cd6..2a9a2db 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; |
@@ -100,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
100 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 101 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
101 | new Dictionary<UUID, IScriptInstance>(); | 102 | new Dictionary<UUID, IScriptInstance>(); |
102 | 103 | ||
104 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
105 | |||
103 | // Maps the asset ID to the assembly | 106 | // Maps the asset ID to the assembly |
104 | 107 | ||
105 | private Dictionary<UUID, string> m_Assemblies = | 108 | private Dictionary<UUID, string> m_Assemblies = |
@@ -121,6 +124,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
121 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); | 124 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
122 | IWorkItemResult m_CurrentCompile = null; | 125 | IWorkItemResult m_CurrentCompile = null; |
123 | 126 | ||
127 | private void lockScriptsForRead(bool locked) | ||
128 | { | ||
129 | if (locked) | ||
130 | { | ||
131 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
132 | { | ||
133 | 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."); | ||
134 | m_scriptsLock.ExitReadLock(); | ||
135 | } | ||
136 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
137 | { | ||
138 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
139 | m_scriptsLock.ExitWriteLock(); | ||
140 | } | ||
141 | |||
142 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
143 | { | ||
144 | 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."); | ||
145 | if (m_scriptsLock.IsWriteLockHeld) | ||
146 | { | ||
147 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
154 | { | ||
155 | m_scriptsLock.ExitReadLock(); | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | private void lockScriptsForWrite(bool locked) | ||
160 | { | ||
161 | if (locked) | ||
162 | { | ||
163 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
164 | { | ||
165 | 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."); | ||
166 | m_scriptsLock.ExitReadLock(); | ||
167 | } | ||
168 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
169 | { | ||
170 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
171 | m_scriptsLock.ExitWriteLock(); | ||
172 | } | ||
173 | |||
174 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
175 | { | ||
176 | 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."); | ||
177 | if (m_scriptsLock.IsWriteLockHeld) | ||
178 | { | ||
179 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
186 | { | ||
187 | m_scriptsLock.ExitWriteLock(); | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | |||
124 | public string ScriptEngineName | 192 | public string ScriptEngineName |
125 | { | 193 | { |
126 | get { return "XEngine"; } | 194 | get { return "XEngine"; } |
@@ -260,43 +328,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
260 | 328 | ||
261 | public void RemoveRegion(Scene scene) | 329 | public void RemoveRegion(Scene scene) |
262 | { | 330 | { |
263 | lock (m_Scripts) | 331 | lockScriptsForRead(true); |
332 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
264 | { | 333 | { |
265 | foreach (IScriptInstance instance in m_Scripts.Values) | 334 | // Force a final state save |
335 | // | ||
336 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
266 | { | 337 | { |
267 | // Force a final state save | 338 | string assembly = m_Assemblies[instance.AssetID]; |
268 | // | 339 | instance.SaveState(assembly); |
269 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 340 | } |
270 | { | ||
271 | string assembly = m_Assemblies[instance.AssetID]; | ||
272 | instance.SaveState(assembly); | ||
273 | } | ||
274 | 341 | ||
275 | // Clear the event queue and abort the instance thread | 342 | // Clear the event queue and abort the instance thread |
276 | // | 343 | // |
277 | instance.ClearQueue(); | 344 | instance.ClearQueue(); |
278 | instance.Stop(0); | 345 | instance.Stop(0); |
279 | 346 | ||
280 | // Release events, timer, etc | 347 | // Release events, timer, etc |
281 | // | 348 | // |
282 | instance.DestroyScriptInstance(); | 349 | instance.DestroyScriptInstance(); |
283 | 350 | ||
284 | // Unload scripts and app domains | 351 | // Unload scripts and app domains |
285 | // Must be done explicitly because they have infinite | 352 | // Must be done explicitly because they have infinite |
286 | // lifetime | 353 | // lifetime |
287 | // | 354 | // |
288 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 355 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
289 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 356 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
290 | { | 357 | { |
291 | m_DomainScripts.Remove(instance.AppDomain); | 358 | m_DomainScripts.Remove(instance.AppDomain); |
292 | UnloadAppDomain(instance.AppDomain); | 359 | UnloadAppDomain(instance.AppDomain); |
293 | } | ||
294 | } | 360 | } |
295 | m_Scripts.Clear(); | ||
296 | m_PrimObjects.Clear(); | ||
297 | m_Assemblies.Clear(); | ||
298 | m_DomainScripts.Clear(); | ||
299 | } | 361 | } |
362 | lockScriptsForRead(false); | ||
363 | lockScriptsForWrite(true); | ||
364 | m_Scripts.Clear(); | ||
365 | lockScriptsForWrite(false); | ||
366 | m_PrimObjects.Clear(); | ||
367 | m_Assemblies.Clear(); | ||
368 | m_DomainScripts.Clear(); | ||
369 | |||
300 | lock (m_ScriptEngines) | 370 | lock (m_ScriptEngines) |
301 | { | 371 | { |
302 | m_ScriptEngines.Remove(this); | 372 | m_ScriptEngines.Remove(this); |
@@ -355,22 +425,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
355 | 425 | ||
356 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 426 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
357 | 427 | ||
358 | lock (m_Scripts) | 428 | lockScriptsForRead(true); |
359 | { | 429 | foreach (IScriptInstance instance in m_Scripts.Values) |
360 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
361 | instances.Add(instance); | 430 | instances.Add(instance); |
362 | } | 431 | lockScriptsForRead(false); |
363 | 432 | ||
364 | foreach (IScriptInstance i in instances) | 433 | foreach (IScriptInstance i in instances) |
365 | { | 434 | { |
366 | string assembly = String.Empty; | 435 | string assembly = String.Empty; |
367 | 436 | ||
368 | lock (m_Scripts) | 437 | |
369 | { | ||
370 | if (!m_Assemblies.ContainsKey(i.AssetID)) | 438 | if (!m_Assemblies.ContainsKey(i.AssetID)) |
371 | continue; | 439 | continue; |
372 | assembly = m_Assemblies[i.AssetID]; | 440 | assembly = m_Assemblies[i.AssetID]; |
373 | } | 441 | |
374 | 442 | ||
375 | i.SaveState(assembly); | 443 | i.SaveState(assembly); |
376 | } | 444 | } |
@@ -672,172 +740,183 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
672 | return false; | 740 | return false; |
673 | } | 741 | } |
674 | 742 | ||
675 | lock (m_Scripts) | 743 | |
744 | |||
745 | ScriptInstance instance = null; | ||
746 | // Create the object record | ||
747 | lockScriptsForRead(true); | ||
748 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
749 | (m_Scripts[itemID].AssetID != assetID)) | ||
676 | { | 750 | { |
677 | ScriptInstance instance = null; | 751 | lockScriptsForRead(false); |
678 | // Create the object record | ||
679 | 752 | ||
680 | if ((!m_Scripts.ContainsKey(itemID)) || | 753 | UUID appDomain = assetID; |
681 | (m_Scripts[itemID].AssetID != assetID)) | ||
682 | { | ||
683 | UUID appDomain = assetID; | ||
684 | 754 | ||
685 | if (part.ParentGroup.IsAttachment) | 755 | if (part.ParentGroup.IsAttachment) |
686 | appDomain = part.ParentGroup.RootPart.UUID; | 756 | appDomain = part.ParentGroup.RootPart.UUID; |
687 | 757 | ||
688 | if (!m_AppDomains.ContainsKey(appDomain)) | 758 | if (!m_AppDomains.ContainsKey(appDomain)) |
759 | { | ||
760 | try | ||
689 | { | 761 | { |
690 | try | 762 | AppDomainSetup appSetup = new AppDomainSetup(); |
691 | { | 763 | // appSetup.ApplicationBase = Path.Combine( |
692 | AppDomainSetup appSetup = new AppDomainSetup(); | 764 | // "ScriptEngines", |
693 | // appSetup.ApplicationBase = Path.Combine( | 765 | // m_Scene.RegionInfo.RegionID.ToString()); |
694 | // "ScriptEngines", | 766 | |
695 | // m_Scene.RegionInfo.RegionID.ToString()); | 767 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
696 | 768 | Evidence evidence = new Evidence(baseEvidence); | |
697 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 769 | |
698 | Evidence evidence = new Evidence(baseEvidence); | 770 | AppDomain sandbox; |
699 | 771 | if (m_AppDomainLoading) | |
700 | AppDomain sandbox; | 772 | sandbox = AppDomain.CreateDomain( |
701 | if (m_AppDomainLoading) | 773 | m_Scene.RegionInfo.RegionID.ToString(), |
702 | sandbox = AppDomain.CreateDomain( | 774 | evidence, appSetup); |
703 | m_Scene.RegionInfo.RegionID.ToString(), | 775 | else |
704 | evidence, appSetup); | 776 | sandbox = AppDomain.CurrentDomain; |
705 | else | 777 | |
706 | sandbox = AppDomain.CurrentDomain; | 778 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
707 | 779 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | |
708 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 780 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
709 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 781 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
710 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 782 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
711 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 783 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; |
712 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 784 | //sandbox.SetAppDomainPolicy(sandboxPolicy); |
713 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 785 | |
714 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | 786 | m_AppDomains[appDomain] = sandbox; |
715 | 787 | ||
716 | m_AppDomains[appDomain] = sandbox; | 788 | m_AppDomains[appDomain].AssemblyResolve += |
717 | 789 | new ResolveEventHandler( | |
718 | m_AppDomains[appDomain].AssemblyResolve += | 790 | AssemblyResolver.OnAssemblyResolve); |
719 | new ResolveEventHandler( | 791 | m_DomainScripts[appDomain] = new List<UUID>(); |
720 | AssemblyResolver.OnAssemblyResolve); | ||
721 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
722 | } | ||
723 | catch (Exception e) | ||
724 | { | ||
725 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | ||
726 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
727 | m_ScriptFailCount++; | ||
728 | lock (m_AddingAssemblies) | ||
729 | { | ||
730 | m_AddingAssemblies[assembly]--; | ||
731 | } | ||
732 | return false; | ||
733 | } | ||
734 | } | 792 | } |
735 | m_DomainScripts[appDomain].Add(itemID); | 793 | catch (Exception e) |
736 | |||
737 | instance = new ScriptInstance(this, part, | ||
738 | itemID, assetID, assembly, | ||
739 | m_AppDomains[appDomain], | ||
740 | part.ParentGroup.RootPart.Name, | ||
741 | item.Name, startParam, postOnRez, | ||
742 | stateSource, m_MaxScriptQueue); | ||
743 | |||
744 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", | ||
745 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); | ||
746 | |||
747 | if (presence != null) | ||
748 | { | 794 | { |
749 | ShowScriptSaveResponse(item.OwnerID, | 795 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
750 | assetID, "Compile successful", true); | 796 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
797 | m_ScriptFailCount++; | ||
798 | lock (m_AddingAssemblies) | ||
799 | { | ||
800 | m_AddingAssemblies[assembly]--; | ||
801 | } | ||
802 | return false; | ||
751 | } | 803 | } |
804 | } | ||
805 | m_DomainScripts[appDomain].Add(itemID); | ||
752 | 806 | ||
753 | instance.AppDomain = appDomain; | 807 | instance = new ScriptInstance(this, part, |
754 | instance.LineMap = linemap; | 808 | itemID, assetID, assembly, |
809 | m_AppDomains[appDomain], | ||
810 | part.ParentGroup.RootPart.Name, | ||
811 | item.Name, startParam, postOnRez, | ||
812 | stateSource, m_MaxScriptQueue); | ||
755 | 813 | ||
756 | m_Scripts[itemID] = instance; | 814 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", |
757 | } | 815 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); |
758 | 816 | ||
759 | lock (m_PrimObjects) | 817 | if (presence != null) |
760 | { | 818 | { |
761 | if (!m_PrimObjects.ContainsKey(localID)) | 819 | ShowScriptSaveResponse(item.OwnerID, |
762 | m_PrimObjects[localID] = new List<UUID>(); | 820 | assetID, "Compile successful", true); |
821 | } | ||
763 | 822 | ||
764 | if (!m_PrimObjects[localID].Contains(itemID)) | 823 | instance.AppDomain = appDomain; |
765 | m_PrimObjects[localID].Add(itemID); | 824 | instance.LineMap = linemap; |
825 | lockScriptsForWrite(true); | ||
826 | m_Scripts[itemID] = instance; | ||
827 | lockScriptsForWrite(false); | ||
828 | } | ||
829 | else | ||
830 | { | ||
831 | lockScriptsForRead(false); | ||
832 | } | ||
833 | lock (m_PrimObjects) | ||
834 | { | ||
835 | if (!m_PrimObjects.ContainsKey(localID)) | ||
836 | m_PrimObjects[localID] = new List<UUID>(); | ||
766 | 837 | ||
767 | } | 838 | if (!m_PrimObjects[localID].Contains(itemID)) |
839 | m_PrimObjects[localID].Add(itemID); | ||
768 | 840 | ||
769 | if (!m_Assemblies.ContainsKey(assetID)) | 841 | } |
770 | m_Assemblies[assetID] = assembly; | ||
771 | 842 | ||
772 | lock (m_AddingAssemblies) | 843 | if (!m_Assemblies.ContainsKey(assetID)) |
773 | { | 844 | m_Assemblies[assetID] = assembly; |
774 | m_AddingAssemblies[assembly]--; | ||
775 | } | ||
776 | 845 | ||
777 | if (instance!=null) | 846 | lock (m_AddingAssemblies) |
778 | instance.Init(); | 847 | { |
848 | m_AddingAssemblies[assembly]--; | ||
779 | } | 849 | } |
850 | |||
851 | if (instance!=null) | ||
852 | instance.Init(); | ||
853 | |||
780 | return true; | 854 | return true; |
781 | } | 855 | } |
782 | 856 | ||
783 | public void OnRemoveScript(uint localID, UUID itemID) | 857 | public void OnRemoveScript(uint localID, UUID itemID) |
784 | { | 858 | { |
785 | lock (m_Scripts) | 859 | lockScriptsForRead(true); |
860 | // Do we even have it? | ||
861 | if (!m_Scripts.ContainsKey(itemID)) | ||
786 | { | 862 | { |
787 | // Do we even have it? | 863 | lockScriptsForRead(false); |
788 | if (!m_Scripts.ContainsKey(itemID)) | 864 | return; |
789 | return; | 865 | } |
790 | 866 | ||
791 | IScriptInstance instance=m_Scripts[itemID]; | ||
792 | m_Scripts.Remove(itemID); | ||
793 | 867 | ||
794 | instance.ClearQueue(); | 868 | IScriptInstance instance=m_Scripts[itemID]; |
795 | instance.Stop(0); | 869 | lockScriptsForRead(false); |
870 | lockScriptsForWrite(true); | ||
871 | m_Scripts.Remove(itemID); | ||
872 | lockScriptsForWrite(false); | ||
873 | instance.ClearQueue(); | ||
874 | instance.Stop(0); | ||
796 | 875 | ||
797 | SceneObjectPart part = | 876 | SceneObjectPart part = |
798 | m_Scene.GetSceneObjectPart(localID); | 877 | m_Scene.GetSceneObjectPart(localID); |
799 | 878 | ||
800 | if (part != null) | 879 | if (part != null) |
801 | part.RemoveScriptEvents(itemID); | 880 | part.RemoveScriptEvents(itemID); |
802 | 881 | ||
803 | // bool objectRemoved = false; | 882 | // bool objectRemoved = false; |
804 | 883 | ||
805 | lock (m_PrimObjects) | 884 | lock (m_PrimObjects) |
885 | { | ||
886 | // Remove the script from it's prim | ||
887 | if (m_PrimObjects.ContainsKey(localID)) | ||
806 | { | 888 | { |
807 | // Remove the script from it's prim | 889 | // Remove inventory item record |
808 | if (m_PrimObjects.ContainsKey(localID)) | 890 | if (m_PrimObjects[localID].Contains(itemID)) |
809 | { | 891 | m_PrimObjects[localID].Remove(itemID); |
810 | // Remove inventory item record | ||
811 | if (m_PrimObjects[localID].Contains(itemID)) | ||
812 | m_PrimObjects[localID].Remove(itemID); | ||
813 | 892 | ||
814 | // If there are no more scripts, remove prim | 893 | // If there are no more scripts, remove prim |
815 | if (m_PrimObjects[localID].Count == 0) | 894 | if (m_PrimObjects[localID].Count == 0) |
816 | { | 895 | { |
817 | m_PrimObjects.Remove(localID); | 896 | m_PrimObjects.Remove(localID); |
818 | // objectRemoved = true; | 897 | // objectRemoved = true; |
819 | } | ||
820 | } | 898 | } |
821 | } | 899 | } |
900 | } | ||
822 | 901 | ||
823 | instance.RemoveState(); | 902 | instance.RemoveState(); |
824 | instance.DestroyScriptInstance(); | 903 | instance.DestroyScriptInstance(); |
825 | 904 | ||
826 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 905 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
827 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 906 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
828 | { | 907 | { |
829 | m_DomainScripts.Remove(instance.AppDomain); | 908 | m_DomainScripts.Remove(instance.AppDomain); |
830 | UnloadAppDomain(instance.AppDomain); | 909 | UnloadAppDomain(instance.AppDomain); |
831 | } | 910 | } |
832 | 911 | ||
833 | instance = null; | 912 | instance = null; |
834 | 913 | ||
835 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 914 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
836 | if (handlerObjectRemoved != null) | 915 | if (handlerObjectRemoved != null) |
837 | handlerObjectRemoved(part.UUID); | 916 | handlerObjectRemoved(part.UUID); |
838 | 917 | ||
839 | CleanAssemblies(); | 918 | CleanAssemblies(); |
840 | } | 919 | |
841 | 920 | ||
842 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 921 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
843 | if (handlerScriptRemoved != null) | 922 | if (handlerScriptRemoved != null) |
@@ -1090,12 +1169,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1090 | private IScriptInstance GetInstance(UUID itemID) | 1169 | private IScriptInstance GetInstance(UUID itemID) |
1091 | { | 1170 | { |
1092 | IScriptInstance instance; | 1171 | IScriptInstance instance; |
1093 | lock (m_Scripts) | 1172 | lockScriptsForRead(true); |
1173 | if (!m_Scripts.ContainsKey(itemID)) | ||
1094 | { | 1174 | { |
1095 | if (!m_Scripts.ContainsKey(itemID)) | 1175 | lockScriptsForRead(false); |
1096 | return null; | 1176 | return null; |
1097 | instance = m_Scripts[itemID]; | ||
1098 | } | 1177 | } |
1178 | instance = m_Scripts[itemID]; | ||
1179 | lockScriptsForRead(false); | ||
1099 | return instance; | 1180 | return instance; |
1100 | } | 1181 | } |
1101 | 1182 | ||
@@ -1119,6 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1119 | return false; | 1200 | return false; |
1120 | } | 1201 | } |
1121 | 1202 | ||
1203 | [DebuggerNonUserCode] | ||
1122 | public void ApiResetScript(UUID itemID) | 1204 | public void ApiResetScript(UUID itemID) |
1123 | { | 1205 | { |
1124 | IScriptInstance instance = GetInstance(itemID); | 1206 | IScriptInstance instance = GetInstance(itemID); |
@@ -1170,6 +1252,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1170 | return UUID.Zero; | 1252 | return UUID.Zero; |
1171 | } | 1253 | } |
1172 | 1254 | ||
1255 | [DebuggerNonUserCode] | ||
1173 | public void SetState(UUID itemID, string newState) | 1256 | public void SetState(UUID itemID, string newState) |
1174 | { | 1257 | { |
1175 | IScriptInstance instance = GetInstance(itemID); | 1258 | IScriptInstance instance = GetInstance(itemID); |
@@ -1197,11 +1280,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1197 | { | 1280 | { |
1198 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1281 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1199 | 1282 | ||
1200 | lock (m_Scripts) | 1283 | lockScriptsForRead(true); |
1201 | { | 1284 | foreach (IScriptInstance instance in m_Scripts.Values) |
1202 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1203 | instances.Add(instance); | 1285 | instances.Add(instance); |
1204 | } | 1286 | lockScriptsForRead(false); |
1205 | 1287 | ||
1206 | foreach (IScriptInstance i in instances) | 1288 | foreach (IScriptInstance i in instances) |
1207 | { | 1289 | { |