diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
15 files changed, 1776 insertions, 617 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..5b180ff --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,502 @@ | |||
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 | /// Like osGetAgents but returns enough info for a radar | ||
90 | /// </summary> | ||
91 | /// <returns>Strided list of the UUID, position and name of each avatar in the region</returns> | ||
92 | public LSL_List cmGetAvatarList() | ||
93 | { | ||
94 | LSL_List result = new LSL_List(); | ||
95 | foreach (ScenePresence avatar in World.GetAvatars()) | ||
96 | { | ||
97 | if (avatar != null && avatar.UUID != m_host.OwnerID) | ||
98 | { | ||
99 | if (avatar.IsChildAgent == false) | ||
100 | { | ||
101 | if (avatar.PhysicsActor != null && avatar.PhysicsActor.Position != null) | ||
102 | { | ||
103 | result.Add(avatar.UUID); | ||
104 | result.Add(avatar.PhysicsActor.Position); | ||
105 | result.Add(avatar.Name); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | return result; | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Get the current Windlight scene | ||
115 | /// </summary> | ||
116 | /// <returns>List of windlight parameters</returns> | ||
117 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
118 | { | ||
119 | if (!m_CMFunctionsEnabled) | ||
120 | { | ||
121 | CMShoutError("Careminster functions are not enabled."); | ||
122 | return new LSL_List(); | ||
123 | } | ||
124 | m_host.AddScriptLPS(1); | ||
125 | RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
126 | |||
127 | LSL_List values = new LSL_List(); | ||
128 | int idx = 0; | ||
129 | while (idx < rules.Length) | ||
130 | { | ||
131 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
132 | LSL_List toadd = new LSL_List(); | ||
133 | |||
134 | switch (rule) | ||
135 | { | ||
136 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
137 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
138 | break; | ||
139 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
140 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
141 | break; | ||
142 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
143 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
144 | break; | ||
145 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
146 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
147 | break; | ||
148 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
149 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
150 | break; | ||
151 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
152 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
153 | break; | ||
154 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
155 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
156 | break; | ||
157 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
158 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
159 | break; | ||
160 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
161 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
162 | break; | ||
163 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
164 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
165 | break; | ||
166 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
167 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
168 | break; | ||
169 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
170 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
171 | break; | ||
172 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
173 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
174 | break; | ||
175 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
176 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
177 | break; | ||
178 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
179 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
180 | break; | ||
181 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
182 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
183 | break; | ||
184 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
185 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
186 | break; | ||
187 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
188 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
189 | break; | ||
190 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
191 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
192 | break; | ||
193 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
194 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
195 | break; | ||
196 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
197 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
198 | break; | ||
199 | case (int)ScriptBaseClass.WL_HORIZON: | ||
200 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
201 | break; | ||
202 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
203 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
204 | break; | ||
205 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
206 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
207 | break; | ||
208 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
209 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
210 | break; | ||
211 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
212 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
213 | break; | ||
214 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
215 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
216 | break; | ||
217 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
218 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
219 | break; | ||
220 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
221 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
222 | break; | ||
223 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
224 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
225 | break; | ||
226 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
227 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
228 | break; | ||
229 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
230 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
231 | break; | ||
232 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
233 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
234 | break; | ||
235 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
236 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
237 | break; | ||
238 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
239 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
240 | break; | ||
241 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
242 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
243 | break; | ||
244 | } | ||
245 | |||
246 | if (toadd.Length > 0) | ||
247 | { | ||
248 | values.Add(rule); | ||
249 | values.Add(toadd.Data[0]); | ||
250 | } | ||
251 | idx++; | ||
252 | } | ||
253 | |||
254 | |||
255 | return values; | ||
256 | |||
257 | } | ||
258 | |||
259 | private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) | ||
260 | { | ||
261 | RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
262 | |||
263 | LSL_List values = new LSL_List(); | ||
264 | int idx = 0; | ||
265 | while (idx < rules.Length) | ||
266 | { | ||
267 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
268 | LSL_Types.Quaternion iQ; | ||
269 | LSL_Types.Vector3 iV; | ||
270 | switch (rule) | ||
271 | { | ||
272 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | ||
273 | idx++; | ||
274 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | ||
275 | break; | ||
276 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
277 | idx++; | ||
278 | iQ = rules.GetQuaternionItem(idx); | ||
279 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
280 | break; | ||
281 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
282 | idx++; | ||
283 | iV = rules.GetVector3Item(idx); | ||
284 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
285 | break; | ||
286 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
287 | idx++; | ||
288 | iQ = rules.GetQuaternionItem(idx); | ||
289 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
290 | break; | ||
291 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
292 | idx++; | ||
293 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
294 | break; | ||
295 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
296 | idx++; | ||
297 | iQ = rules.GetQuaternionItem(idx); | ||
298 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
299 | break; | ||
300 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
301 | idx++; | ||
302 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
303 | break; | ||
304 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
305 | idx++; | ||
306 | iV = rules.GetVector3Item(idx); | ||
307 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
308 | break; | ||
309 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
310 | idx++; | ||
311 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
312 | break; | ||
313 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
314 | idx++; | ||
315 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
316 | break; | ||
317 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
318 | idx++; | ||
319 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
320 | break; | ||
321 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
322 | idx++; | ||
323 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
324 | break; | ||
325 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
326 | idx++; | ||
327 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
328 | break; | ||
329 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
330 | idx++; | ||
331 | iV = rules.GetVector3Item(idx); | ||
332 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
333 | break; | ||
334 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
335 | idx++; | ||
336 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
337 | break; | ||
338 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
339 | idx++; | ||
340 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
341 | break; | ||
342 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
343 | idx++; | ||
344 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
345 | break; | ||
346 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
347 | idx++; | ||
348 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
349 | break; | ||
350 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
351 | idx++; | ||
352 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
353 | break; | ||
354 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
355 | idx++; | ||
356 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
357 | break; | ||
358 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
359 | idx++; | ||
360 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
361 | break; | ||
362 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
363 | idx++; | ||
364 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
365 | break; | ||
366 | case (int)ScriptBaseClass.WL_HORIZON: | ||
367 | idx++; | ||
368 | iQ = rules.GetQuaternionItem(idx); | ||
369 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
370 | break; | ||
371 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
372 | idx++; | ||
373 | iV = rules.GetVector3Item(idx); | ||
374 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
375 | break; | ||
376 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
377 | idx++; | ||
378 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
379 | break; | ||
380 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
381 | idx++; | ||
382 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
383 | break; | ||
384 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
385 | idx++; | ||
386 | iV = rules.GetVector3Item(idx); | ||
387 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
388 | break; | ||
389 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
390 | idx++; | ||
391 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
392 | break; | ||
393 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
394 | idx++; | ||
395 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
396 | break; | ||
397 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
398 | idx++; | ||
399 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
400 | break; | ||
401 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
402 | idx++; | ||
403 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
404 | break; | ||
405 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
406 | idx++; | ||
407 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
408 | break; | ||
409 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
410 | idx++; | ||
411 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
412 | break; | ||
413 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
414 | idx++; | ||
415 | iQ = rules.GetQuaternionItem(idx); | ||
416 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
417 | break; | ||
418 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
419 | idx++; | ||
420 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
421 | break; | ||
422 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
423 | idx++; | ||
424 | iV = rules.GetVector3Item(idx); | ||
425 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
426 | break; | ||
427 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
428 | idx++; | ||
429 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
430 | break; | ||
431 | } | ||
432 | idx++; | ||
433 | } | ||
434 | return wl; | ||
435 | } | ||
436 | /// <summary> | ||
437 | /// Set the current Windlight scene | ||
438 | /// </summary> | ||
439 | /// <param name="rules"></param> | ||
440 | /// <returns>success: true or false</returns> | ||
441 | public int cmSetWindlightScene(LSL_List rules) | ||
442 | { | ||
443 | if (!m_CMFunctionsEnabled) | ||
444 | { | ||
445 | CMShoutError("Careminster functions are not enabled."); | ||
446 | return 0; | ||
447 | } | ||
448 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
449 | { | ||
450 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
451 | return 0; | ||
452 | } | ||
453 | int success = 0; | ||
454 | m_host.AddScriptLPS(1); | ||
455 | if (Meta7WindlightModule.EnableWindlight) | ||
456 | { | ||
457 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
458 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
459 | success = 1; | ||
460 | } | ||
461 | else | ||
462 | { | ||
463 | CMShoutError("Windlight module is disabled"); | ||
464 | return 0; | ||
465 | } | ||
466 | return success; | ||
467 | } | ||
468 | /// <summary> | ||
469 | /// Set the current Windlight scene to a target avatar | ||
470 | /// </summary> | ||
471 | /// <param name="rules"></param> | ||
472 | /// <returns>success: true or false</returns> | ||
473 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
474 | { | ||
475 | if (!m_CMFunctionsEnabled) | ||
476 | { | ||
477 | CMShoutError("Careminster functions are not enabled."); | ||
478 | return 0; | ||
479 | } | ||
480 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
481 | { | ||
482 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
483 | return 0; | ||
484 | } | ||
485 | int success = 0; | ||
486 | m_host.AddScriptLPS(1); | ||
487 | if (Meta7WindlightModule.EnableWindlight) | ||
488 | { | ||
489 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
490 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
491 | success = 1; | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | CMShoutError("Windlight module is disabled"); | ||
496 | return 0; | ||
497 | } | ||
498 | return success; | ||
499 | } | ||
500 | |||
501 | } | ||
502 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index eaaa9eb..012ba90 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); |
@@ -219,6 +222,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
219 | public List<SceneObjectPart> GetLinkParts(int linkType) | 222 | public List<SceneObjectPart> GetLinkParts(int linkType) |
220 | { | 223 | { |
221 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); | 224 | List<SceneObjectPart> ret = new List<SceneObjectPart>(); |
225 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
226 | return ret; | ||
222 | ret.Add(m_host); | 227 | ret.Add(m_host); |
223 | 228 | ||
224 | switch (linkType) | 229 | switch (linkType) |
@@ -272,40 +277,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
272 | protected UUID InventorySelf() | 277 | protected UUID InventorySelf() |
273 | { | 278 | { |
274 | UUID invItemID = new UUID(); | 279 | UUID invItemID = new UUID(); |
275 | 280 | bool unlock = false; | |
276 | lock (m_host.TaskInventory) | 281 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
277 | { | 282 | { |
278 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 283 | m_host.TaskInventory.LockItemsForRead(true); |
284 | unlock = true; | ||
285 | } | ||
286 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
287 | { | ||
288 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | ||
279 | { | 289 | { |
280 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 290 | invItemID = inv.Key; |
281 | { | 291 | break; |
282 | invItemID = inv.Key; | ||
283 | break; | ||
284 | } | ||
285 | } | 292 | } |
286 | } | 293 | } |
287 | 294 | if (unlock) | |
295 | { | ||
296 | m_host.TaskInventory.LockItemsForRead(false); | ||
297 | } | ||
288 | return invItemID; | 298 | return invItemID; |
289 | } | 299 | } |
290 | 300 | ||
291 | protected UUID InventoryKey(string name, int type) | 301 | protected UUID InventoryKey(string name, int type) |
292 | { | 302 | { |
293 | m_host.AddScriptLPS(1); | 303 | m_host.AddScriptLPS(1); |
294 | 304 | m_host.TaskInventory.LockItemsForRead(true); | |
295 | lock (m_host.TaskInventory) | 305 | |
306 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
296 | { | 307 | { |
297 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 308 | if (inv.Value.Name == name) |
298 | { | 309 | { |
299 | if (inv.Value.Name == name) | 310 | m_host.TaskInventory.LockItemsForRead(false); |
311 | |||
312 | if (inv.Value.Type != type) | ||
300 | { | 313 | { |
301 | if (inv.Value.Type != type) | 314 | return UUID.Zero; |
302 | return UUID.Zero; | ||
303 | |||
304 | return inv.Value.AssetID; | ||
305 | } | 315 | } |
316 | |||
317 | return inv.Value.AssetID; | ||
306 | } | 318 | } |
307 | } | 319 | } |
308 | 320 | ||
321 | m_host.TaskInventory.LockItemsForRead(false); | ||
309 | return UUID.Zero; | 322 | return UUID.Zero; |
310 | } | 323 | } |
311 | 324 | ||
@@ -313,17 +326,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
313 | { | 326 | { |
314 | m_host.AddScriptLPS(1); | 327 | m_host.AddScriptLPS(1); |
315 | 328 | ||
316 | lock (m_host.TaskInventory) | 329 | |
330 | m_host.TaskInventory.LockItemsForRead(true); | ||
331 | |||
332 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
317 | { | 333 | { |
318 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 334 | if (inv.Value.Name == name) |
319 | { | 335 | { |
320 | if (inv.Value.Name == name) | 336 | m_host.TaskInventory.LockItemsForRead(false); |
321 | { | 337 | return inv.Value.AssetID; |
322 | return inv.Value.AssetID; | ||
323 | } | ||
324 | } | 338 | } |
325 | } | 339 | } |
326 | 340 | ||
341 | m_host.TaskInventory.LockItemsForRead(false); | ||
342 | |||
343 | |||
327 | return UUID.Zero; | 344 | return UUID.Zero; |
328 | } | 345 | } |
329 | 346 | ||
@@ -700,6 +717,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
700 | { | 717 | { |
701 | //A and B should both be normalized | 718 | //A and B should both be normalized |
702 | m_host.AddScriptLPS(1); | 719 | m_host.AddScriptLPS(1); |
720 | /* This method is more accurate than the SL one, and thus causes problems | ||
721 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. | ||
722 | |||
703 | double dotProduct = LSL_Vector.Dot(a, b); | 723 | double dotProduct = LSL_Vector.Dot(a, b); |
704 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 724 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
705 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | 725 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
@@ -716,8 +736,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
716 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 736 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
717 | 737 | ||
718 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | 738 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
719 | } | 739 | */ |
720 | 740 | ||
741 | // This method mimics the 180 errors found in SL | ||
742 | // See www.euclideanspace.com... angleBetween | ||
743 | LSL_Vector vec_a = a; | ||
744 | LSL_Vector vec_b = b; | ||
745 | |||
746 | // Eliminate zero length | ||
747 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
748 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
749 | if (vec_a_mag < 0.00001 || | ||
750 | vec_b_mag < 0.00001) | ||
751 | { | ||
752 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
753 | } | ||
754 | |||
755 | // Normalize | ||
756 | vec_a = llVecNorm(vec_a); | ||
757 | vec_b = llVecNorm(vec_b); | ||
758 | |||
759 | // Calculate axis and rotation angle | ||
760 | LSL_Vector axis = vec_a % vec_b; | ||
761 | LSL_Float cos_theta = vec_a * vec_b; | ||
762 | |||
763 | // Check if parallel | ||
764 | if (cos_theta > 0.99999) | ||
765 | { | ||
766 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
767 | } | ||
768 | |||
769 | // Check if anti-parallel | ||
770 | else if (cos_theta < -0.99999) | ||
771 | { | ||
772 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); | ||
773 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); | ||
774 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); | ||
775 | } | ||
776 | else // other rotation | ||
777 | { | ||
778 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; | ||
779 | axis = llVecNorm(axis); | ||
780 | double x, y, z, s, t; | ||
781 | s = Math.Cos(theta); | ||
782 | t = Math.Sin(theta); | ||
783 | x = axis.x * t; | ||
784 | y = axis.y * t; | ||
785 | z = axis.z * t; | ||
786 | return new LSL_Rotation(x,y,z,s); | ||
787 | } | ||
788 | } | ||
789 | |||
721 | public void llWhisper(int channelID, string text) | 790 | public void llWhisper(int channelID, string text) |
722 | { | 791 | { |
723 | m_host.AddScriptLPS(1); | 792 | m_host.AddScriptLPS(1); |
@@ -1041,10 +1110,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1041 | return detectedParams.TouchUV; | 1110 | return detectedParams.TouchUV; |
1042 | } | 1111 | } |
1043 | 1112 | ||
1113 | [DebuggerNonUserCode] | ||
1044 | public virtual void llDie() | 1114 | public virtual void llDie() |
1045 | { | 1115 | { |
1046 | m_host.AddScriptLPS(1); | 1116 | m_host.AddScriptLPS(1); |
1047 | throw new SelfDeleteException(); | 1117 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1048 | } | 1118 | } |
1049 | 1119 | ||
1050 | public LSL_Float llGround(LSL_Vector offset) | 1120 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1117,6 +1187,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1117 | 1187 | ||
1118 | public void llSetStatus(int status, int value) | 1188 | public void llSetStatus(int status, int value) |
1119 | { | 1189 | { |
1190 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1191 | return; | ||
1120 | m_host.AddScriptLPS(1); | 1192 | m_host.AddScriptLPS(1); |
1121 | 1193 | ||
1122 | int statusrotationaxis = 0; | 1194 | int statusrotationaxis = 0; |
@@ -1346,6 +1418,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1346 | { | 1418 | { |
1347 | m_host.AddScriptLPS(1); | 1419 | m_host.AddScriptLPS(1); |
1348 | 1420 | ||
1421 | SetColor(m_host, color, face); | ||
1422 | } | ||
1423 | |||
1424 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1425 | { | ||
1426 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1427 | return; | ||
1428 | |||
1429 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1430 | Color4 texcolor; | ||
1431 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1432 | { | ||
1433 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1434 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1435 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1436 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1437 | tex.FaceTextures[face].RGBA = texcolor; | ||
1438 | part.UpdateTexture(tex); | ||
1439 | return; | ||
1440 | } | ||
1441 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1442 | { | ||
1443 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1444 | { | ||
1445 | if (tex.FaceTextures[i] != null) | ||
1446 | { | ||
1447 | texcolor = tex.FaceTextures[i].RGBA; | ||
1448 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1449 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1450 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1451 | tex.FaceTextures[i].RGBA = texcolor; | ||
1452 | } | ||
1453 | texcolor = tex.DefaultTexture.RGBA; | ||
1454 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1455 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1456 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1457 | tex.DefaultTexture.RGBA = texcolor; | ||
1458 | } | ||
1459 | part.UpdateTexture(tex); | ||
1460 | return; | ||
1461 | } | ||
1462 | |||
1349 | if (face == ScriptBaseClass.ALL_SIDES) | 1463 | if (face == ScriptBaseClass.ALL_SIDES) |
1350 | face = SceneObjectPart.ALL_SIDES; | 1464 | face = SceneObjectPart.ALL_SIDES; |
1351 | 1465 | ||
@@ -1354,6 +1468,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1354 | 1468 | ||
1355 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1469 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1356 | { | 1470 | { |
1471 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1472 | return; | ||
1473 | |||
1357 | Primitive.TextureEntry tex = part.Shape.Textures; | 1474 | Primitive.TextureEntry tex = part.Shape.Textures; |
1358 | MappingType textype; | 1475 | MappingType textype; |
1359 | textype = MappingType.Default; | 1476 | textype = MappingType.Default; |
@@ -1384,6 +1501,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1384 | 1501 | ||
1385 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1502 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1386 | { | 1503 | { |
1504 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1505 | return; | ||
1506 | |||
1387 | Primitive.TextureEntry tex = part.Shape.Textures; | 1507 | Primitive.TextureEntry tex = part.Shape.Textures; |
1388 | if (face >= 0 && face < GetNumberOfSides(part)) | 1508 | if (face >= 0 && face < GetNumberOfSides(part)) |
1389 | { | 1509 | { |
@@ -1409,6 +1529,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1409 | 1529 | ||
1410 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1530 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1411 | { | 1531 | { |
1532 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1533 | return; | ||
1412 | 1534 | ||
1413 | Shininess sval = new Shininess(); | 1535 | Shininess sval = new Shininess(); |
1414 | 1536 | ||
@@ -1459,6 +1581,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1459 | 1581 | ||
1460 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1582 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1461 | { | 1583 | { |
1584 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1585 | return; | ||
1586 | |||
1462 | Primitive.TextureEntry tex = part.Shape.Textures; | 1587 | Primitive.TextureEntry tex = part.Shape.Textures; |
1463 | if (face >= 0 && face < GetNumberOfSides(part)) | 1588 | if (face >= 0 && face < GetNumberOfSides(part)) |
1464 | { | 1589 | { |
@@ -1526,6 +1651,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1526 | 1651 | ||
1527 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1652 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1528 | { | 1653 | { |
1654 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1655 | return; | ||
1656 | |||
1529 | Primitive.TextureEntry tex = part.Shape.Textures; | 1657 | Primitive.TextureEntry tex = part.Shape.Textures; |
1530 | Color4 texcolor; | 1658 | Color4 texcolor; |
1531 | if (face >= 0 && face < GetNumberOfSides(part)) | 1659 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1571,7 +1699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1571 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1699 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1572 | float wind, float tension, LSL_Vector Force) | 1700 | float wind, float tension, LSL_Vector Force) |
1573 | { | 1701 | { |
1574 | if (part == null) | 1702 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1575 | return; | 1703 | return; |
1576 | 1704 | ||
1577 | if (flexi) | 1705 | if (flexi) |
@@ -1606,7 +1734,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1606 | /// <param name="falloff"></param> | 1734 | /// <param name="falloff"></param> |
1607 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1735 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1608 | { | 1736 | { |
1609 | if (part == null) | 1737 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1610 | return; | 1738 | return; |
1611 | 1739 | ||
1612 | if (light) | 1740 | if (light) |
@@ -1692,6 +1820,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1692 | 1820 | ||
1693 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1821 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1694 | { | 1822 | { |
1823 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1824 | return; | ||
1825 | |||
1695 | UUID textureID=new UUID(); | 1826 | UUID textureID=new UUID(); |
1696 | 1827 | ||
1697 | if (!UUID.TryParse(texture, out textureID)) | 1828 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1737,6 +1868,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1737 | 1868 | ||
1738 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1869 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1739 | { | 1870 | { |
1871 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1872 | return; | ||
1873 | |||
1740 | Primitive.TextureEntry tex = part.Shape.Textures; | 1874 | Primitive.TextureEntry tex = part.Shape.Textures; |
1741 | if (face >= 0 && face < GetNumberOfSides(part)) | 1875 | if (face >= 0 && face < GetNumberOfSides(part)) |
1742 | { | 1876 | { |
@@ -1773,6 +1907,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1773 | 1907 | ||
1774 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1908 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1775 | { | 1909 | { |
1910 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1911 | return; | ||
1912 | |||
1776 | Primitive.TextureEntry tex = part.Shape.Textures; | 1913 | Primitive.TextureEntry tex = part.Shape.Textures; |
1777 | if (face >= 0 && face < GetNumberOfSides(part)) | 1914 | if (face >= 0 && face < GetNumberOfSides(part)) |
1778 | { | 1915 | { |
@@ -1809,6 +1946,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1809 | 1946 | ||
1810 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1947 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1811 | { | 1948 | { |
1949 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1950 | return; | ||
1951 | |||
1812 | Primitive.TextureEntry tex = part.Shape.Textures; | 1952 | Primitive.TextureEntry tex = part.Shape.Textures; |
1813 | if (face >= 0 && face < GetNumberOfSides(part)) | 1953 | if (face >= 0 && face < GetNumberOfSides(part)) |
1814 | { | 1954 | { |
@@ -1879,6 +2019,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1879 | 2019 | ||
1880 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2020 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1881 | { | 2021 | { |
2022 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2023 | return; | ||
2024 | |||
1882 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2025 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1883 | LSL_Vector currentPos = llGetLocalPos(); | 2026 | LSL_Vector currentPos = llGetLocalPos(); |
1884 | 2027 | ||
@@ -1973,6 +2116,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1973 | 2116 | ||
1974 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2117 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1975 | { | 2118 | { |
2119 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2120 | return; | ||
2121 | |||
1976 | part.UpdateRotation(rot); | 2122 | part.UpdateRotation(rot); |
1977 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2123 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1978 | 2124 | ||
@@ -2592,12 +2738,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2592 | 2738 | ||
2593 | m_host.AddScriptLPS(1); | 2739 | m_host.AddScriptLPS(1); |
2594 | 2740 | ||
2741 | m_host.TaskInventory.LockItemsForRead(true); | ||
2595 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2742 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2596 | 2743 | m_host.TaskInventory.LockItemsForRead(false); | |
2597 | lock (m_host.TaskInventory) | ||
2598 | { | ||
2599 | item = m_host.TaskInventory[invItemID]; | ||
2600 | } | ||
2601 | 2744 | ||
2602 | if (item.PermsGranter == UUID.Zero) | 2745 | if (item.PermsGranter == UUID.Zero) |
2603 | return 0; | 2746 | return 0; |
@@ -2672,6 +2815,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2672 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2815 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2673 | return; | 2816 | return; |
2674 | 2817 | ||
2818 | //Clone is thread-safe | ||
2675 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2819 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2676 | 2820 | ||
2677 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2821 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2732,6 +2876,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2732 | 2876 | ||
2733 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2877 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2734 | { | 2878 | { |
2879 | /* | ||
2735 | m_host.AddScriptLPS(1); | 2880 | m_host.AddScriptLPS(1); |
2736 | // Determine where we are looking from | 2881 | // Determine where we are looking from |
2737 | LSL_Vector from = llGetPos(); | 2882 | LSL_Vector from = llGetPos(); |
@@ -2751,10 +2896,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2751 | // the angles of rotation in radians into rotation value | 2896 | // the angles of rotation in radians into rotation value |
2752 | 2897 | ||
2753 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2898 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2754 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2899 | |
2755 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2900 | // This would only work if your physics system contains an APID controller: |
2901 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2902 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2903 | |||
2756 | // Orient the object to the angle calculated | 2904 | // Orient the object to the angle calculated |
2757 | //llSetRot(rot); | 2905 | llSetRot(rot); |
2906 | */ | ||
2907 | |||
2908 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2909 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2910 | // http://bugs.meta7.com/view.php?id=28 | ||
2911 | // - Tom | ||
2912 | |||
2913 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2914 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2915 | |||
2916 | } | ||
2917 | |||
2918 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2919 | { | ||
2920 | m_host.AddScriptLPS(1); | ||
2921 | // NotImplemented("llRotLookAt"); | ||
2922 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2923 | |||
2758 | } | 2924 | } |
2759 | 2925 | ||
2760 | public void llStopLookAt() | 2926 | public void llStopLookAt() |
@@ -2803,13 +2969,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2803 | { | 2969 | { |
2804 | TaskInventoryItem item; | 2970 | TaskInventoryItem item; |
2805 | 2971 | ||
2806 | lock (m_host.TaskInventory) | 2972 | m_host.TaskInventory.LockItemsForRead(true); |
2973 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2807 | { | 2974 | { |
2808 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2975 | m_host.TaskInventory.LockItemsForRead(false); |
2809 | return; | 2976 | return; |
2810 | else | ||
2811 | item = m_host.TaskInventory[InventorySelf()]; | ||
2812 | } | 2977 | } |
2978 | else | ||
2979 | { | ||
2980 | item = m_host.TaskInventory[InventorySelf()]; | ||
2981 | } | ||
2982 | m_host.TaskInventory.LockItemsForRead(false); | ||
2813 | 2983 | ||
2814 | if (item.PermsGranter != UUID.Zero) | 2984 | if (item.PermsGranter != UUID.Zero) |
2815 | { | 2985 | { |
@@ -2831,13 +3001,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2831 | { | 3001 | { |
2832 | TaskInventoryItem item; | 3002 | TaskInventoryItem item; |
2833 | 3003 | ||
3004 | m_host.TaskInventory.LockItemsForRead(true); | ||
2834 | lock (m_host.TaskInventory) | 3005 | lock (m_host.TaskInventory) |
2835 | { | 3006 | { |
3007 | |||
2836 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3008 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3009 | { | ||
3010 | m_host.TaskInventory.LockItemsForRead(false); | ||
2837 | return; | 3011 | return; |
3012 | } | ||
2838 | else | 3013 | else |
3014 | { | ||
2839 | item = m_host.TaskInventory[InventorySelf()]; | 3015 | item = m_host.TaskInventory[InventorySelf()]; |
3016 | } | ||
2840 | } | 3017 | } |
3018 | m_host.TaskInventory.LockItemsForRead(false); | ||
2841 | 3019 | ||
2842 | m_host.AddScriptLPS(1); | 3020 | m_host.AddScriptLPS(1); |
2843 | 3021 | ||
@@ -2874,14 +3052,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2874 | 3052 | ||
2875 | TaskInventoryItem item; | 3053 | TaskInventoryItem item; |
2876 | 3054 | ||
2877 | lock (m_host.TaskInventory) | 3055 | m_host.TaskInventory.LockItemsForRead(true); |
3056 | |||
3057 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2878 | { | 3058 | { |
2879 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3059 | m_host.TaskInventory.LockItemsForRead(false); |
2880 | return; | 3060 | return; |
2881 | else | 3061 | } |
2882 | item = m_host.TaskInventory[InventorySelf()]; | 3062 | else |
3063 | { | ||
3064 | item = m_host.TaskInventory[InventorySelf()]; | ||
2883 | } | 3065 | } |
2884 | 3066 | ||
3067 | m_host.TaskInventory.LockItemsForRead(false); | ||
3068 | |||
2885 | if (item.PermsGranter != m_host.OwnerID) | 3069 | if (item.PermsGranter != m_host.OwnerID) |
2886 | return; | 3070 | return; |
2887 | 3071 | ||
@@ -2906,13 +3090,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2906 | 3090 | ||
2907 | TaskInventoryItem item; | 3091 | TaskInventoryItem item; |
2908 | 3092 | ||
2909 | lock (m_host.TaskInventory) | 3093 | m_host.TaskInventory.LockItemsForRead(true); |
3094 | |||
3095 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2910 | { | 3096 | { |
2911 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3097 | m_host.TaskInventory.LockItemsForRead(false); |
2912 | return; | 3098 | return; |
2913 | else | ||
2914 | item = m_host.TaskInventory[InventorySelf()]; | ||
2915 | } | 3099 | } |
3100 | else | ||
3101 | { | ||
3102 | item = m_host.TaskInventory[InventorySelf()]; | ||
3103 | } | ||
3104 | m_host.TaskInventory.LockItemsForRead(false); | ||
3105 | |||
2916 | 3106 | ||
2917 | if (item.PermsGranter != m_host.OwnerID) | 3107 | if (item.PermsGranter != m_host.OwnerID) |
2918 | return; | 3108 | return; |
@@ -2948,8 +3138,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | return m_host.OwnerID.ToString(); | 3138 | return m_host.OwnerID.ToString(); |
2949 | } | 3139 | } |
2950 | 3140 | ||
3141 | [DebuggerNonUserCode] | ||
2951 | public void llInstantMessage(string user, string message) | 3142 | public void llInstantMessage(string user, string message) |
2952 | { | 3143 | { |
3144 | UUID result; | ||
3145 | if (!UUID.TryParse(user, out result)) | ||
3146 | { | ||
3147 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3148 | return; | ||
3149 | } | ||
3150 | |||
3151 | |||
2953 | m_host.AddScriptLPS(1); | 3152 | m_host.AddScriptLPS(1); |
2954 | 3153 | ||
2955 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3154 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2964,7 +3163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2964 | UUID friendTransactionID = UUID.Random(); | 3163 | UUID friendTransactionID = UUID.Random(); |
2965 | 3164 | ||
2966 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3165 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2967 | 3166 | ||
2968 | GridInstantMessage msg = new GridInstantMessage(); | 3167 | GridInstantMessage msg = new GridInstantMessage(); |
2969 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3168 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2970 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3169 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3113,13 +3312,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3113 | m_host.AddScriptLPS(1); | 3312 | m_host.AddScriptLPS(1); |
3114 | } | 3313 | } |
3115 | 3314 | ||
3116 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3117 | { | ||
3118 | m_host.AddScriptLPS(1); | ||
3119 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3120 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3121 | } | ||
3122 | |||
3123 | public LSL_Integer llStringLength(string str) | 3315 | public LSL_Integer llStringLength(string str) |
3124 | { | 3316 | { |
3125 | m_host.AddScriptLPS(1); | 3317 | m_host.AddScriptLPS(1); |
@@ -3143,14 +3335,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3143 | 3335 | ||
3144 | TaskInventoryItem item; | 3336 | TaskInventoryItem item; |
3145 | 3337 | ||
3146 | lock (m_host.TaskInventory) | 3338 | m_host.TaskInventory.LockItemsForRead(true); |
3339 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3147 | { | 3340 | { |
3148 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3341 | m_host.TaskInventory.LockItemsForRead(false); |
3149 | return; | 3342 | return; |
3150 | else | ||
3151 | item = m_host.TaskInventory[InventorySelf()]; | ||
3152 | } | 3343 | } |
3153 | 3344 | else | |
3345 | { | ||
3346 | item = m_host.TaskInventory[InventorySelf()]; | ||
3347 | } | ||
3348 | m_host.TaskInventory.LockItemsForRead(false); | ||
3154 | if (item.PermsGranter == UUID.Zero) | 3349 | if (item.PermsGranter == UUID.Zero) |
3155 | return; | 3350 | return; |
3156 | 3351 | ||
@@ -3180,13 +3375,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3180 | 3375 | ||
3181 | TaskInventoryItem item; | 3376 | TaskInventoryItem item; |
3182 | 3377 | ||
3183 | lock (m_host.TaskInventory) | 3378 | m_host.TaskInventory.LockItemsForRead(true); |
3379 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3184 | { | 3380 | { |
3185 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3381 | m_host.TaskInventory.LockItemsForRead(false); |
3186 | return; | 3382 | return; |
3187 | else | ||
3188 | item = m_host.TaskInventory[InventorySelf()]; | ||
3189 | } | 3383 | } |
3384 | else | ||
3385 | { | ||
3386 | item = m_host.TaskInventory[InventorySelf()]; | ||
3387 | } | ||
3388 | m_host.TaskInventory.LockItemsForRead(false); | ||
3389 | |||
3190 | 3390 | ||
3191 | if (item.PermsGranter == UUID.Zero) | 3391 | if (item.PermsGranter == UUID.Zero) |
3192 | return; | 3392 | return; |
@@ -3263,10 +3463,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3263 | 3463 | ||
3264 | TaskInventoryItem item; | 3464 | TaskInventoryItem item; |
3265 | 3465 | ||
3266 | lock (m_host.TaskInventory) | 3466 | |
3467 | m_host.TaskInventory.LockItemsForRead(true); | ||
3468 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3469 | { | ||
3470 | m_host.TaskInventory.LockItemsForRead(false); | ||
3471 | return; | ||
3472 | } | ||
3473 | else | ||
3267 | { | 3474 | { |
3268 | item = m_host.TaskInventory[invItemID]; | 3475 | item = m_host.TaskInventory[invItemID]; |
3269 | } | 3476 | } |
3477 | m_host.TaskInventory.LockItemsForRead(false); | ||
3270 | 3478 | ||
3271 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3479 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3272 | { | 3480 | { |
@@ -3298,11 +3506,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3298 | 3506 | ||
3299 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3507 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3300 | { | 3508 | { |
3301 | lock (m_host.TaskInventory) | 3509 | m_host.TaskInventory.LockItemsForWrite(true); |
3302 | { | 3510 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3303 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3511 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3304 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3512 | m_host.TaskInventory.LockItemsForWrite(false); |
3305 | } | ||
3306 | 3513 | ||
3307 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3514 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3308 | "run_time_permissions", new Object[] { | 3515 | "run_time_permissions", new Object[] { |
@@ -3322,11 +3529,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3322 | 3529 | ||
3323 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3530 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3324 | { | 3531 | { |
3325 | lock (m_host.TaskInventory) | 3532 | m_host.TaskInventory.LockItemsForWrite(true); |
3326 | { | 3533 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3327 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3534 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3328 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3535 | m_host.TaskInventory.LockItemsForWrite(false); |
3329 | } | ||
3330 | 3536 | ||
3331 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3537 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3332 | "run_time_permissions", new Object[] { | 3538 | "run_time_permissions", new Object[] { |
@@ -3347,11 +3553,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3347 | 3553 | ||
3348 | if (!m_waitingForScriptAnswer) | 3554 | if (!m_waitingForScriptAnswer) |
3349 | { | 3555 | { |
3350 | lock (m_host.TaskInventory) | 3556 | m_host.TaskInventory.LockItemsForWrite(true); |
3351 | { | 3557 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3352 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3558 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3353 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3559 | m_host.TaskInventory.LockItemsForWrite(false); |
3354 | } | ||
3355 | 3560 | ||
3356 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3561 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3357 | m_waitingForScriptAnswer=true; | 3562 | m_waitingForScriptAnswer=true; |
@@ -3386,10 +3591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3386 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3591 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3387 | llReleaseControls(); | 3592 | llReleaseControls(); |
3388 | 3593 | ||
3389 | lock (m_host.TaskInventory) | 3594 | |
3390 | { | 3595 | m_host.TaskInventory.LockItemsForWrite(true); |
3391 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3596 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3392 | } | 3597 | m_host.TaskInventory.LockItemsForWrite(false); |
3598 | |||
3393 | 3599 | ||
3394 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3600 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3395 | "run_time_permissions", new Object[] { | 3601 | "run_time_permissions", new Object[] { |
@@ -3401,16 +3607,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3401 | { | 3607 | { |
3402 | m_host.AddScriptLPS(1); | 3608 | m_host.AddScriptLPS(1); |
3403 | 3609 | ||
3404 | lock (m_host.TaskInventory) | 3610 | m_host.TaskInventory.LockItemsForRead(true); |
3611 | |||
3612 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3405 | { | 3613 | { |
3406 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3614 | if (item.Type == 10 && item.ItemID == m_itemID) |
3407 | { | 3615 | { |
3408 | if (item.Type == 10 && item.ItemID == m_itemID) | 3616 | m_host.TaskInventory.LockItemsForRead(false); |
3409 | { | 3617 | return item.PermsGranter.ToString(); |
3410 | return item.PermsGranter.ToString(); | ||
3411 | } | ||
3412 | } | 3618 | } |
3413 | } | 3619 | } |
3620 | m_host.TaskInventory.LockItemsForRead(false); | ||
3414 | 3621 | ||
3415 | return UUID.Zero.ToString(); | 3622 | return UUID.Zero.ToString(); |
3416 | } | 3623 | } |
@@ -3419,19 +3626,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3419 | { | 3626 | { |
3420 | m_host.AddScriptLPS(1); | 3627 | m_host.AddScriptLPS(1); |
3421 | 3628 | ||
3422 | lock (m_host.TaskInventory) | 3629 | m_host.TaskInventory.LockItemsForRead(true); |
3630 | |||
3631 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3423 | { | 3632 | { |
3424 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3633 | if (item.Type == 10 && item.ItemID == m_itemID) |
3425 | { | 3634 | { |
3426 | if (item.Type == 10 && item.ItemID == m_itemID) | 3635 | int perms = item.PermsMask; |
3427 | { | 3636 | if (m_automaticLinkPermission) |
3428 | int perms = item.PermsMask; | 3637 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3429 | if (m_automaticLinkPermission) | 3638 | m_host.TaskInventory.LockItemsForRead(false); |
3430 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3639 | return perms; |
3431 | return perms; | ||
3432 | } | ||
3433 | } | 3640 | } |
3434 | } | 3641 | } |
3642 | m_host.TaskInventory.LockItemsForRead(false); | ||
3435 | 3643 | ||
3436 | return 0; | 3644 | return 0; |
3437 | } | 3645 | } |
@@ -3464,11 +3672,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3464 | UUID invItemID = InventorySelf(); | 3672 | UUID invItemID = InventorySelf(); |
3465 | 3673 | ||
3466 | TaskInventoryItem item; | 3674 | TaskInventoryItem item; |
3467 | lock (m_host.TaskInventory) | 3675 | m_host.TaskInventory.LockItemsForRead(true); |
3468 | { | 3676 | item = m_host.TaskInventory[invItemID]; |
3469 | item = m_host.TaskInventory[invItemID]; | 3677 | m_host.TaskInventory.LockItemsForRead(false); |
3470 | } | 3678 | |
3471 | |||
3472 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3679 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3473 | && !m_automaticLinkPermission) | 3680 | && !m_automaticLinkPermission) |
3474 | { | 3681 | { |
@@ -3521,16 +3728,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3521 | m_host.AddScriptLPS(1); | 3728 | m_host.AddScriptLPS(1); |
3522 | UUID invItemID = InventorySelf(); | 3729 | UUID invItemID = InventorySelf(); |
3523 | 3730 | ||
3524 | lock (m_host.TaskInventory) | 3731 | m_host.TaskInventory.LockItemsForRead(true); |
3525 | { | ||
3526 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3732 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3527 | && !m_automaticLinkPermission) | 3733 | && !m_automaticLinkPermission) |
3528 | { | 3734 | { |
3529 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3735 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3736 | m_host.TaskInventory.LockItemsForRead(false); | ||
3530 | return; | 3737 | return; |
3531 | } | 3738 | } |
3532 | } | 3739 | m_host.TaskInventory.LockItemsForRead(false); |
3533 | 3740 | ||
3534 | if (linknum < ScriptBaseClass.LINK_THIS) | 3741 | if (linknum < ScriptBaseClass.LINK_THIS) |
3535 | return; | 3742 | return; |
3536 | 3743 | ||
@@ -3707,17 +3914,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3707 | m_host.AddScriptLPS(1); | 3914 | m_host.AddScriptLPS(1); |
3708 | int count = 0; | 3915 | int count = 0; |
3709 | 3916 | ||
3710 | lock (m_host.TaskInventory) | 3917 | m_host.TaskInventory.LockItemsForRead(true); |
3918 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3711 | { | 3919 | { |
3712 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3920 | if (inv.Value.Type == type || type == -1) |
3713 | { | 3921 | { |
3714 | if (inv.Value.Type == type || type == -1) | 3922 | count = count + 1; |
3715 | { | ||
3716 | count = count + 1; | ||
3717 | } | ||
3718 | } | 3923 | } |
3719 | } | 3924 | } |
3720 | 3925 | ||
3926 | m_host.TaskInventory.LockItemsForRead(false); | ||
3721 | return count; | 3927 | return count; |
3722 | } | 3928 | } |
3723 | 3929 | ||
@@ -3726,16 +3932,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3726 | m_host.AddScriptLPS(1); | 3932 | m_host.AddScriptLPS(1); |
3727 | ArrayList keys = new ArrayList(); | 3933 | ArrayList keys = new ArrayList(); |
3728 | 3934 | ||
3729 | lock (m_host.TaskInventory) | 3935 | m_host.TaskInventory.LockItemsForRead(true); |
3936 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3730 | { | 3937 | { |
3731 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3938 | if (inv.Value.Type == type || type == -1) |
3732 | { | 3939 | { |
3733 | if (inv.Value.Type == type || type == -1) | 3940 | keys.Add(inv.Value.Name); |
3734 | { | ||
3735 | keys.Add(inv.Value.Name); | ||
3736 | } | ||
3737 | } | 3941 | } |
3738 | } | 3942 | } |
3943 | m_host.TaskInventory.LockItemsForRead(false); | ||
3739 | 3944 | ||
3740 | if (keys.Count == 0) | 3945 | if (keys.Count == 0) |
3741 | { | 3946 | { |
@@ -3772,20 +3977,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3772 | } | 3977 | } |
3773 | 3978 | ||
3774 | // move the first object found with this inventory name | 3979 | // move the first object found with this inventory name |
3775 | lock (m_host.TaskInventory) | 3980 | m_host.TaskInventory.LockItemsForRead(true); |
3981 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3776 | { | 3982 | { |
3777 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3983 | if (inv.Value.Name == inventory) |
3778 | { | 3984 | { |
3779 | if (inv.Value.Name == inventory) | 3985 | found = true; |
3780 | { | 3986 | objId = inv.Key; |
3781 | found = true; | 3987 | assetType = inv.Value.Type; |
3782 | objId = inv.Key; | 3988 | objName = inv.Value.Name; |
3783 | assetType = inv.Value.Type; | 3989 | break; |
3784 | objName = inv.Value.Name; | ||
3785 | break; | ||
3786 | } | ||
3787 | } | 3990 | } |
3788 | } | 3991 | } |
3992 | m_host.TaskInventory.LockItemsForRead(false); | ||
3789 | 3993 | ||
3790 | if (!found) | 3994 | if (!found) |
3791 | { | 3995 | { |
@@ -3821,33 +4025,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3821 | 4025 | ||
3822 | if (m_TransferModule != null) | 4026 | if (m_TransferModule != null) |
3823 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4027 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4028 | |||
4029 | //This delay should only occur when giving inventory to avatars. | ||
4030 | ScriptSleep(3000); | ||
3824 | } | 4031 | } |
3825 | else | 4032 | else |
3826 | { | 4033 | { |
3827 | // destination is an object | 4034 | // destination is an object |
3828 | World.MoveTaskInventoryItem(destId, m_host, objId); | 4035 | World.MoveTaskInventoryItem(destId, m_host, objId); |
3829 | } | 4036 | } |
3830 | ScriptSleep(3000); | 4037 | |
3831 | } | 4038 | } |
3832 | 4039 | ||
4040 | [DebuggerNonUserCode] | ||
3833 | public void llRemoveInventory(string name) | 4041 | public void llRemoveInventory(string name) |
3834 | { | 4042 | { |
3835 | m_host.AddScriptLPS(1); | 4043 | m_host.AddScriptLPS(1); |
3836 | 4044 | ||
3837 | lock (m_host.TaskInventory) | 4045 | m_host.TaskInventory.LockItemsForRead(true); |
4046 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3838 | { | 4047 | { |
3839 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4048 | if (item.Name == name) |
3840 | { | 4049 | { |
3841 | if (item.Name == name) | 4050 | if (item.ItemID == m_itemID) |
3842 | { | 4051 | throw new ScriptDeleteException(); |
3843 | if (item.ItemID == m_itemID) | 4052 | else |
3844 | throw new ScriptDeleteException(); | 4053 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3845 | else | 4054 | |
3846 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4055 | m_host.TaskInventory.LockItemsForRead(false); |
3847 | return; | 4056 | return; |
3848 | } | ||
3849 | } | 4057 | } |
3850 | } | 4058 | } |
4059 | m_host.TaskInventory.LockItemsForRead(false); | ||
3851 | } | 4060 | } |
3852 | 4061 | ||
3853 | public void llSetText(string text, LSL_Vector color, double alpha) | 4062 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3937,6 +4146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3937 | { | 4146 | { |
3938 | m_host.AddScriptLPS(1); | 4147 | m_host.AddScriptLPS(1); |
3939 | 4148 | ||
4149 | //Clone is thread safe | ||
3940 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4150 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3941 | 4151 | ||
3942 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4152 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3990,6 +4200,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3990 | ScenePresence presence = World.GetScenePresence(agentId); | 4200 | ScenePresence presence = World.GetScenePresence(agentId); |
3991 | if (presence != null) | 4201 | if (presence != null) |
3992 | { | 4202 | { |
4203 | // agent must not be a god | ||
4204 | if (presence.GodLevel >= 200) return; | ||
4205 | |||
3993 | // agent must be over the owners land | 4206 | // agent must be over the owners land |
3994 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4207 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
3995 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4208 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4025,17 +4238,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4025 | UUID soundId = UUID.Zero; | 4238 | UUID soundId = UUID.Zero; |
4026 | if (!UUID.TryParse(impact_sound, out soundId)) | 4239 | if (!UUID.TryParse(impact_sound, out soundId)) |
4027 | { | 4240 | { |
4028 | lock (m_host.TaskInventory) | 4241 | m_host.TaskInventory.LockItemsForRead(true); |
4242 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4029 | { | 4243 | { |
4030 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4244 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4031 | { | 4245 | { |
4032 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4246 | soundId = item.AssetID; |
4033 | { | 4247 | break; |
4034 | soundId = item.AssetID; | ||
4035 | break; | ||
4036 | } | ||
4037 | } | 4248 | } |
4038 | } | 4249 | } |
4250 | m_host.TaskInventory.LockItemsForRead(false); | ||
4039 | } | 4251 | } |
4040 | m_host.CollisionSound = soundId; | 4252 | m_host.CollisionSound = soundId; |
4041 | m_host.CollisionSoundVolume = (float)impact_volume; | 4253 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4081,6 +4293,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4081 | UUID partItemID; | 4293 | UUID partItemID; |
4082 | foreach (SceneObjectPart part in parts) | 4294 | foreach (SceneObjectPart part in parts) |
4083 | { | 4295 | { |
4296 | //Clone is thread safe | ||
4084 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4297 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4085 | 4298 | ||
4086 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4299 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4295,17 +4508,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4295 | 4508 | ||
4296 | m_host.AddScriptLPS(1); | 4509 | m_host.AddScriptLPS(1); |
4297 | 4510 | ||
4298 | lock (m_host.TaskInventory) | 4511 | m_host.TaskInventory.LockItemsForRead(true); |
4512 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4299 | { | 4513 | { |
4300 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4514 | if (item.Type == 10 && item.ItemID == m_itemID) |
4301 | { | 4515 | { |
4302 | if (item.Type == 10 && item.ItemID == m_itemID) | 4516 | result = item.Name!=null?item.Name:String.Empty; |
4303 | { | 4517 | break; |
4304 | result = item.Name != null ? item.Name : String.Empty; | ||
4305 | break; | ||
4306 | } | ||
4307 | } | 4518 | } |
4308 | } | 4519 | } |
4520 | m_host.TaskInventory.LockItemsForRead(false); | ||
4309 | 4521 | ||
4310 | return result; | 4522 | return result; |
4311 | } | 4523 | } |
@@ -4458,23 +4670,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4458 | { | 4670 | { |
4459 | m_host.AddScriptLPS(1); | 4671 | m_host.AddScriptLPS(1); |
4460 | 4672 | ||
4461 | lock (m_host.TaskInventory) | 4673 | m_host.TaskInventory.LockItemsForRead(true); |
4674 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4462 | { | 4675 | { |
4463 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4676 | if (inv.Value.Name == name) |
4464 | { | 4677 | { |
4465 | if (inv.Value.Name == name) | 4678 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4466 | { | 4679 | { |
4467 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4680 | m_host.TaskInventory.LockItemsForRead(false); |
4468 | { | 4681 | return inv.Value.AssetID.ToString(); |
4469 | return inv.Value.AssetID.ToString(); | 4682 | } |
4470 | } | 4683 | else |
4471 | else | 4684 | { |
4472 | { | 4685 | m_host.TaskInventory.LockItemsForRead(false); |
4473 | return UUID.Zero.ToString(); | 4686 | return UUID.Zero.ToString(); |
4474 | } | ||
4475 | } | 4687 | } |
4476 | } | 4688 | } |
4477 | } | 4689 | } |
4690 | m_host.TaskInventory.LockItemsForRead(false); | ||
4478 | 4691 | ||
4479 | return UUID.Zero.ToString(); | 4692 | return UUID.Zero.ToString(); |
4480 | } | 4693 | } |
@@ -5060,7 +5273,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5060 | public LSL_Integer llGetRegionAgentCount() | 5273 | public LSL_Integer llGetRegionAgentCount() |
5061 | { | 5274 | { |
5062 | m_host.AddScriptLPS(1); | 5275 | m_host.AddScriptLPS(1); |
5063 | return new LSL_Integer(World.GetAvatars().Count); | 5276 | return new LSL_Integer(World.GetRootAgentCount()); |
5064 | } | 5277 | } |
5065 | 5278 | ||
5066 | public LSL_Vector llGetRegionCorner() | 5279 | public LSL_Vector llGetRegionCorner() |
@@ -5989,6 +6202,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5989 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6202 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
5990 | prules.OuterAngle = (float)tempf; | 6203 | prules.OuterAngle = (float)tempf; |
5991 | break; | 6204 | break; |
6205 | |||
6206 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6207 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6208 | prules.InnerAngle = (float)tempf; | ||
6209 | break; | ||
6210 | |||
6211 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6212 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6213 | prules.OuterAngle = (float)tempf; | ||
6214 | break; | ||
5992 | } | 6215 | } |
5993 | 6216 | ||
5994 | } | 6217 | } |
@@ -6027,14 +6250,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6027 | 6250 | ||
6028 | protected UUID GetTaskInventoryItem(string name) | 6251 | protected UUID GetTaskInventoryItem(string name) |
6029 | { | 6252 | { |
6030 | lock (m_host.TaskInventory) | 6253 | m_host.TaskInventory.LockItemsForRead(true); |
6254 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6031 | { | 6255 | { |
6032 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6256 | if (inv.Value.Name == name) |
6033 | { | 6257 | { |
6034 | if (inv.Value.Name == name) | 6258 | m_host.TaskInventory.LockItemsForRead(false); |
6035 | return inv.Key; | 6259 | return inv.Key; |
6036 | } | 6260 | } |
6037 | } | 6261 | } |
6262 | m_host.TaskInventory.LockItemsForRead(false); | ||
6038 | 6263 | ||
6039 | return UUID.Zero; | 6264 | return UUID.Zero; |
6040 | } | 6265 | } |
@@ -6362,22 +6587,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6362 | } | 6587 | } |
6363 | 6588 | ||
6364 | // copy the first script found with this inventory name | 6589 | // copy the first script found with this inventory name |
6365 | lock (m_host.TaskInventory) | 6590 | m_host.TaskInventory.LockItemsForRead(true); |
6591 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6366 | { | 6592 | { |
6367 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6593 | if (inv.Value.Name == name) |
6368 | { | 6594 | { |
6369 | if (inv.Value.Name == name) | 6595 | // make sure the object is a script |
6596 | if (10 == inv.Value.Type) | ||
6370 | { | 6597 | { |
6371 | // make sure the object is a script | 6598 | found = true; |
6372 | if (10 == inv.Value.Type) | 6599 | srcId = inv.Key; |
6373 | { | 6600 | break; |
6374 | found = true; | ||
6375 | srcId = inv.Key; | ||
6376 | break; | ||
6377 | } | ||
6378 | } | 6601 | } |
6379 | } | 6602 | } |
6380 | } | 6603 | } |
6604 | m_host.TaskInventory.LockItemsForRead(false); | ||
6381 | 6605 | ||
6382 | if (!found) | 6606 | if (!found) |
6383 | { | 6607 | { |
@@ -6461,6 +6685,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6461 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6685 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6462 | { | 6686 | { |
6463 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6687 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6688 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6689 | return shapeBlock; | ||
6464 | 6690 | ||
6465 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6691 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6466 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6692 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6531,6 +6757,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6531 | 6757 | ||
6532 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6758 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6533 | { | 6759 | { |
6760 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6761 | return; | ||
6762 | |||
6534 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6763 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6535 | 6764 | ||
6536 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6765 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6580,6 +6809,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6580 | 6809 | ||
6581 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6810 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6582 | { | 6811 | { |
6812 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6813 | return; | ||
6814 | |||
6583 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6815 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6584 | 6816 | ||
6585 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6817 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6622,6 +6854,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6622 | 6854 | ||
6623 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) | 6855 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) |
6624 | { | 6856 | { |
6857 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6858 | return; | ||
6859 | |||
6625 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6860 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6626 | 6861 | ||
6627 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6862 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6743,6 +6978,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6743 | 6978 | ||
6744 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6979 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6745 | { | 6980 | { |
6981 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6982 | return; | ||
6983 | |||
6746 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6984 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6747 | UUID sculptId; | 6985 | UUID sculptId; |
6748 | 6986 | ||
@@ -6783,7 +7021,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6783 | 7021 | ||
6784 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7022 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6785 | { | 7023 | { |
6786 | m_host.AddScriptLPS(1); | 7024 | m_host.AddScriptLPS(1); |
6787 | 7025 | ||
6788 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7026 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6789 | 7027 | ||
@@ -6798,6 +7036,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6798 | 7036 | ||
6799 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7037 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6800 | { | 7038 | { |
7039 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7040 | return; | ||
7041 | |||
6801 | int idx = 0; | 7042 | int idx = 0; |
6802 | 7043 | ||
6803 | while (idx < rules.Length) | 7044 | while (idx < rules.Length) |
@@ -7629,24 +7870,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7629 | break; | 7870 | break; |
7630 | 7871 | ||
7631 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7872 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7632 | // TODO-------------- | ||
7633 | if (remain < 1) | 7873 | if (remain < 1) |
7634 | return res; | 7874 | return res; |
7875 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7635 | 7876 | ||
7636 | face=(int)rules.GetLSLIntegerItem(idx++); | 7877 | tex = part.Shape.Textures; |
7637 | 7878 | int shiny; | |
7638 | res.Add(new LSL_Integer(0)); | 7879 | if (face == ScriptBaseClass.ALL_SIDES) |
7639 | res.Add(new LSL_Integer(0)); | 7880 | { |
7881 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7882 | { | ||
7883 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7884 | if (shinyness == Shininess.High) | ||
7885 | { | ||
7886 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7887 | } | ||
7888 | else if (shinyness == Shininess.Medium) | ||
7889 | { | ||
7890 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7891 | } | ||
7892 | else if (shinyness == Shininess.Low) | ||
7893 | { | ||
7894 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7895 | } | ||
7896 | else | ||
7897 | { | ||
7898 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7899 | } | ||
7900 | res.Add(new LSL_Integer(shiny)); | ||
7901 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7902 | } | ||
7903 | } | ||
7904 | else | ||
7905 | { | ||
7906 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7907 | if (shinyness == Shininess.High) | ||
7908 | { | ||
7909 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7910 | } | ||
7911 | else if (shinyness == Shininess.Medium) | ||
7912 | { | ||
7913 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7914 | } | ||
7915 | else if (shinyness == Shininess.Low) | ||
7916 | { | ||
7917 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7918 | } | ||
7919 | else | ||
7920 | { | ||
7921 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7922 | } | ||
7923 | res.Add(new LSL_Integer(shiny)); | ||
7924 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7925 | } | ||
7640 | break; | 7926 | break; |
7641 | 7927 | ||
7642 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7928 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7643 | // TODO-------------- | ||
7644 | if (remain < 1) | 7929 | if (remain < 1) |
7645 | return res; | 7930 | return res; |
7931 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7646 | 7932 | ||
7647 | face=(int)rules.GetLSLIntegerItem(idx++); | 7933 | tex = part.Shape.Textures; |
7648 | 7934 | int fullbright; | |
7649 | res.Add(new LSL_Integer(0)); | 7935 | if (face == ScriptBaseClass.ALL_SIDES) |
7936 | { | ||
7937 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7938 | { | ||
7939 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7940 | { | ||
7941 | fullbright = ScriptBaseClass.TRUE; | ||
7942 | } | ||
7943 | else | ||
7944 | { | ||
7945 | fullbright = ScriptBaseClass.FALSE; | ||
7946 | } | ||
7947 | res.Add(new LSL_Integer(fullbright)); | ||
7948 | } | ||
7949 | } | ||
7950 | else | ||
7951 | { | ||
7952 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7953 | { | ||
7954 | fullbright = ScriptBaseClass.TRUE; | ||
7955 | } | ||
7956 | else | ||
7957 | { | ||
7958 | fullbright = ScriptBaseClass.FALSE; | ||
7959 | } | ||
7960 | res.Add(new LSL_Integer(fullbright)); | ||
7961 | } | ||
7650 | break; | 7962 | break; |
7651 | 7963 | ||
7652 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7964 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7667,14 +7979,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7667 | break; | 7979 | break; |
7668 | 7980 | ||
7669 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 7981 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7670 | // TODO-------------- | ||
7671 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 7982 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7672 | if (remain < 1) | 7983 | if (remain < 1) |
7673 | return res; | 7984 | return res; |
7985 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7674 | 7986 | ||
7675 | face=(int)rules.GetLSLIntegerItem(idx++); | 7987 | tex = part.Shape.Textures; |
7676 | 7988 | if (face == ScriptBaseClass.ALL_SIDES) | |
7677 | res.Add(new LSL_Integer(0)); | 7989 | { |
7990 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7991 | { | ||
7992 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
7993 | { | ||
7994 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
7995 | } | ||
7996 | else | ||
7997 | { | ||
7998 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
7999 | } | ||
8000 | } | ||
8001 | } | ||
8002 | else | ||
8003 | { | ||
8004 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8005 | { | ||
8006 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8007 | } | ||
8008 | else | ||
8009 | { | ||
8010 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8011 | } | ||
8012 | } | ||
7678 | break; | 8013 | break; |
7679 | 8014 | ||
7680 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8015 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7693,13 +8028,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7693 | break; | 8028 | break; |
7694 | 8029 | ||
7695 | case (int)ScriptBaseClass.PRIM_GLOW: | 8030 | case (int)ScriptBaseClass.PRIM_GLOW: |
7696 | // TODO-------------- | ||
7697 | if (remain < 1) | 8031 | if (remain < 1) |
7698 | return res; | 8032 | return res; |
8033 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7699 | 8034 | ||
7700 | face=(int)rules.GetLSLIntegerItem(idx++); | 8035 | tex = part.Shape.Textures; |
7701 | 8036 | float primglow; | |
7702 | res.Add(new LSL_Float(0)); | 8037 | if (face == ScriptBaseClass.ALL_SIDES) |
8038 | { | ||
8039 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8040 | { | ||
8041 | primglow = tex.GetFace((uint)face).Glow; | ||
8042 | res.Add(new LSL_Float(primglow)); | ||
8043 | } | ||
8044 | } | ||
8045 | else | ||
8046 | { | ||
8047 | primglow = tex.GetFace((uint)face).Glow; | ||
8048 | res.Add(new LSL_Float(primglow)); | ||
8049 | } | ||
7703 | break; | 8050 | break; |
7704 | case (int)ScriptBaseClass.PRIM_TEXT: | 8051 | case (int)ScriptBaseClass.PRIM_TEXT: |
7705 | Color4 textColor = part.GetTextColor(); | 8052 | Color4 textColor = part.GetTextColor(); |
@@ -8236,28 +8583,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8236 | { | 8583 | { |
8237 | m_host.AddScriptLPS(1); | 8584 | m_host.AddScriptLPS(1); |
8238 | 8585 | ||
8239 | lock (m_host.TaskInventory) | 8586 | m_host.TaskInventory.LockItemsForRead(true); |
8587 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8240 | { | 8588 | { |
8241 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8589 | if (inv.Value.Name == item) |
8242 | { | 8590 | { |
8243 | if (inv.Value.Name == item) | 8591 | m_host.TaskInventory.LockItemsForRead(false); |
8592 | switch (mask) | ||
8244 | { | 8593 | { |
8245 | switch (mask) | 8594 | case 0: |
8246 | { | 8595 | return (int)inv.Value.BasePermissions; |
8247 | case 0: | 8596 | case 1: |
8248 | return (int)inv.Value.BasePermissions; | 8597 | return (int)inv.Value.CurrentPermissions; |
8249 | case 1: | 8598 | case 2: |
8250 | return (int)inv.Value.CurrentPermissions; | 8599 | return (int)inv.Value.GroupPermissions; |
8251 | case 2: | 8600 | case 3: |
8252 | return (int)inv.Value.GroupPermissions; | 8601 | return (int)inv.Value.EveryonePermissions; |
8253 | case 3: | 8602 | case 4: |
8254 | return (int)inv.Value.EveryonePermissions; | 8603 | return (int)inv.Value.NextPermissions; |
8255 | case 4: | ||
8256 | return (int)inv.Value.NextPermissions; | ||
8257 | } | ||
8258 | } | 8604 | } |
8259 | } | 8605 | } |
8260 | } | 8606 | } |
8607 | m_host.TaskInventory.LockItemsForRead(false); | ||
8261 | 8608 | ||
8262 | return -1; | 8609 | return -1; |
8263 | } | 8610 | } |
@@ -8304,16 +8651,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8304 | { | 8651 | { |
8305 | m_host.AddScriptLPS(1); | 8652 | m_host.AddScriptLPS(1); |
8306 | 8653 | ||
8307 | lock (m_host.TaskInventory) | 8654 | m_host.TaskInventory.LockItemsForRead(true); |
8655 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8308 | { | 8656 | { |
8309 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8657 | if (inv.Value.Name == item) |
8310 | { | 8658 | { |
8311 | if (inv.Value.Name == item) | 8659 | m_host.TaskInventory.LockItemsForRead(false); |
8312 | { | 8660 | return inv.Value.CreatorID.ToString(); |
8313 | return inv.Value.CreatorID.ToString(); | ||
8314 | } | ||
8315 | } | 8661 | } |
8316 | } | 8662 | } |
8663 | m_host.TaskInventory.LockItemsForRead(false); | ||
8317 | 8664 | ||
8318 | llSay(0, "No item name '" + item + "'"); | 8665 | llSay(0, "No item name '" + item + "'"); |
8319 | 8666 | ||
@@ -8573,17 +8920,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8573 | int width = 0; | 8920 | int width = 0; |
8574 | int height = 0; | 8921 | int height = 0; |
8575 | 8922 | ||
8576 | ParcelMediaCommandEnum? commandToSend = null; | 8923 | uint commandToSend = 0; |
8577 | float time = 0.0f; // default is from start | 8924 | float time = 0.0f; // default is from start |
8578 | 8925 | ||
8579 | ScenePresence presence = null; | 8926 | ScenePresence presence = null; |
8580 | 8927 | ||
8581 | for (int i = 0; i < commandList.Data.Length; i++) | 8928 | for (int i = 0; i < commandList.Data.Length; i++) |
8582 | { | 8929 | { |
8583 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 8930 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8584 | switch (command) | 8931 | switch (command) |
8585 | { | 8932 | { |
8586 | case ParcelMediaCommandEnum.Agent: | 8933 | case (uint)ParcelMediaCommandEnum.Agent: |
8587 | // we send only to one agent | 8934 | // we send only to one agent |
8588 | if ((i + 1) < commandList.Length) | 8935 | if ((i + 1) < commandList.Length) |
8589 | { | 8936 | { |
@@ -8600,25 +8947,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8600 | } | 8947 | } |
8601 | break; | 8948 | break; |
8602 | 8949 | ||
8603 | case ParcelMediaCommandEnum.Loop: | 8950 | case (uint)ParcelMediaCommandEnum.Loop: |
8604 | loop = 1; | 8951 | loop = 1; |
8605 | commandToSend = command; | 8952 | commandToSend = command; |
8606 | update = true; //need to send the media update packet to set looping | 8953 | update = true; //need to send the media update packet to set looping |
8607 | break; | 8954 | break; |
8608 | 8955 | ||
8609 | case ParcelMediaCommandEnum.Play: | 8956 | case (uint)ParcelMediaCommandEnum.Play: |
8610 | loop = 0; | 8957 | loop = 0; |
8611 | commandToSend = command; | 8958 | commandToSend = command; |
8612 | update = true; //need to send the media update packet to make sure it doesn't loop | 8959 | update = true; //need to send the media update packet to make sure it doesn't loop |
8613 | break; | 8960 | break; |
8614 | 8961 | ||
8615 | case ParcelMediaCommandEnum.Pause: | 8962 | case (uint)ParcelMediaCommandEnum.Pause: |
8616 | case ParcelMediaCommandEnum.Stop: | 8963 | case (uint)ParcelMediaCommandEnum.Stop: |
8617 | case ParcelMediaCommandEnum.Unload: | 8964 | case (uint)ParcelMediaCommandEnum.Unload: |
8618 | commandToSend = command; | 8965 | commandToSend = command; |
8619 | break; | 8966 | break; |
8620 | 8967 | ||
8621 | case ParcelMediaCommandEnum.Url: | 8968 | case (uint)ParcelMediaCommandEnum.Url: |
8622 | if ((i + 1) < commandList.Length) | 8969 | if ((i + 1) < commandList.Length) |
8623 | { | 8970 | { |
8624 | if (commandList.Data[i + 1] is LSL_String) | 8971 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8631,7 +8978,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8631 | } | 8978 | } |
8632 | break; | 8979 | break; |
8633 | 8980 | ||
8634 | case ParcelMediaCommandEnum.Texture: | 8981 | case (uint)ParcelMediaCommandEnum.Texture: |
8635 | if ((i + 1) < commandList.Length) | 8982 | if ((i + 1) < commandList.Length) |
8636 | { | 8983 | { |
8637 | if (commandList.Data[i + 1] is LSL_String) | 8984 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8644,7 +8991,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8644 | } | 8991 | } |
8645 | break; | 8992 | break; |
8646 | 8993 | ||
8647 | case ParcelMediaCommandEnum.Time: | 8994 | case (uint)ParcelMediaCommandEnum.Time: |
8648 | if ((i + 1) < commandList.Length) | 8995 | if ((i + 1) < commandList.Length) |
8649 | { | 8996 | { |
8650 | if (commandList.Data[i + 1] is LSL_Float) | 8997 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -8656,7 +9003,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8656 | } | 9003 | } |
8657 | break; | 9004 | break; |
8658 | 9005 | ||
8659 | case ParcelMediaCommandEnum.AutoAlign: | 9006 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
8660 | if ((i + 1) < commandList.Length) | 9007 | if ((i + 1) < commandList.Length) |
8661 | { | 9008 | { |
8662 | if (commandList.Data[i + 1] is LSL_Integer) | 9009 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8670,7 +9017,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8670 | } | 9017 | } |
8671 | break; | 9018 | break; |
8672 | 9019 | ||
8673 | case ParcelMediaCommandEnum.Type: | 9020 | case (uint)ParcelMediaCommandEnum.Type: |
8674 | if ((i + 1) < commandList.Length) | 9021 | if ((i + 1) < commandList.Length) |
8675 | { | 9022 | { |
8676 | if (commandList.Data[i + 1] is LSL_String) | 9023 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8683,7 +9030,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8683 | } | 9030 | } |
8684 | break; | 9031 | break; |
8685 | 9032 | ||
8686 | case ParcelMediaCommandEnum.Desc: | 9033 | case (uint)ParcelMediaCommandEnum.Desc: |
8687 | if ((i + 1) < commandList.Length) | 9034 | if ((i + 1) < commandList.Length) |
8688 | { | 9035 | { |
8689 | if (commandList.Data[i + 1] is LSL_String) | 9036 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8696,7 +9043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8696 | } | 9043 | } |
8697 | break; | 9044 | break; |
8698 | 9045 | ||
8699 | case ParcelMediaCommandEnum.Size: | 9046 | case (uint)ParcelMediaCommandEnum.Size: |
8700 | if ((i + 2) < commandList.Length) | 9047 | if ((i + 2) < commandList.Length) |
8701 | { | 9048 | { |
8702 | if (commandList.Data[i + 1] is LSL_Integer) | 9049 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8764,7 +9111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8764 | } | 9111 | } |
8765 | } | 9112 | } |
8766 | 9113 | ||
8767 | if (commandToSend != null) | 9114 | if (commandToSend != 0) |
8768 | { | 9115 | { |
8769 | // the commandList contained a start/stop/... command, too | 9116 | // the commandList contained a start/stop/... command, too |
8770 | if (presence == null) | 9117 | if (presence == null) |
@@ -8842,16 +9189,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8842 | { | 9189 | { |
8843 | m_host.AddScriptLPS(1); | 9190 | m_host.AddScriptLPS(1); |
8844 | 9191 | ||
8845 | lock (m_host.TaskInventory) | 9192 | m_host.TaskInventory.LockItemsForRead(true); |
9193 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8846 | { | 9194 | { |
8847 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9195 | if (inv.Value.Name == name) |
8848 | { | 9196 | { |
8849 | if (inv.Value.Name == name) | 9197 | m_host.TaskInventory.LockItemsForRead(false); |
8850 | { | 9198 | return inv.Value.Type; |
8851 | return inv.Value.Type; | ||
8852 | } | ||
8853 | } | 9199 | } |
8854 | } | 9200 | } |
9201 | m_host.TaskInventory.LockItemsForRead(false); | ||
8855 | 9202 | ||
8856 | return -1; | 9203 | return -1; |
8857 | } | 9204 | } |
@@ -8862,15 +9209,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8862 | 9209 | ||
8863 | if (quick_pay_buttons.Data.Length < 4) | 9210 | if (quick_pay_buttons.Data.Length < 4) |
8864 | { | 9211 | { |
8865 | LSLError("List must have at least 4 elements"); | 9212 | int x; |
8866 | return; | 9213 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9214 | { | ||
9215 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9216 | } | ||
8867 | } | 9217 | } |
8868 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9218 | int[] nPrice = new int[5]; |
8869 | 9219 | nPrice[0]=price; | |
8870 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9220 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8871 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9221 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8872 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9222 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8873 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9223 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9224 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8874 | m_host.ParentGroup.HasGroupChanged = true; | 9225 | m_host.ParentGroup.HasGroupChanged = true; |
8875 | } | 9226 | } |
8876 | 9227 | ||
@@ -8882,17 +9233,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8882 | if (invItemID == UUID.Zero) | 9233 | if (invItemID == UUID.Zero) |
8883 | return new LSL_Vector(); | 9234 | return new LSL_Vector(); |
8884 | 9235 | ||
8885 | lock (m_host.TaskInventory) | 9236 | m_host.TaskInventory.LockItemsForRead(true); |
9237 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8886 | { | 9238 | { |
8887 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9239 | m_host.TaskInventory.LockItemsForRead(false); |
8888 | return new LSL_Vector(); | 9240 | return new LSL_Vector(); |
9241 | } | ||
8889 | 9242 | ||
8890 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9243 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8891 | { | 9244 | { |
8892 | ShoutError("No permissions to track the camera"); | 9245 | ShoutError("No permissions to track the camera"); |
8893 | return new LSL_Vector(); | 9246 | m_host.TaskInventory.LockItemsForRead(false); |
8894 | } | 9247 | return new LSL_Vector(); |
8895 | } | 9248 | } |
9249 | m_host.TaskInventory.LockItemsForRead(false); | ||
8896 | 9250 | ||
8897 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9251 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8898 | if (presence != null) | 9252 | if (presence != null) |
@@ -8910,17 +9264,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8910 | if (invItemID == UUID.Zero) | 9264 | if (invItemID == UUID.Zero) |
8911 | return new LSL_Rotation(); | 9265 | return new LSL_Rotation(); |
8912 | 9266 | ||
8913 | lock (m_host.TaskInventory) | 9267 | m_host.TaskInventory.LockItemsForRead(true); |
9268 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8914 | { | 9269 | { |
8915 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9270 | m_host.TaskInventory.LockItemsForRead(false); |
8916 | return new LSL_Rotation(); | 9271 | return new LSL_Rotation(); |
8917 | |||
8918 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8919 | { | ||
8920 | ShoutError("No permissions to track the camera"); | ||
8921 | return new LSL_Rotation(); | ||
8922 | } | ||
8923 | } | 9272 | } |
9273 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
9274 | { | ||
9275 | ShoutError("No permissions to track the camera"); | ||
9276 | m_host.TaskInventory.LockItemsForRead(false); | ||
9277 | return new LSL_Rotation(); | ||
9278 | } | ||
9279 | m_host.TaskInventory.LockItemsForRead(false); | ||
8924 | 9280 | ||
8925 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9281 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8926 | if (presence != null) | 9282 | if (presence != null) |
@@ -9070,14 +9426,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9070 | if (objectID == UUID.Zero) return; | 9426 | if (objectID == UUID.Zero) return; |
9071 | 9427 | ||
9072 | UUID agentID; | 9428 | UUID agentID; |
9073 | lock (m_host.TaskInventory) | 9429 | m_host.TaskInventory.LockItemsForRead(true); |
9074 | { | 9430 | // we need the permission first, to know which avatar we want to set the camera for |
9075 | // we need the permission first, to know which avatar we want to set the camera for | 9431 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9076 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9077 | 9432 | ||
9078 | if (agentID == UUID.Zero) return; | 9433 | if (agentID == UUID.Zero) |
9079 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9434 | { |
9435 | m_host.TaskInventory.LockItemsForRead(false); | ||
9436 | return; | ||
9437 | } | ||
9438 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9439 | { | ||
9440 | m_host.TaskInventory.LockItemsForRead(false); | ||
9441 | return; | ||
9080 | } | 9442 | } |
9443 | m_host.TaskInventory.LockItemsForRead(false); | ||
9081 | 9444 | ||
9082 | ScenePresence presence = World.GetScenePresence(agentID); | 9445 | ScenePresence presence = World.GetScenePresence(agentID); |
9083 | 9446 | ||
@@ -9127,12 +9490,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9127 | 9490 | ||
9128 | // we need the permission first, to know which avatar we want to clear the camera for | 9491 | // we need the permission first, to know which avatar we want to clear the camera for |
9129 | UUID agentID; | 9492 | UUID agentID; |
9130 | lock (m_host.TaskInventory) | 9493 | m_host.TaskInventory.LockItemsForRead(true); |
9494 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9495 | if (agentID == UUID.Zero) | ||
9131 | { | 9496 | { |
9132 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9497 | m_host.TaskInventory.LockItemsForRead(false); |
9133 | if (agentID == UUID.Zero) return; | 9498 | return; |
9134 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9135 | } | 9499 | } |
9500 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9501 | { | ||
9502 | m_host.TaskInventory.LockItemsForRead(false); | ||
9503 | return; | ||
9504 | } | ||
9505 | m_host.TaskInventory.LockItemsForRead(false); | ||
9136 | 9506 | ||
9137 | ScenePresence presence = World.GetScenePresence(agentID); | 9507 | ScenePresence presence = World.GetScenePresence(agentID); |
9138 | 9508 | ||
@@ -9589,15 +9959,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9589 | 9959 | ||
9590 | internal UUID ScriptByName(string name) | 9960 | internal UUID ScriptByName(string name) |
9591 | { | 9961 | { |
9592 | lock (m_host.TaskInventory) | 9962 | m_host.TaskInventory.LockItemsForRead(true); |
9963 | |||
9964 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9593 | { | 9965 | { |
9594 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9966 | if (item.Type == 10 && item.Name == name) |
9595 | { | 9967 | { |
9596 | if (item.Type == 10 && item.Name == name) | 9968 | m_host.TaskInventory.LockItemsForRead(false); |
9597 | return item.ItemID; | 9969 | return item.ItemID; |
9598 | } | 9970 | } |
9599 | } | 9971 | } |
9600 | 9972 | ||
9973 | m_host.TaskInventory.LockItemsForRead(false); | ||
9974 | |||
9601 | return UUID.Zero; | 9975 | return UUID.Zero; |
9602 | } | 9976 | } |
9603 | 9977 | ||
@@ -9638,6 +10012,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9638 | { | 10012 | { |
9639 | m_host.AddScriptLPS(1); | 10013 | m_host.AddScriptLPS(1); |
9640 | 10014 | ||
10015 | //Clone is thread safe | ||
9641 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10016 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9642 | 10017 | ||
9643 | UUID assetID = UUID.Zero; | 10018 | UUID assetID = UUID.Zero; |
@@ -9700,6 +10075,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9700 | { | 10075 | { |
9701 | m_host.AddScriptLPS(1); | 10076 | m_host.AddScriptLPS(1); |
9702 | 10077 | ||
10078 | //Clone is thread safe | ||
9703 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10079 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9704 | 10080 | ||
9705 | UUID assetID = UUID.Zero; | 10081 | UUID assetID = UUID.Zero; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2c8b0ea..1ddba1e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | if (target != null) | 728 | if (target != null) |
729 | { | 729 | { |
730 | UUID animID=UUID.Zero; | 730 | UUID animID=UUID.Zero; |
731 | lock (m_host.TaskInventory) | 731 | m_host.TaskInventory.LockItemsForRead(true); |
732 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
732 | { | 733 | { |
733 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 734 | if (inv.Value.Name == animation) |
734 | { | 735 | { |
735 | if (inv.Value.Name == animation) | 736 | if (inv.Value.Type == (int)AssetType.Animation) |
736 | { | 737 | animID = inv.Value.AssetID; |
737 | if (inv.Value.Type == (int)AssetType.Animation) | 738 | continue; |
738 | animID = inv.Value.AssetID; | ||
739 | continue; | ||
740 | } | ||
741 | } | 739 | } |
742 | } | 740 | } |
741 | m_host.TaskInventory.LockItemsForRead(false); | ||
743 | if (animID == UUID.Zero) | 742 | if (animID == UUID.Zero) |
744 | target.Animator.AddAnimation(animation, m_host.UUID); | 743 | target.Animator.AddAnimation(animation, m_host.UUID); |
745 | else | 744 | else |
@@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
761 | if (target != null) | 760 | if (target != null) |
762 | { | 761 | { |
763 | UUID animID=UUID.Zero; | 762 | UUID animID=UUID.Zero; |
764 | lock (m_host.TaskInventory) | 763 | m_host.TaskInventory.LockItemsForRead(true); |
764 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
765 | { | 765 | { |
766 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 766 | if (inv.Value.Name == animation) |
767 | { | 767 | { |
768 | if (inv.Value.Name == animation) | 768 | if (inv.Value.Type == (int)AssetType.Animation) |
769 | { | 769 | animID = inv.Value.AssetID; |
770 | if (inv.Value.Type == (int)AssetType.Animation) | 770 | continue; |
771 | animID = inv.Value.AssetID; | ||
772 | continue; | ||
773 | } | ||
774 | } | 771 | } |
775 | } | 772 | } |
773 | m_host.TaskInventory.LockItemsForRead(false); | ||
776 | 774 | ||
777 | if (animID == UUID.Zero) | 775 | if (animID == UUID.Zero) |
778 | target.Animator.RemoveAnimation(animation); | 776 | target.Animator.RemoveAnimation(animation); |
@@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1541 | 1539 | ||
1542 | if (!UUID.TryParse(name, out assetID)) | 1540 | if (!UUID.TryParse(name, out assetID)) |
1543 | { | 1541 | { |
1542 | m_host.TaskInventory.LockItemsForRead(true); | ||
1544 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1543 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1545 | { | 1544 | { |
1546 | if (item.Type == 7 && item.Name == name) | 1545 | if (item.Type == 7 && item.Name == name) |
@@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1548 | assetID = item.AssetID; | 1547 | assetID = item.AssetID; |
1549 | } | 1548 | } |
1550 | } | 1549 | } |
1550 | m_host.TaskInventory.LockItemsForRead(false); | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if (assetID == UUID.Zero) | 1553 | if (assetID == UUID.Zero) |
@@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1594 | 1594 | ||
1595 | if (!UUID.TryParse(name, out assetID)) | 1595 | if (!UUID.TryParse(name, out assetID)) |
1596 | { | 1596 | { |
1597 | m_host.TaskInventory.LockItemsForRead(true); | ||
1597 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1598 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1598 | { | 1599 | { |
1599 | if (item.Type == 7 && item.Name == name) | 1600 | if (item.Type == 7 && item.Name == name) |
@@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1601 | assetID = item.AssetID; | 1602 | assetID = item.AssetID; |
1602 | } | 1603 | } |
1603 | } | 1604 | } |
1605 | m_host.TaskInventory.LockItemsForRead(false); | ||
1604 | } | 1606 | } |
1605 | 1607 | ||
1606 | if (assetID == UUID.Zero) | 1608 | if (assetID == UUID.Zero) |
@@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1651 | 1653 | ||
1652 | if (!UUID.TryParse(name, out assetID)) | 1654 | if (!UUID.TryParse(name, out assetID)) |
1653 | { | 1655 | { |
1656 | m_host.TaskInventory.LockItemsForRead(true); | ||
1654 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1657 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1655 | { | 1658 | { |
1656 | if (item.Type == 7 && item.Name == name) | 1659 | if (item.Type == 7 && item.Name == name) |
@@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1658 | assetID = item.AssetID; | 1661 | assetID = item.AssetID; |
1659 | } | 1662 | } |
1660 | } | 1663 | } |
1664 | m_host.TaskInventory.LockItemsForRead(false); | ||
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | if (assetID == UUID.Zero) | 1667 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..6239726 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,22 @@ | |||
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 | LSL_List cmGetAvatarList(); | ||
21 | } | ||
22 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 60b8050..f5921e1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs new file mode 100644 index 0000000..522c020 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | public const int WL_SUN_MOON_POSITION = 36; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..aaffbe4 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,80 @@ | |||
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 | public LSL_List cmGetAvatarList() | ||
76 | { | ||
77 | return m_CM_Functions.cmGetAvatarList(); | ||
78 | } | ||
79 | } | ||
80 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 9615315..943d7a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index ee35fa4..b3e4740 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -274,6 +274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
274 | public const int CHANGED_ALLOWED_DROP = 64; | 274 | public const int CHANGED_ALLOWED_DROP = 64; |
275 | public const int CHANGED_OWNER = 128; | 275 | public const int CHANGED_OWNER = 128; |
276 | public const int CHANGED_REGION_RESTART = 256; | 276 | public const int CHANGED_REGION_RESTART = 256; |
277 | public const int CHANGED_REGION_START = 256; //LL Changed the constant from CHANGED_REGION_RESTART | ||
277 | public const int CHANGED_REGION = 512; | 278 | public const int CHANGED_REGION = 512; |
278 | public const int CHANGED_TELEPORT = 1024; | 279 | public const int CHANGED_TELEPORT = 1024; |
279 | public const int CHANGED_ANIMATION = 16384; | 280 | public const int CHANGED_ANIMATION = 16384; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 3339995..e86d08c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | using System.Threading; | 31 | using System.Threading; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -309,6 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
309 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); | 310 | m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); |
310 | } | 311 | } |
311 | 312 | ||
313 | [DebuggerNonUserCode] | ||
312 | public void llDie() | 314 | public void llDie() |
313 | { | 315 | { |
314 | m_LSL_Functions.llDie(); | 316 | m_LSL_Functions.llDie(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index 98bbc68..23138ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -17,6 +17,8 @@ | |||
17 | <excludeFiles /> | 17 | <excludeFiles /> |
18 | </DeploymentInformation> | 18 | </DeploymentInformation> |
19 | <Contents> | 19 | <Contents> |
20 | <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
21 | <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 23 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index edbbc2a..b138da3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -33,6 +33,7 @@ using System.Threading; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using System.Collections; | 34 | using System.Collections; |
35 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
36 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | 37 | using OpenSim.Region.ScriptEngine.Interfaces; |
37 | using OpenSim.Region.ScriptEngine.Shared; | 38 | using OpenSim.Region.ScriptEngine.Shared; |
38 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; | 39 | using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; |
@@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
90 | return (int)m_Executor.GetStateEventFlags(state); | 91 | return (int)m_Executor.GetStateEventFlags(state); |
91 | } | 92 | } |
92 | 93 | ||
94 | [DebuggerNonUserCode] | ||
93 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 95 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
94 | { | 96 | { |
95 | m_Executor.ExecuteEvent(state, FunctionName, args); | 97 | m_Executor.ExecuteEvent(state, FunctionName, args); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 18351ad..a299dba 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 false; | 545 | return false; |
545 | } | 546 | } |
546 | 547 | ||
548 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
547 | public void SetState(string state) | 549 | public void SetState(string state) |
548 | { | 550 | { |
549 | if (state == State) | 551 | if (state == State) |
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
555 | new DetectParams[0])); | 557 | new DetectParams[0])); |
556 | PostEvent(new EventParams("state_entry", new Object[0], | 558 | PostEvent(new EventParams("state_entry", new Object[0], |
557 | new DetectParams[0])); | 559 | new DetectParams[0])); |
558 | 560 | ||
559 | throw new EventAbortException(); | 561 | throw new EventAbortException(); |
560 | } | 562 | } |
561 | 563 | ||
@@ -638,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
638 | /// <returns></returns> | 640 | /// <returns></returns> |
639 | public object EventProcessor() | 641 | public object EventProcessor() |
640 | { | 642 | { |
643 | |||
644 | EventParams data = null; | ||
645 | |||
646 | lock (m_EventQueue) | ||
647 | { | ||
641 | lock (m_Script) | 648 | lock (m_Script) |
642 | { | 649 | { |
643 | EventParams data = null; | 650 | data = (EventParams) m_EventQueue.Dequeue(); |
644 | 651 | if (data == null) // Shouldn't happen | |
645 | lock (m_EventQueue) | ||
646 | { | 652 | { |
647 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
648 | if (data == null) // Shouldn't happen | ||
649 | { | 654 | { |
650 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
651 | { | ||
652 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_CurrentResult = null; | ||
657 | } | ||
658 | return 0; | ||
659 | } | 656 | } |
660 | 657 | else | |
661 | if (data.EventName == "timer") | ||
662 | m_TimerQueued = false; | ||
663 | if (data.EventName == "control") | ||
664 | { | 658 | { |
665 | if (m_ControlEventsInQueue > 0) | 659 | m_CurrentResult = null; |
666 | m_ControlEventsInQueue--; | ||
667 | } | 660 | } |
668 | if (data.EventName == "collision") | 661 | return 0; |
669 | m_CollisionInQueue = false; | ||
670 | } | 662 | } |
671 | |||
672 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
673 | 663 | ||
674 | m_DetectParams = data.DetectParams; | 664 | if (data.EventName == "timer") |
675 | 665 | m_TimerQueued = false; | |
676 | if (data.EventName == "state") // Hardcoded state change | 666 | if (data.EventName == "control") |
677 | { | 667 | { |
678 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 668 | if (m_ControlEventsInQueue > 0) |
679 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 669 | m_ControlEventsInQueue--; |
680 | m_State=data.Params[0].ToString(); | 670 | } |
681 | AsyncCommandManager.RemoveScript(m_Engine, | 671 | if (data.EventName == "collision") |
682 | m_LocalID, m_ItemID); | 672 | m_CollisionInQueue = false; |
673 | } | ||
674 | } | ||
675 | lock(m_Script) | ||
676 | { | ||
677 | |||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
683 | 679 | ||
684 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 680 | m_DetectParams = data.DetectParams; |
685 | m_LocalID); | 681 | |
686 | if (part != null) | 682 | if (data.EventName == "state") // Hardcoded state change |
687 | { | 683 | { |
688 | part.SetScriptEvents(m_ItemID, | 684 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
689 | (int)m_Script.GetStateEventFlags(State)); | 685 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
690 | } | 686 | m_State=data.Params[0].ToString(); |
687 | AsyncCommandManager.RemoveScript(m_Engine, | ||
688 | m_LocalID, m_ItemID); | ||
689 | |||
690 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | ||
691 | m_LocalID); | ||
692 | if (part != null) | ||
693 | { | ||
694 | part.SetScriptEvents(m_ItemID, | ||
695 | (int)m_Script.GetStateEventFlags(State)); | ||
691 | } | 696 | } |
692 | else | 697 | } |
698 | else | ||
699 | { | ||
700 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | ||
701 | data.EventName == "control") // Don't freeze avies! | ||
693 | { | 702 | { |
694 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 703 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
695 | data.EventName == "control") // Don't freeze avies! | 704 | m_LocalID); |
696 | { | 705 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
697 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 706 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
698 | m_LocalID); | ||
699 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | ||
700 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
701 | 707 | ||
702 | try | 708 | try |
703 | { | 709 | { |
704 | m_CurrentEvent = data.EventName; | 710 | m_CurrentEvent = data.EventName; |
705 | m_EventStart = DateTime.Now; | 711 | m_EventStart = DateTime.Now; |
706 | m_InEvent = true; | 712 | m_InEvent = true; |
707 | 713 | ||
708 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 714 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
709 | 715 | ||
710 | m_InEvent = false; | 716 | m_InEvent = false; |
711 | m_CurrentEvent = String.Empty; | 717 | m_CurrentEvent = String.Empty; |
712 | 718 | ||
713 | if (m_SaveState) | 719 | if (m_SaveState) |
714 | { | 720 | { |
715 | // This will be the very first event we deliver | 721 | // This will be the very first event we deliver |
716 | // (state_entry) in default state | 722 | // (state_entry) in default state |
717 | // | 723 | // |
718 | 724 | ||
719 | SaveState(m_Assembly); | 725 | SaveState(m_Assembly); |
720 | 726 | ||
721 | m_SaveState = false; | 727 | m_SaveState = false; |
722 | } | ||
723 | } | 728 | } |
724 | catch (Exception e) | 729 | } |
725 | { | 730 | catch (Exception e) |
726 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); | 731 | { |
727 | m_InEvent = false; | 732 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); |
728 | m_CurrentEvent = String.Empty; | 733 | m_InEvent = false; |
734 | m_CurrentEvent = String.Empty; | ||
729 | 735 | ||
730 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 736 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) |
731 | { | 737 | { |
732 | try | 738 | try |
733 | { | ||
734 | // DISPLAY ERROR INWORLD | ||
735 | string text = FormatException(e); | ||
736 | |||
737 | if (text.Length > 1000) | ||
738 | text = text.Substring(0, 1000); | ||
739 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
740 | ChatTypeEnum.DebugChannel, 2147483647, | ||
741 | part.AbsolutePosition, | ||
742 | part.Name, part.UUID, false); | ||
743 | } | ||
744 | catch (Exception) | ||
745 | { | ||
746 | } | ||
747 | // catch (Exception e2) // LEGIT: User Scripting | ||
748 | // { | ||
749 | // m_log.Error("[SCRIPT]: "+ | ||
750 | // "Error displaying error in-world: " + | ||
751 | // e2.ToString()); | ||
752 | // m_log.Error("[SCRIPT]: " + | ||
753 | // "Errormessage: Error compiling script:\r\n" + | ||
754 | // e.ToString()); | ||
755 | // } | ||
756 | } | ||
757 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
758 | { | 739 | { |
759 | m_InSelfDelete = true; | 740 | // DISPLAY ERROR INWORLD |
760 | if (part != null && part.ParentGroup != null) | 741 | string text = FormatException(e); |
761 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 742 | |
743 | if (text.Length > 1000) | ||
744 | text = text.Substring(0, 1000); | ||
745 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
746 | ChatTypeEnum.DebugChannel, 2147483647, | ||
747 | part.AbsolutePosition, | ||
748 | part.Name, part.UUID, false); | ||
762 | } | 749 | } |
763 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 750 | catch (Exception) |
764 | { | 751 | { |
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
768 | } | 752 | } |
753 | // catch (Exception e2) // LEGIT: User Scripting | ||
754 | // { | ||
755 | // m_log.Error("[SCRIPT]: "+ | ||
756 | // "Error displaying error in-world: " + | ||
757 | // e2.ToString()); | ||
758 | // m_log.Error("[SCRIPT]: " + | ||
759 | // "Errormessage: Error compiling script:\r\n" + | ||
760 | // e.ToString()); | ||
761 | // } | ||
762 | } | ||
763 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
764 | { | ||
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
768 | } | ||
769 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | ||
770 | { | ||
771 | m_InSelfDelete = true; | ||
772 | if (part != null && part.ParentGroup != null) | ||
773 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
769 | } | 774 | } |
770 | } | 775 | } |
771 | } | 776 | } |
777 | } | ||
772 | 778 | ||
773 | lock (m_EventQueue) | 779 | lock (m_EventQueue) |
780 | { | ||
781 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | ||
774 | { | 782 | { |
775 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 783 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
776 | { | 784 | } |
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 785 | else |
778 | } | 786 | { |
779 | else | 787 | m_CurrentResult = null; |
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 788 | } |
789 | } | ||
784 | 790 | ||
785 | m_DetectParams = null; | 791 | m_DetectParams = null; |
786 | 792 | ||
787 | return 0; | 793 | return 0; |
788 | } | 794 | } |
789 | } | 795 | } |
790 | 796 | ||
791 | public int EventTime() | 797 | public int EventTime() |
@@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
824 | new Object[0], new DetectParams[0])); | 830 | new Object[0], new DetectParams[0])); |
825 | } | 831 | } |
826 | 832 | ||
833 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
827 | public void ApiResetScript() | 834 | public void ApiResetScript() |
828 | { | 835 | { |
829 | // bool running = Running; | 836 | // bool running = Running; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index cc37225..3bdbdfb 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Threading; | 30 | using System.Threading; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
33 | using System.Security; | 34 | using System.Security; |
34 | using System.Security.Policy; | 35 | using System.Security.Policy; |
35 | using System.Reflection; | 36 | using System.Reflection; |
@@ -102,6 +103,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
102 | private Dictionary<UUID, IScriptInstance> m_Scripts = | 103 | private Dictionary<UUID, IScriptInstance> m_Scripts = |
103 | new Dictionary<UUID, IScriptInstance>(); | 104 | new Dictionary<UUID, IScriptInstance>(); |
104 | 105 | ||
106 | private OpenMetaverse.ReaderWriterLockSlim m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
107 | |||
105 | // Maps the asset ID to the assembly | 108 | // Maps the asset ID to the assembly |
106 | 109 | ||
107 | private Dictionary<UUID, string> m_Assemblies = | 110 | private Dictionary<UUID, string> m_Assemblies = |
@@ -124,6 +127,71 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
124 | IWorkItemResult m_CurrentCompile = null; | 127 | IWorkItemResult m_CurrentCompile = null; |
125 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); | 128 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); |
126 | 129 | ||
130 | private void lockScriptsForRead(bool locked) | ||
131 | { | ||
132 | if (locked) | ||
133 | { | ||
134 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
135 | { | ||
136 | 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."); | ||
137 | m_scriptsLock.ExitReadLock(); | ||
138 | } | ||
139 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
140 | { | ||
141 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
142 | m_scriptsLock.ExitWriteLock(); | ||
143 | } | ||
144 | |||
145 | while (!m_scriptsLock.TryEnterReadLock(60000)) | ||
146 | { | ||
147 | 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."); | ||
148 | if (m_scriptsLock.IsWriteLockHeld) | ||
149 | { | ||
150 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
157 | { | ||
158 | m_scriptsLock.ExitReadLock(); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | private void lockScriptsForWrite(bool locked) | ||
163 | { | ||
164 | if (locked) | ||
165 | { | ||
166 | if (m_scriptsLock.RecursiveReadCount > 0) | ||
167 | { | ||
168 | 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."); | ||
169 | m_scriptsLock.ExitReadLock(); | ||
170 | } | ||
171 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
172 | { | ||
173 | m_log.Error("[XEngine.m_Scripts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
174 | m_scriptsLock.ExitWriteLock(); | ||
175 | } | ||
176 | |||
177 | while (!m_scriptsLock.TryEnterWriteLock(60000)) | ||
178 | { | ||
179 | 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."); | ||
180 | if (m_scriptsLock.IsWriteLockHeld) | ||
181 | { | ||
182 | m_scriptsLock = new OpenMetaverse.ReaderWriterLockSlim(); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | if (m_scriptsLock.RecursiveWriteCount > 0) | ||
189 | { | ||
190 | m_scriptsLock.ExitWriteLock(); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
127 | public string ScriptEngineName | 195 | public string ScriptEngineName |
128 | { | 196 | { |
129 | get { return "XEngine"; } | 197 | get { return "XEngine"; } |
@@ -263,43 +331,45 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
263 | 331 | ||
264 | public void RemoveRegion(Scene scene) | 332 | public void RemoveRegion(Scene scene) |
265 | { | 333 | { |
266 | lock (m_Scripts) | 334 | lockScriptsForRead(true); |
335 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
267 | { | 336 | { |
268 | foreach (IScriptInstance instance in m_Scripts.Values) | 337 | // Force a final state save |
338 | // | ||
339 | if (m_Assemblies.ContainsKey(instance.AssetID)) | ||
269 | { | 340 | { |
270 | // Force a final state save | 341 | string assembly = m_Assemblies[instance.AssetID]; |
271 | // | 342 | instance.SaveState(assembly); |
272 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 343 | } |
273 | { | ||
274 | string assembly = m_Assemblies[instance.AssetID]; | ||
275 | instance.SaveState(assembly); | ||
276 | } | ||
277 | 344 | ||
278 | // Clear the event queue and abort the instance thread | 345 | // Clear the event queue and abort the instance thread |
279 | // | 346 | // |
280 | instance.ClearQueue(); | 347 | instance.ClearQueue(); |
281 | instance.Stop(0); | 348 | instance.Stop(0); |
282 | 349 | ||
283 | // Release events, timer, etc | 350 | // Release events, timer, etc |
284 | // | 351 | // |
285 | instance.DestroyScriptInstance(); | 352 | instance.DestroyScriptInstance(); |
286 | 353 | ||
287 | // Unload scripts and app domains | 354 | // Unload scripts and app domains |
288 | // Must be done explicitly because they have infinite | 355 | // Must be done explicitly because they have infinite |
289 | // lifetime | 356 | // lifetime |
290 | // | 357 | // |
291 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 358 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
292 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 359 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
293 | { | 360 | { |
294 | m_DomainScripts.Remove(instance.AppDomain); | 361 | m_DomainScripts.Remove(instance.AppDomain); |
295 | UnloadAppDomain(instance.AppDomain); | 362 | UnloadAppDomain(instance.AppDomain); |
296 | } | ||
297 | } | 363 | } |
298 | m_Scripts.Clear(); | ||
299 | m_PrimObjects.Clear(); | ||
300 | m_Assemblies.Clear(); | ||
301 | m_DomainScripts.Clear(); | ||
302 | } | 364 | } |
365 | lockScriptsForRead(false); | ||
366 | lockScriptsForWrite(true); | ||
367 | m_Scripts.Clear(); | ||
368 | lockScriptsForWrite(false); | ||
369 | m_PrimObjects.Clear(); | ||
370 | m_Assemblies.Clear(); | ||
371 | m_DomainScripts.Clear(); | ||
372 | |||
303 | lock (m_ScriptEngines) | 373 | lock (m_ScriptEngines) |
304 | { | 374 | { |
305 | m_ScriptEngines.Remove(this); | 375 | m_ScriptEngines.Remove(this); |
@@ -358,22 +428,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
358 | 428 | ||
359 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 429 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
360 | 430 | ||
361 | lock (m_Scripts) | 431 | lockScriptsForRead(true); |
362 | { | 432 | foreach (IScriptInstance instance in m_Scripts.Values) |
363 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
364 | instances.Add(instance); | 433 | instances.Add(instance); |
365 | } | 434 | lockScriptsForRead(false); |
366 | 435 | ||
367 | foreach (IScriptInstance i in instances) | 436 | foreach (IScriptInstance i in instances) |
368 | { | 437 | { |
369 | string assembly = String.Empty; | 438 | string assembly = String.Empty; |
370 | 439 | ||
371 | lock (m_Scripts) | 440 | |
372 | { | ||
373 | if (!m_Assemblies.ContainsKey(i.AssetID)) | 441 | if (!m_Assemblies.ContainsKey(i.AssetID)) |
374 | continue; | 442 | continue; |
375 | assembly = m_Assemblies[i.AssetID]; | 443 | assembly = m_Assemblies[i.AssetID]; |
376 | } | 444 | |
377 | 445 | ||
378 | i.SaveState(assembly); | 446 | i.SaveState(assembly); |
379 | } | 447 | } |
@@ -701,111 +769,117 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
701 | } | 769 | } |
702 | } | 770 | } |
703 | 771 | ||
704 | lock (m_Scripts) | 772 | |
773 | |||
774 | ScriptInstance instance = null; | ||
775 | // Create the object record | ||
776 | lockScriptsForRead(true); | ||
777 | if ((!m_Scripts.ContainsKey(itemID)) || | ||
778 | (m_Scripts[itemID].AssetID != assetID)) | ||
705 | { | 779 | { |
706 | ScriptInstance instance = null; | 780 | lockScriptsForRead(false); |
707 | // Create the object record | ||
708 | 781 | ||
709 | if ((!m_Scripts.ContainsKey(itemID)) || | 782 | UUID appDomain = assetID; |
710 | (m_Scripts[itemID].AssetID != assetID)) | ||
711 | { | ||
712 | UUID appDomain = assetID; | ||
713 | 783 | ||
714 | if (part.ParentGroup.IsAttachment) | 784 | if (part.ParentGroup.IsAttachment) |
715 | appDomain = part.ParentGroup.RootPart.UUID; | 785 | appDomain = part.ParentGroup.RootPart.UUID; |
716 | 786 | ||
717 | if (!m_AppDomains.ContainsKey(appDomain)) | 787 | if (!m_AppDomains.ContainsKey(appDomain)) |
788 | { | ||
789 | try | ||
718 | { | 790 | { |
719 | try | 791 | AppDomainSetup appSetup = new AppDomainSetup(); |
720 | { | 792 | // appSetup.ApplicationBase = Path.Combine( |
721 | AppDomainSetup appSetup = new AppDomainSetup(); | 793 | // "ScriptEngines", |
722 | // appSetup.ApplicationBase = Path.Combine( | 794 | // m_Scene.RegionInfo.RegionID.ToString()); |
723 | // "ScriptEngines", | 795 | |
724 | // m_Scene.RegionInfo.RegionID.ToString()); | 796 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
725 | 797 | Evidence evidence = new Evidence(baseEvidence); | |
726 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 798 | |
727 | Evidence evidence = new Evidence(baseEvidence); | 799 | AppDomain sandbox; |
728 | 800 | if (m_AppDomainLoading) | |
729 | AppDomain sandbox; | 801 | sandbox = AppDomain.CreateDomain( |
730 | if (m_AppDomainLoading) | 802 | m_Scene.RegionInfo.RegionID.ToString(), |
731 | sandbox = AppDomain.CreateDomain( | 803 | evidence, appSetup); |
732 | m_Scene.RegionInfo.RegionID.ToString(), | 804 | else |
733 | evidence, appSetup); | 805 | sandbox = AppDomain.CurrentDomain; |
734 | else | 806 | |
735 | sandbox = AppDomain.CurrentDomain; | 807 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
736 | 808 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | |
737 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 809 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); |
738 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 810 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); |
739 | //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | 811 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); |
740 | //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | 812 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; |
741 | //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | 813 | //sandbox.SetAppDomainPolicy(sandboxPolicy); |
742 | //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | 814 | |
743 | //sandbox.SetAppDomainPolicy(sandboxPolicy); | 815 | m_AppDomains[appDomain] = sandbox; |
744 | 816 | ||
745 | m_AppDomains[appDomain] = sandbox; | 817 | m_AppDomains[appDomain].AssemblyResolve += |
746 | 818 | new ResolveEventHandler( | |
747 | m_AppDomains[appDomain].AssemblyResolve += | 819 | AssemblyResolver.OnAssemblyResolve); |
748 | new ResolveEventHandler( | 820 | m_DomainScripts[appDomain] = new List<UUID>(); |
749 | AssemblyResolver.OnAssemblyResolve); | ||
750 | m_DomainScripts[appDomain] = new List<UUID>(); | ||
751 | } | ||
752 | catch (Exception e) | ||
753 | { | ||
754 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); | ||
755 | m_ScriptErrorMessage += "Exception creating app domain:\n"; | ||
756 | m_ScriptFailCount++; | ||
757 | lock (m_AddingAssemblies) | ||
758 | { | ||
759 | m_AddingAssemblies[assembly]--; | ||
760 | } | ||
761 | return false; | ||
762 | } | ||
763 | } | 821 | } |
764 | m_DomainScripts[appDomain].Add(itemID); | 822 | catch (Exception e) |
765 | |||
766 | instance = new ScriptInstance(this, part, | ||
767 | itemID, assetID, assembly, | ||
768 | m_AppDomains[appDomain], | ||
769 | part.ParentGroup.RootPart.Name, | ||
770 | item.Name, startParam, postOnRez, | ||
771 | stateSource, m_MaxScriptQueue); | ||
772 | |||
773 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", | ||
774 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); | ||
775 | |||
776 | if (presence != null) | ||
777 | { | 823 | { |
778 | ShowScriptSaveResponse(item.OwnerID, | 824 | m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); |
779 | assetID, "Compile successful", true); | 825 | m_ScriptErrorMessage += "Exception creating app domain:\n"; |
826 | m_ScriptFailCount++; | ||
827 | lock (m_AddingAssemblies) | ||
828 | { | ||
829 | m_AddingAssemblies[assembly]--; | ||
830 | } | ||
831 | return false; | ||
780 | } | 832 | } |
833 | } | ||
834 | m_DomainScripts[appDomain].Add(itemID); | ||
781 | 835 | ||
782 | instance.AppDomain = appDomain; | 836 | instance = new ScriptInstance(this, part, |
783 | instance.LineMap = linemap; | 837 | itemID, assetID, assembly, |
838 | m_AppDomains[appDomain], | ||
839 | part.ParentGroup.RootPart.Name, | ||
840 | item.Name, startParam, postOnRez, | ||
841 | stateSource, m_MaxScriptQueue); | ||
784 | 842 | ||
785 | m_Scripts[itemID] = instance; | 843 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}", |
786 | } | 844 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition.ToString()); |
787 | 845 | ||
788 | lock (m_PrimObjects) | 846 | if (presence != null) |
789 | { | 847 | { |
790 | if (!m_PrimObjects.ContainsKey(localID)) | 848 | ShowScriptSaveResponse(item.OwnerID, |
791 | m_PrimObjects[localID] = new List<UUID>(); | 849 | assetID, "Compile successful", true); |
850 | } | ||
792 | 851 | ||
793 | if (!m_PrimObjects[localID].Contains(itemID)) | 852 | instance.AppDomain = appDomain; |
794 | m_PrimObjects[localID].Add(itemID); | 853 | instance.LineMap = linemap; |
854 | lockScriptsForWrite(true); | ||
855 | m_Scripts[itemID] = instance; | ||
856 | lockScriptsForWrite(false); | ||
857 | } | ||
858 | else | ||
859 | { | ||
860 | lockScriptsForRead(false); | ||
861 | } | ||
862 | lock (m_PrimObjects) | ||
863 | { | ||
864 | if (!m_PrimObjects.ContainsKey(localID)) | ||
865 | m_PrimObjects[localID] = new List<UUID>(); | ||
795 | 866 | ||
796 | } | 867 | if (!m_PrimObjects[localID].Contains(itemID)) |
868 | m_PrimObjects[localID].Add(itemID); | ||
797 | 869 | ||
798 | if (!m_Assemblies.ContainsKey(assetID)) | 870 | } |
799 | m_Assemblies[assetID] = assembly; | ||
800 | 871 | ||
801 | lock (m_AddingAssemblies) | 872 | if (!m_Assemblies.ContainsKey(assetID)) |
802 | { | 873 | m_Assemblies[assetID] = assembly; |
803 | m_AddingAssemblies[assembly]--; | ||
804 | } | ||
805 | 874 | ||
806 | if (instance!=null) | 875 | lock (m_AddingAssemblies) |
807 | instance.Init(); | 876 | { |
877 | m_AddingAssemblies[assembly]--; | ||
808 | } | 878 | } |
879 | |||
880 | if (instance!=null) | ||
881 | instance.Init(); | ||
882 | |||
809 | return true; | 883 | return true; |
810 | } | 884 | } |
811 | 885 | ||
@@ -820,58 +894,61 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
820 | 894 | ||
821 | lock (m_Scripts) | 895 | lock (m_Scripts) |
822 | { | 896 | { |
823 | // Do we even have it? | 897 | lockScriptsForRead(false); |
824 | if (!m_Scripts.ContainsKey(itemID)) | 898 | return; |
825 | return; | 899 | } |
900 | |||
826 | 901 | ||
827 | IScriptInstance instance=m_Scripts[itemID]; | 902 | IScriptInstance instance=m_Scripts[itemID]; |
828 | m_Scripts.Remove(itemID); | 903 | lockScriptsForRead(false); |
829 | 904 | lockScriptsForWrite(true); | |
830 | instance.ClearQueue(); | 905 | m_Scripts.Remove(itemID); |
831 | instance.Stop(0); | 906 | lockScriptsForWrite(false); |
907 | instance.ClearQueue(); | ||
908 | instance.Stop(0); | ||
832 | 909 | ||
833 | // bool objectRemoved = false; | 910 | // bool objectRemoved = false; |
834 | 911 | ||
835 | lock (m_PrimObjects) | 912 | lock (m_PrimObjects) |
913 | { | ||
914 | // Remove the script from it's prim | ||
915 | if (m_PrimObjects.ContainsKey(localID)) | ||
836 | { | 916 | { |
837 | // Remove the script from it's prim | 917 | // Remove inventory item record |
838 | if (m_PrimObjects.ContainsKey(localID)) | 918 | if (m_PrimObjects[localID].Contains(itemID)) |
839 | { | 919 | m_PrimObjects[localID].Remove(itemID); |
840 | // Remove inventory item record | ||
841 | if (m_PrimObjects[localID].Contains(itemID)) | ||
842 | m_PrimObjects[localID].Remove(itemID); | ||
843 | 920 | ||
844 | // If there are no more scripts, remove prim | 921 | // If there are no more scripts, remove prim |
845 | if (m_PrimObjects[localID].Count == 0) | 922 | if (m_PrimObjects[localID].Count == 0) |
846 | { | 923 | { |
847 | m_PrimObjects.Remove(localID); | 924 | m_PrimObjects.Remove(localID); |
848 | // objectRemoved = true; | 925 | // objectRemoved = true; |
849 | } | ||
850 | } | 926 | } |
851 | } | 927 | } |
928 | } | ||
852 | 929 | ||
853 | instance.RemoveState(); | 930 | instance.RemoveState(); |
854 | instance.DestroyScriptInstance(); | 931 | instance.DestroyScriptInstance(); |
855 | 932 | ||
856 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); | 933 | m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); |
857 | if (m_DomainScripts[instance.AppDomain].Count == 0) | 934 | if (m_DomainScripts[instance.AppDomain].Count == 0) |
858 | { | 935 | { |
859 | m_DomainScripts.Remove(instance.AppDomain); | 936 | m_DomainScripts.Remove(instance.AppDomain); |
860 | UnloadAppDomain(instance.AppDomain); | 937 | UnloadAppDomain(instance.AppDomain); |
861 | } | 938 | } |
862 | |||
863 | instance = null; | ||
864 | 939 | ||
865 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; | 940 | instance = null; |
866 | if (handlerObjectRemoved != null) | ||
867 | { | ||
868 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
869 | handlerObjectRemoved(part.UUID); | ||
870 | } | ||
871 | 941 | ||
872 | CleanAssemblies(); | 942 | ObjectRemoved handlerObjectRemoved = OnObjectRemoved; |
943 | if (handlerObjectRemoved != null) | ||
944 | { | ||
945 | SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); | ||
946 | handlerObjectRemoved(part.UUID); | ||
873 | } | 947 | } |
874 | 948 | ||
949 | CleanAssemblies(); | ||
950 | |||
951 | |||
875 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; | 952 | ScriptRemoved handlerScriptRemoved = OnScriptRemoved; |
876 | if (handlerScriptRemoved != null) | 953 | if (handlerScriptRemoved != null) |
877 | handlerScriptRemoved(itemID); | 954 | handlerScriptRemoved(itemID); |
@@ -1123,12 +1200,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1123 | private IScriptInstance GetInstance(UUID itemID) | 1200 | private IScriptInstance GetInstance(UUID itemID) |
1124 | { | 1201 | { |
1125 | IScriptInstance instance; | 1202 | IScriptInstance instance; |
1126 | lock (m_Scripts) | 1203 | lockScriptsForRead(true); |
1204 | if (!m_Scripts.ContainsKey(itemID)) | ||
1127 | { | 1205 | { |
1128 | if (!m_Scripts.ContainsKey(itemID)) | 1206 | lockScriptsForRead(false); |
1129 | return null; | 1207 | return null; |
1130 | instance = m_Scripts[itemID]; | ||
1131 | } | 1208 | } |
1209 | instance = m_Scripts[itemID]; | ||
1210 | lockScriptsForRead(false); | ||
1132 | return instance; | 1211 | return instance; |
1133 | } | 1212 | } |
1134 | 1213 | ||
@@ -1152,6 +1231,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1152 | return false; | 1231 | return false; |
1153 | } | 1232 | } |
1154 | 1233 | ||
1234 | [DebuggerNonUserCode] | ||
1155 | public void ApiResetScript(UUID itemID) | 1235 | public void ApiResetScript(UUID itemID) |
1156 | { | 1236 | { |
1157 | IScriptInstance instance = GetInstance(itemID); | 1237 | IScriptInstance instance = GetInstance(itemID); |
@@ -1203,6 +1283,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1203 | return UUID.Zero; | 1283 | return UUID.Zero; |
1204 | } | 1284 | } |
1205 | 1285 | ||
1286 | [DebuggerNonUserCode] | ||
1206 | public void SetState(UUID itemID, string newState) | 1287 | public void SetState(UUID itemID, string newState) |
1207 | { | 1288 | { |
1208 | IScriptInstance instance = GetInstance(itemID); | 1289 | IScriptInstance instance = GetInstance(itemID); |
@@ -1223,11 +1304,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1223 | { | 1304 | { |
1224 | List<IScriptInstance> instances = new List<IScriptInstance>(); | 1305 | List<IScriptInstance> instances = new List<IScriptInstance>(); |
1225 | 1306 | ||
1226 | lock (m_Scripts) | 1307 | lockScriptsForRead(true); |
1227 | { | 1308 | foreach (IScriptInstance instance in m_Scripts.Values) |
1228 | foreach (IScriptInstance instance in m_Scripts.Values) | ||
1229 | instances.Add(instance); | 1309 | instances.Add(instance); |
1230 | } | 1310 | lockScriptsForRead(false); |
1231 | 1311 | ||
1232 | foreach (IScriptInstance i in instances) | 1312 | foreach (IScriptInstance i in instances) |
1233 | { | 1313 | { |