diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
14 files changed, 1527 insertions, 448 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 e4e087f..ec7fde0 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 | ||
@@ -705,6 +722,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
705 | { | 722 | { |
706 | //A and B should both be normalized | 723 | //A and B should both be normalized |
707 | m_host.AddScriptLPS(1); | 724 | m_host.AddScriptLPS(1); |
725 | /* This method is more accurate than the SL one, and thus causes problems | ||
726 | for scripts that deal with the SL inaccuracy around 180-degrees -.- .._. | ||
727 | |||
708 | double dotProduct = LSL_Vector.Dot(a, b); | 728 | double dotProduct = LSL_Vector.Dot(a, b); |
709 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); | 729 | LSL_Vector crossProduct = LSL_Vector.Cross(a, b); |
710 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); | 730 | double magProduct = LSL_Vector.Mag(a) * LSL_Vector.Mag(b); |
@@ -721,8 +741,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
721 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | 741 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); |
722 | 742 | ||
723 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); | 743 | return new LSL_Rotation((float)x, (float)y, (float)z, (float)w); |
724 | } | 744 | */ |
725 | 745 | ||
746 | // This method mimics the 180 errors found in SL | ||
747 | // See www.euclideanspace.com... angleBetween | ||
748 | LSL_Vector vec_a = a; | ||
749 | LSL_Vector vec_b = b; | ||
750 | |||
751 | // Eliminate zero length | ||
752 | LSL_Float vec_a_mag = LSL_Vector.Mag(vec_a); | ||
753 | LSL_Float vec_b_mag = LSL_Vector.Mag(vec_b); | ||
754 | if (vec_a_mag < 0.00001 || | ||
755 | vec_b_mag < 0.00001) | ||
756 | { | ||
757 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
758 | } | ||
759 | |||
760 | // Normalize | ||
761 | vec_a = llVecNorm(vec_a); | ||
762 | vec_b = llVecNorm(vec_b); | ||
763 | |||
764 | // Calculate axis and rotation angle | ||
765 | LSL_Vector axis = vec_a % vec_b; | ||
766 | LSL_Float cos_theta = vec_a * vec_b; | ||
767 | |||
768 | // Check if parallel | ||
769 | if (cos_theta > 0.99999) | ||
770 | { | ||
771 | return new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f); | ||
772 | } | ||
773 | |||
774 | // Check if anti-parallel | ||
775 | else if (cos_theta < -0.99999) | ||
776 | { | ||
777 | LSL_Vector orthog_axis = new LSL_Vector(1.0, 0.0, 0.0) - (vec_a.x / (vec_a * vec_a) * vec_a); | ||
778 | if (LSL_Vector.Mag(orthog_axis) < 0.000001) orthog_axis = new LSL_Vector(0.0, 0.0, 1.0); | ||
779 | return new LSL_Rotation((float)orthog_axis.x, (float)orthog_axis.y, (float)orthog_axis.z, 0.0); | ||
780 | } | ||
781 | else // other rotation | ||
782 | { | ||
783 | LSL_Float theta = (LSL_Float)Math.Acos(cos_theta) * 0.5f; | ||
784 | axis = llVecNorm(axis); | ||
785 | double x, y, z, s, t; | ||
786 | s = Math.Cos(theta); | ||
787 | t = Math.Sin(theta); | ||
788 | x = axis.x * t; | ||
789 | y = axis.y * t; | ||
790 | z = axis.z * t; | ||
791 | return new LSL_Rotation(x,y,z,s); | ||
792 | } | ||
793 | } | ||
794 | |||
726 | public void llWhisper(int channelID, string text) | 795 | public void llWhisper(int channelID, string text) |
727 | { | 796 | { |
728 | m_host.AddScriptLPS(1); | 797 | m_host.AddScriptLPS(1); |
@@ -1046,10 +1115,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1046 | return detectedParams.TouchUV; | 1115 | return detectedParams.TouchUV; |
1047 | } | 1116 | } |
1048 | 1117 | ||
1118 | [DebuggerNonUserCode] | ||
1049 | public virtual void llDie() | 1119 | public virtual void llDie() |
1050 | { | 1120 | { |
1051 | m_host.AddScriptLPS(1); | 1121 | m_host.AddScriptLPS(1); |
1052 | throw new SelfDeleteException(); | 1122 | if (!m_host.IsAttachment) throw new SelfDeleteException(); |
1053 | } | 1123 | } |
1054 | 1124 | ||
1055 | public LSL_Float llGround(LSL_Vector offset) | 1125 | public LSL_Float llGround(LSL_Vector offset) |
@@ -1122,6 +1192,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1122 | 1192 | ||
1123 | public void llSetStatus(int status, int value) | 1193 | public void llSetStatus(int status, int value) |
1124 | { | 1194 | { |
1195 | if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) | ||
1196 | return; | ||
1125 | m_host.AddScriptLPS(1); | 1197 | m_host.AddScriptLPS(1); |
1126 | 1198 | ||
1127 | int statusrotationaxis = 0; | 1199 | int statusrotationaxis = 0; |
@@ -1351,6 +1423,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1351 | { | 1423 | { |
1352 | m_host.AddScriptLPS(1); | 1424 | m_host.AddScriptLPS(1); |
1353 | 1425 | ||
1426 | SetColor(m_host, color, face); | ||
1427 | } | ||
1428 | |||
1429 | protected void SetColor(SceneObjectPart part, LSL_Vector color, int face) | ||
1430 | { | ||
1431 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1432 | return; | ||
1433 | |||
1434 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1435 | Color4 texcolor; | ||
1436 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1437 | { | ||
1438 | texcolor = tex.CreateFace((uint)face).RGBA; | ||
1439 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1440 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1441 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1442 | tex.FaceTextures[face].RGBA = texcolor; | ||
1443 | part.UpdateTexture(tex); | ||
1444 | return; | ||
1445 | } | ||
1446 | else if (face == ScriptBaseClass.ALL_SIDES) | ||
1447 | { | ||
1448 | for (uint i = 0; i < GetNumberOfSides(part); i++) | ||
1449 | { | ||
1450 | if (tex.FaceTextures[i] != null) | ||
1451 | { | ||
1452 | texcolor = tex.FaceTextures[i].RGBA; | ||
1453 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1454 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1455 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1456 | tex.FaceTextures[i].RGBA = texcolor; | ||
1457 | } | ||
1458 | texcolor = tex.DefaultTexture.RGBA; | ||
1459 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | ||
1460 | texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); | ||
1461 | texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); | ||
1462 | tex.DefaultTexture.RGBA = texcolor; | ||
1463 | } | ||
1464 | part.UpdateTexture(tex); | ||
1465 | return; | ||
1466 | } | ||
1467 | |||
1354 | if (face == ScriptBaseClass.ALL_SIDES) | 1468 | if (face == ScriptBaseClass.ALL_SIDES) |
1355 | face = SceneObjectPart.ALL_SIDES; | 1469 | face = SceneObjectPart.ALL_SIDES; |
1356 | 1470 | ||
@@ -1359,6 +1473,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1359 | 1473 | ||
1360 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1474 | public void SetTexGen(SceneObjectPart part, int face,int style) |
1361 | { | 1475 | { |
1476 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1477 | return; | ||
1478 | |||
1362 | Primitive.TextureEntry tex = part.Shape.Textures; | 1479 | Primitive.TextureEntry tex = part.Shape.Textures; |
1363 | MappingType textype; | 1480 | MappingType textype; |
1364 | textype = MappingType.Default; | 1481 | textype = MappingType.Default; |
@@ -1389,6 +1506,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1389 | 1506 | ||
1390 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1507 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1391 | { | 1508 | { |
1509 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1510 | return; | ||
1511 | |||
1392 | Primitive.TextureEntry tex = part.Shape.Textures; | 1512 | Primitive.TextureEntry tex = part.Shape.Textures; |
1393 | if (face >= 0 && face < GetNumberOfSides(part)) | 1513 | if (face >= 0 && face < GetNumberOfSides(part)) |
1394 | { | 1514 | { |
@@ -1414,6 +1534,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1414 | 1534 | ||
1415 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) | 1535 | public void SetShiny(SceneObjectPart part, int face, int shiny, Bumpiness bump) |
1416 | { | 1536 | { |
1537 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1538 | return; | ||
1417 | 1539 | ||
1418 | Shininess sval = new Shininess(); | 1540 | Shininess sval = new Shininess(); |
1419 | 1541 | ||
@@ -1464,6 +1586,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1464 | 1586 | ||
1465 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1587 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1466 | { | 1588 | { |
1589 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1590 | return; | ||
1591 | |||
1467 | Primitive.TextureEntry tex = part.Shape.Textures; | 1592 | Primitive.TextureEntry tex = part.Shape.Textures; |
1468 | if (face >= 0 && face < GetNumberOfSides(part)) | 1593 | if (face >= 0 && face < GetNumberOfSides(part)) |
1469 | { | 1594 | { |
@@ -1531,6 +1656,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1531 | 1656 | ||
1532 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) | 1657 | protected void SetAlpha(SceneObjectPart part, double alpha, int face) |
1533 | { | 1658 | { |
1659 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1660 | return; | ||
1661 | |||
1534 | Primitive.TextureEntry tex = part.Shape.Textures; | 1662 | Primitive.TextureEntry tex = part.Shape.Textures; |
1535 | Color4 texcolor; | 1663 | Color4 texcolor; |
1536 | if (face >= 0 && face < GetNumberOfSides(part)) | 1664 | if (face >= 0 && face < GetNumberOfSides(part)) |
@@ -1576,7 +1704,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1576 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, | 1704 | protected void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction, |
1577 | float wind, float tension, LSL_Vector Force) | 1705 | float wind, float tension, LSL_Vector Force) |
1578 | { | 1706 | { |
1579 | if (part == null) | 1707 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1580 | return; | 1708 | return; |
1581 | 1709 | ||
1582 | if (flexi) | 1710 | if (flexi) |
@@ -1611,7 +1739,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1611 | /// <param name="falloff"></param> | 1739 | /// <param name="falloff"></param> |
1612 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) | 1740 | protected void SetPointLight(SceneObjectPart part, bool light, LSL_Vector color, float intensity, float radius, float falloff) |
1613 | { | 1741 | { |
1614 | if (part == null) | 1742 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1615 | return; | 1743 | return; |
1616 | 1744 | ||
1617 | if (light) | 1745 | if (light) |
@@ -1697,6 +1825,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1697 | 1825 | ||
1698 | protected void SetTexture(SceneObjectPart part, string texture, int face) | 1826 | protected void SetTexture(SceneObjectPart part, string texture, int face) |
1699 | { | 1827 | { |
1828 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1829 | return; | ||
1830 | |||
1700 | UUID textureID=new UUID(); | 1831 | UUID textureID=new UUID(); |
1701 | 1832 | ||
1702 | if (!UUID.TryParse(texture, out textureID)) | 1833 | if (!UUID.TryParse(texture, out textureID)) |
@@ -1742,6 +1873,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1742 | 1873 | ||
1743 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1874 | protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1744 | { | 1875 | { |
1876 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1877 | return; | ||
1878 | |||
1745 | Primitive.TextureEntry tex = part.Shape.Textures; | 1879 | Primitive.TextureEntry tex = part.Shape.Textures; |
1746 | if (face >= 0 && face < GetNumberOfSides(part)) | 1880 | if (face >= 0 && face < GetNumberOfSides(part)) |
1747 | { | 1881 | { |
@@ -1778,6 +1912,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1778 | 1912 | ||
1779 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1913 | protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1780 | { | 1914 | { |
1915 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1916 | return; | ||
1917 | |||
1781 | Primitive.TextureEntry tex = part.Shape.Textures; | 1918 | Primitive.TextureEntry tex = part.Shape.Textures; |
1782 | if (face >= 0 && face < GetNumberOfSides(part)) | 1919 | if (face >= 0 && face < GetNumberOfSides(part)) |
1783 | { | 1920 | { |
@@ -1814,6 +1951,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1814 | 1951 | ||
1815 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) | 1952 | protected void RotateTexture(SceneObjectPart part, double rotation, int face) |
1816 | { | 1953 | { |
1954 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
1955 | return; | ||
1956 | |||
1817 | Primitive.TextureEntry tex = part.Shape.Textures; | 1957 | Primitive.TextureEntry tex = part.Shape.Textures; |
1818 | if (face >= 0 && face < GetNumberOfSides(part)) | 1958 | if (face >= 0 && face < GetNumberOfSides(part)) |
1819 | { | 1959 | { |
@@ -1884,6 +2024,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1884 | 2024 | ||
1885 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) | 2025 | protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) |
1886 | { | 2026 | { |
2027 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2028 | return; | ||
2029 | |||
1887 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) | 2030 | // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) |
1888 | LSL_Vector currentPos = llGetLocalPos(); | 2031 | LSL_Vector currentPos = llGetLocalPos(); |
1889 | 2032 | ||
@@ -1978,6 +2121,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1978 | 2121 | ||
1979 | protected void SetRot(SceneObjectPart part, Quaternion rot) | 2122 | protected void SetRot(SceneObjectPart part, Quaternion rot) |
1980 | { | 2123 | { |
2124 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
2125 | return; | ||
2126 | |||
1981 | part.UpdateRotation(rot); | 2127 | part.UpdateRotation(rot); |
1982 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2128 | // Update rotation does not move the object in the physics scene if it's a linkset. |
1983 | 2129 | ||
@@ -2597,12 +2743,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2597 | 2743 | ||
2598 | m_host.AddScriptLPS(1); | 2744 | m_host.AddScriptLPS(1); |
2599 | 2745 | ||
2746 | m_host.TaskInventory.LockItemsForRead(true); | ||
2600 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | 2747 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; |
2601 | 2748 | m_host.TaskInventory.LockItemsForRead(false); | |
2602 | lock (m_host.TaskInventory) | ||
2603 | { | ||
2604 | item = m_host.TaskInventory[invItemID]; | ||
2605 | } | ||
2606 | 2749 | ||
2607 | if (item.PermsGranter == UUID.Zero) | 2750 | if (item.PermsGranter == UUID.Zero) |
2608 | return 0; | 2751 | return 0; |
@@ -2677,6 +2820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2677 | if (dist > m_ScriptDistanceFactor * 10.0f) | 2820 | if (dist > m_ScriptDistanceFactor * 10.0f) |
2678 | return; | 2821 | return; |
2679 | 2822 | ||
2823 | //Clone is thread-safe | ||
2680 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 2824 | TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
2681 | 2825 | ||
2682 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) | 2826 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) |
@@ -2737,6 +2881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2737 | 2881 | ||
2738 | public void llLookAt(LSL_Vector target, double strength, double damping) | 2882 | public void llLookAt(LSL_Vector target, double strength, double damping) |
2739 | { | 2883 | { |
2884 | /* | ||
2740 | m_host.AddScriptLPS(1); | 2885 | m_host.AddScriptLPS(1); |
2741 | // Determine where we are looking from | 2886 | // Determine where we are looking from |
2742 | LSL_Vector from = llGetPos(); | 2887 | LSL_Vector from = llGetPos(); |
@@ -2756,10 +2901,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2756 | // the angles of rotation in radians into rotation value | 2901 | // the angles of rotation in radians into rotation value |
2757 | 2902 | ||
2758 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2903 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2759 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2904 | |
2760 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2905 | // This would only work if your physics system contains an APID controller: |
2906 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
2907 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
2908 | |||
2761 | // Orient the object to the angle calculated | 2909 | // Orient the object to the angle calculated |
2762 | //llSetRot(rot); | 2910 | llSetRot(rot); |
2911 | */ | ||
2912 | |||
2913 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
2914 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
2915 | // http://bugs.meta7.com/view.php?id=28 | ||
2916 | // - Tom | ||
2917 | |||
2918 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
2919 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
2920 | |||
2921 | } | ||
2922 | |||
2923 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2924 | { | ||
2925 | m_host.AddScriptLPS(1); | ||
2926 | // NotImplemented("llRotLookAt"); | ||
2927 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2928 | |||
2763 | } | 2929 | } |
2764 | 2930 | ||
2765 | public void llStopLookAt() | 2931 | public void llStopLookAt() |
@@ -2808,13 +2974,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2808 | { | 2974 | { |
2809 | TaskInventoryItem item; | 2975 | TaskInventoryItem item; |
2810 | 2976 | ||
2811 | lock (m_host.TaskInventory) | 2977 | m_host.TaskInventory.LockItemsForRead(true); |
2978 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2812 | { | 2979 | { |
2813 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2980 | m_host.TaskInventory.LockItemsForRead(false); |
2814 | return; | 2981 | return; |
2815 | else | ||
2816 | item = m_host.TaskInventory[InventorySelf()]; | ||
2817 | } | 2982 | } |
2983 | else | ||
2984 | { | ||
2985 | item = m_host.TaskInventory[InventorySelf()]; | ||
2986 | } | ||
2987 | m_host.TaskInventory.LockItemsForRead(false); | ||
2818 | 2988 | ||
2819 | if (item.PermsGranter != UUID.Zero) | 2989 | if (item.PermsGranter != UUID.Zero) |
2820 | { | 2990 | { |
@@ -2836,13 +3006,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2836 | { | 3006 | { |
2837 | TaskInventoryItem item; | 3007 | TaskInventoryItem item; |
2838 | 3008 | ||
3009 | m_host.TaskInventory.LockItemsForRead(true); | ||
2839 | lock (m_host.TaskInventory) | 3010 | lock (m_host.TaskInventory) |
2840 | { | 3011 | { |
3012 | |||
2841 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3013 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3014 | { | ||
3015 | m_host.TaskInventory.LockItemsForRead(false); | ||
2842 | return; | 3016 | return; |
3017 | } | ||
2843 | else | 3018 | else |
3019 | { | ||
2844 | item = m_host.TaskInventory[InventorySelf()]; | 3020 | item = m_host.TaskInventory[InventorySelf()]; |
3021 | } | ||
2845 | } | 3022 | } |
3023 | m_host.TaskInventory.LockItemsForRead(false); | ||
2846 | 3024 | ||
2847 | m_host.AddScriptLPS(1); | 3025 | m_host.AddScriptLPS(1); |
2848 | 3026 | ||
@@ -2879,14 +3057,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2879 | 3057 | ||
2880 | TaskInventoryItem item; | 3058 | TaskInventoryItem item; |
2881 | 3059 | ||
2882 | lock (m_host.TaskInventory) | 3060 | m_host.TaskInventory.LockItemsForRead(true); |
3061 | |||
3062 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2883 | { | 3063 | { |
2884 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3064 | m_host.TaskInventory.LockItemsForRead(false); |
2885 | return; | 3065 | return; |
2886 | else | 3066 | } |
2887 | item = m_host.TaskInventory[InventorySelf()]; | 3067 | else |
3068 | { | ||
3069 | item = m_host.TaskInventory[InventorySelf()]; | ||
2888 | } | 3070 | } |
2889 | 3071 | ||
3072 | m_host.TaskInventory.LockItemsForRead(false); | ||
3073 | |||
2890 | if (item.PermsGranter != m_host.OwnerID) | 3074 | if (item.PermsGranter != m_host.OwnerID) |
2891 | return; | 3075 | return; |
2892 | 3076 | ||
@@ -2911,13 +3095,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2911 | 3095 | ||
2912 | TaskInventoryItem item; | 3096 | TaskInventoryItem item; |
2913 | 3097 | ||
2914 | lock (m_host.TaskInventory) | 3098 | m_host.TaskInventory.LockItemsForRead(true); |
3099 | |||
3100 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2915 | { | 3101 | { |
2916 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3102 | m_host.TaskInventory.LockItemsForRead(false); |
2917 | return; | 3103 | return; |
2918 | else | ||
2919 | item = m_host.TaskInventory[InventorySelf()]; | ||
2920 | } | 3104 | } |
3105 | else | ||
3106 | { | ||
3107 | item = m_host.TaskInventory[InventorySelf()]; | ||
3108 | } | ||
3109 | m_host.TaskInventory.LockItemsForRead(false); | ||
3110 | |||
2921 | 3111 | ||
2922 | if (item.PermsGranter != m_host.OwnerID) | 3112 | if (item.PermsGranter != m_host.OwnerID) |
2923 | return; | 3113 | return; |
@@ -2953,8 +3143,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2953 | return m_host.OwnerID.ToString(); | 3143 | return m_host.OwnerID.ToString(); |
2954 | } | 3144 | } |
2955 | 3145 | ||
3146 | [DebuggerNonUserCode] | ||
2956 | public void llInstantMessage(string user, string message) | 3147 | public void llInstantMessage(string user, string message) |
2957 | { | 3148 | { |
3149 | UUID result; | ||
3150 | if (!UUID.TryParse(user, out result)) | ||
3151 | { | ||
3152 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3153 | return; | ||
3154 | } | ||
3155 | |||
3156 | |||
2958 | m_host.AddScriptLPS(1); | 3157 | m_host.AddScriptLPS(1); |
2959 | 3158 | ||
2960 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3159 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2969,7 +3168,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2969 | UUID friendTransactionID = UUID.Random(); | 3168 | UUID friendTransactionID = UUID.Random(); |
2970 | 3169 | ||
2971 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3170 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2972 | 3171 | ||
2973 | GridInstantMessage msg = new GridInstantMessage(); | 3172 | GridInstantMessage msg = new GridInstantMessage(); |
2974 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3173 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2975 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3174 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3118,13 +3317,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3118 | m_host.AddScriptLPS(1); | 3317 | m_host.AddScriptLPS(1); |
3119 | } | 3318 | } |
3120 | 3319 | ||
3121 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3122 | { | ||
3123 | m_host.AddScriptLPS(1); | ||
3124 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3125 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3126 | } | ||
3127 | |||
3128 | public LSL_Integer llStringLength(string str) | 3320 | public LSL_Integer llStringLength(string str) |
3129 | { | 3321 | { |
3130 | m_host.AddScriptLPS(1); | 3322 | m_host.AddScriptLPS(1); |
@@ -3148,14 +3340,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3148 | 3340 | ||
3149 | TaskInventoryItem item; | 3341 | TaskInventoryItem item; |
3150 | 3342 | ||
3151 | lock (m_host.TaskInventory) | 3343 | m_host.TaskInventory.LockItemsForRead(true); |
3344 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3152 | { | 3345 | { |
3153 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3346 | m_host.TaskInventory.LockItemsForRead(false); |
3154 | return; | 3347 | return; |
3155 | else | ||
3156 | item = m_host.TaskInventory[InventorySelf()]; | ||
3157 | } | 3348 | } |
3158 | 3349 | else | |
3350 | { | ||
3351 | item = m_host.TaskInventory[InventorySelf()]; | ||
3352 | } | ||
3353 | m_host.TaskInventory.LockItemsForRead(false); | ||
3159 | if (item.PermsGranter == UUID.Zero) | 3354 | if (item.PermsGranter == UUID.Zero) |
3160 | return; | 3355 | return; |
3161 | 3356 | ||
@@ -3185,13 +3380,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3185 | 3380 | ||
3186 | TaskInventoryItem item; | 3381 | TaskInventoryItem item; |
3187 | 3382 | ||
3188 | lock (m_host.TaskInventory) | 3383 | m_host.TaskInventory.LockItemsForRead(true); |
3384 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3189 | { | 3385 | { |
3190 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3386 | m_host.TaskInventory.LockItemsForRead(false); |
3191 | return; | 3387 | return; |
3192 | else | ||
3193 | item = m_host.TaskInventory[InventorySelf()]; | ||
3194 | } | 3388 | } |
3389 | else | ||
3390 | { | ||
3391 | item = m_host.TaskInventory[InventorySelf()]; | ||
3392 | } | ||
3393 | m_host.TaskInventory.LockItemsForRead(false); | ||
3394 | |||
3195 | 3395 | ||
3196 | if (item.PermsGranter == UUID.Zero) | 3396 | if (item.PermsGranter == UUID.Zero) |
3197 | return; | 3397 | return; |
@@ -3268,10 +3468,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3268 | 3468 | ||
3269 | TaskInventoryItem item; | 3469 | TaskInventoryItem item; |
3270 | 3470 | ||
3271 | lock (m_host.TaskInventory) | 3471 | |
3472 | m_host.TaskInventory.LockItemsForRead(true); | ||
3473 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3474 | { | ||
3475 | m_host.TaskInventory.LockItemsForRead(false); | ||
3476 | return; | ||
3477 | } | ||
3478 | else | ||
3272 | { | 3479 | { |
3273 | item = m_host.TaskInventory[invItemID]; | 3480 | item = m_host.TaskInventory[invItemID]; |
3274 | } | 3481 | } |
3482 | m_host.TaskInventory.LockItemsForRead(false); | ||
3275 | 3483 | ||
3276 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3484 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3277 | { | 3485 | { |
@@ -3303,11 +3511,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3303 | 3511 | ||
3304 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3512 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3305 | { | 3513 | { |
3306 | lock (m_host.TaskInventory) | 3514 | m_host.TaskInventory.LockItemsForWrite(true); |
3307 | { | 3515 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3308 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3516 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3309 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3517 | m_host.TaskInventory.LockItemsForWrite(false); |
3310 | } | ||
3311 | 3518 | ||
3312 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3519 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3313 | "run_time_permissions", new Object[] { | 3520 | "run_time_permissions", new Object[] { |
@@ -3327,11 +3534,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3327 | 3534 | ||
3328 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3535 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3329 | { | 3536 | { |
3330 | lock (m_host.TaskInventory) | 3537 | m_host.TaskInventory.LockItemsForWrite(true); |
3331 | { | 3538 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3332 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3539 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3333 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3540 | m_host.TaskInventory.LockItemsForWrite(false); |
3334 | } | ||
3335 | 3541 | ||
3336 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3542 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3337 | "run_time_permissions", new Object[] { | 3543 | "run_time_permissions", new Object[] { |
@@ -3352,11 +3558,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3352 | 3558 | ||
3353 | if (!m_waitingForScriptAnswer) | 3559 | if (!m_waitingForScriptAnswer) |
3354 | { | 3560 | { |
3355 | lock (m_host.TaskInventory) | 3561 | m_host.TaskInventory.LockItemsForWrite(true); |
3356 | { | 3562 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3357 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3563 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3358 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3564 | m_host.TaskInventory.LockItemsForWrite(false); |
3359 | } | ||
3360 | 3565 | ||
3361 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3566 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3362 | m_waitingForScriptAnswer=true; | 3567 | m_waitingForScriptAnswer=true; |
@@ -3391,10 +3596,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3391 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3596 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3392 | llReleaseControls(); | 3597 | llReleaseControls(); |
3393 | 3598 | ||
3394 | lock (m_host.TaskInventory) | 3599 | |
3395 | { | 3600 | m_host.TaskInventory.LockItemsForWrite(true); |
3396 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3601 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3397 | } | 3602 | m_host.TaskInventory.LockItemsForWrite(false); |
3603 | |||
3398 | 3604 | ||
3399 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3605 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3400 | "run_time_permissions", new Object[] { | 3606 | "run_time_permissions", new Object[] { |
@@ -3406,16 +3612,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3406 | { | 3612 | { |
3407 | m_host.AddScriptLPS(1); | 3613 | m_host.AddScriptLPS(1); |
3408 | 3614 | ||
3409 | lock (m_host.TaskInventory) | 3615 | m_host.TaskInventory.LockItemsForRead(true); |
3616 | |||
3617 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3410 | { | 3618 | { |
3411 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3619 | if (item.Type == 10 && item.ItemID == m_itemID) |
3412 | { | 3620 | { |
3413 | if (item.Type == 10 && item.ItemID == m_itemID) | 3621 | m_host.TaskInventory.LockItemsForRead(false); |
3414 | { | 3622 | return item.PermsGranter.ToString(); |
3415 | return item.PermsGranter.ToString(); | ||
3416 | } | ||
3417 | } | 3623 | } |
3418 | } | 3624 | } |
3625 | m_host.TaskInventory.LockItemsForRead(false); | ||
3419 | 3626 | ||
3420 | return UUID.Zero.ToString(); | 3627 | return UUID.Zero.ToString(); |
3421 | } | 3628 | } |
@@ -3424,19 +3631,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3424 | { | 3631 | { |
3425 | m_host.AddScriptLPS(1); | 3632 | m_host.AddScriptLPS(1); |
3426 | 3633 | ||
3427 | lock (m_host.TaskInventory) | 3634 | m_host.TaskInventory.LockItemsForRead(true); |
3635 | |||
3636 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3428 | { | 3637 | { |
3429 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3638 | if (item.Type == 10 && item.ItemID == m_itemID) |
3430 | { | 3639 | { |
3431 | if (item.Type == 10 && item.ItemID == m_itemID) | 3640 | int perms = item.PermsMask; |
3432 | { | 3641 | if (m_automaticLinkPermission) |
3433 | int perms = item.PermsMask; | 3642 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3434 | if (m_automaticLinkPermission) | 3643 | m_host.TaskInventory.LockItemsForRead(false); |
3435 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3644 | return perms; |
3436 | return perms; | ||
3437 | } | ||
3438 | } | 3645 | } |
3439 | } | 3646 | } |
3647 | m_host.TaskInventory.LockItemsForRead(false); | ||
3440 | 3648 | ||
3441 | return 0; | 3649 | return 0; |
3442 | } | 3650 | } |
@@ -3469,11 +3677,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3469 | UUID invItemID = InventorySelf(); | 3677 | UUID invItemID = InventorySelf(); |
3470 | 3678 | ||
3471 | TaskInventoryItem item; | 3679 | TaskInventoryItem item; |
3472 | lock (m_host.TaskInventory) | 3680 | m_host.TaskInventory.LockItemsForRead(true); |
3473 | { | 3681 | item = m_host.TaskInventory[invItemID]; |
3474 | item = m_host.TaskInventory[invItemID]; | 3682 | m_host.TaskInventory.LockItemsForRead(false); |
3475 | } | 3683 | |
3476 | |||
3477 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3684 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3478 | && !m_automaticLinkPermission) | 3685 | && !m_automaticLinkPermission) |
3479 | { | 3686 | { |
@@ -3526,16 +3733,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3526 | m_host.AddScriptLPS(1); | 3733 | m_host.AddScriptLPS(1); |
3527 | UUID invItemID = InventorySelf(); | 3734 | UUID invItemID = InventorySelf(); |
3528 | 3735 | ||
3529 | lock (m_host.TaskInventory) | 3736 | m_host.TaskInventory.LockItemsForRead(true); |
3530 | { | ||
3531 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3737 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3532 | && !m_automaticLinkPermission) | 3738 | && !m_automaticLinkPermission) |
3533 | { | 3739 | { |
3534 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3740 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3741 | m_host.TaskInventory.LockItemsForRead(false); | ||
3535 | return; | 3742 | return; |
3536 | } | 3743 | } |
3537 | } | 3744 | m_host.TaskInventory.LockItemsForRead(false); |
3538 | 3745 | ||
3539 | if (linknum < ScriptBaseClass.LINK_THIS) | 3746 | if (linknum < ScriptBaseClass.LINK_THIS) |
3540 | return; | 3747 | return; |
3541 | 3748 | ||
@@ -3712,17 +3919,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3712 | m_host.AddScriptLPS(1); | 3919 | m_host.AddScriptLPS(1); |
3713 | int count = 0; | 3920 | int count = 0; |
3714 | 3921 | ||
3715 | lock (m_host.TaskInventory) | 3922 | m_host.TaskInventory.LockItemsForRead(true); |
3923 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3716 | { | 3924 | { |
3717 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3925 | if (inv.Value.Type == type || type == -1) |
3718 | { | 3926 | { |
3719 | if (inv.Value.Type == type || type == -1) | 3927 | count = count + 1; |
3720 | { | ||
3721 | count = count + 1; | ||
3722 | } | ||
3723 | } | 3928 | } |
3724 | } | 3929 | } |
3725 | 3930 | ||
3931 | m_host.TaskInventory.LockItemsForRead(false); | ||
3726 | return count; | 3932 | return count; |
3727 | } | 3933 | } |
3728 | 3934 | ||
@@ -3731,16 +3937,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3731 | m_host.AddScriptLPS(1); | 3937 | m_host.AddScriptLPS(1); |
3732 | ArrayList keys = new ArrayList(); | 3938 | ArrayList keys = new ArrayList(); |
3733 | 3939 | ||
3734 | lock (m_host.TaskInventory) | 3940 | m_host.TaskInventory.LockItemsForRead(true); |
3941 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3735 | { | 3942 | { |
3736 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3943 | if (inv.Value.Type == type || type == -1) |
3737 | { | 3944 | { |
3738 | if (inv.Value.Type == type || type == -1) | 3945 | keys.Add(inv.Value.Name); |
3739 | { | ||
3740 | keys.Add(inv.Value.Name); | ||
3741 | } | ||
3742 | } | 3946 | } |
3743 | } | 3947 | } |
3948 | m_host.TaskInventory.LockItemsForRead(false); | ||
3744 | 3949 | ||
3745 | if (keys.Count == 0) | 3950 | if (keys.Count == 0) |
3746 | { | 3951 | { |
@@ -3777,20 +3982,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3777 | } | 3982 | } |
3778 | 3983 | ||
3779 | // move the first object found with this inventory name | 3984 | // move the first object found with this inventory name |
3780 | lock (m_host.TaskInventory) | 3985 | m_host.TaskInventory.LockItemsForRead(true); |
3986 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3781 | { | 3987 | { |
3782 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3988 | if (inv.Value.Name == inventory) |
3783 | { | 3989 | { |
3784 | if (inv.Value.Name == inventory) | 3990 | found = true; |
3785 | { | 3991 | objId = inv.Key; |
3786 | found = true; | 3992 | assetType = inv.Value.Type; |
3787 | objId = inv.Key; | 3993 | objName = inv.Value.Name; |
3788 | assetType = inv.Value.Type; | 3994 | break; |
3789 | objName = inv.Value.Name; | ||
3790 | break; | ||
3791 | } | ||
3792 | } | 3995 | } |
3793 | } | 3996 | } |
3997 | m_host.TaskInventory.LockItemsForRead(false); | ||
3794 | 3998 | ||
3795 | if (!found) | 3999 | if (!found) |
3796 | { | 4000 | { |
@@ -3826,33 +4030,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3826 | 4030 | ||
3827 | if (m_TransferModule != null) | 4031 | if (m_TransferModule != null) |
3828 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4032 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4033 | |||
4034 | //This delay should only occur when giving inventory to avatars. | ||
4035 | ScriptSleep(3000); | ||
3829 | } | 4036 | } |
3830 | else | 4037 | else |
3831 | { | 4038 | { |
3832 | // destination is an object | 4039 | // destination is an object |
3833 | World.MoveTaskInventoryItem(destId, m_host, objId); | 4040 | World.MoveTaskInventoryItem(destId, m_host, objId); |
3834 | } | 4041 | } |
3835 | ScriptSleep(3000); | 4042 | |
3836 | } | 4043 | } |
3837 | 4044 | ||
4045 | [DebuggerNonUserCode] | ||
3838 | public void llRemoveInventory(string name) | 4046 | public void llRemoveInventory(string name) |
3839 | { | 4047 | { |
3840 | m_host.AddScriptLPS(1); | 4048 | m_host.AddScriptLPS(1); |
3841 | 4049 | ||
3842 | lock (m_host.TaskInventory) | 4050 | m_host.TaskInventory.LockItemsForRead(true); |
4051 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3843 | { | 4052 | { |
3844 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4053 | if (item.Name == name) |
3845 | { | 4054 | { |
3846 | if (item.Name == name) | 4055 | if (item.ItemID == m_itemID) |
3847 | { | 4056 | throw new ScriptDeleteException(); |
3848 | if (item.ItemID == m_itemID) | 4057 | else |
3849 | throw new ScriptDeleteException(); | 4058 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3850 | else | 4059 | |
3851 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4060 | m_host.TaskInventory.LockItemsForRead(false); |
3852 | return; | 4061 | return; |
3853 | } | ||
3854 | } | 4062 | } |
3855 | } | 4063 | } |
4064 | m_host.TaskInventory.LockItemsForRead(false); | ||
3856 | } | 4065 | } |
3857 | 4066 | ||
3858 | public void llSetText(string text, LSL_Vector color, double alpha) | 4067 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3942,6 +4151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3942 | { | 4151 | { |
3943 | m_host.AddScriptLPS(1); | 4152 | m_host.AddScriptLPS(1); |
3944 | 4153 | ||
4154 | //Clone is thread safe | ||
3945 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4155 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3946 | 4156 | ||
3947 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4157 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3995,6 +4205,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3995 | ScenePresence presence = World.GetScenePresence(agentId); | 4205 | ScenePresence presence = World.GetScenePresence(agentId); |
3996 | if (presence != null) | 4206 | if (presence != null) |
3997 | { | 4207 | { |
4208 | // agent must not be a god | ||
4209 | if (presence.GodLevel >= 200) return; | ||
4210 | |||
3998 | // agent must be over the owners land | 4211 | // agent must be over the owners land |
3999 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4212 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4000 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4213 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4030,17 +4243,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4030 | UUID soundId = UUID.Zero; | 4243 | UUID soundId = UUID.Zero; |
4031 | if (!UUID.TryParse(impact_sound, out soundId)) | 4244 | if (!UUID.TryParse(impact_sound, out soundId)) |
4032 | { | 4245 | { |
4033 | lock (m_host.TaskInventory) | 4246 | m_host.TaskInventory.LockItemsForRead(true); |
4247 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4034 | { | 4248 | { |
4035 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4249 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4036 | { | 4250 | { |
4037 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4251 | soundId = item.AssetID; |
4038 | { | 4252 | break; |
4039 | soundId = item.AssetID; | ||
4040 | break; | ||
4041 | } | ||
4042 | } | 4253 | } |
4043 | } | 4254 | } |
4255 | m_host.TaskInventory.LockItemsForRead(false); | ||
4044 | } | 4256 | } |
4045 | m_host.CollisionSound = soundId; | 4257 | m_host.CollisionSound = soundId; |
4046 | m_host.CollisionSoundVolume = (float)impact_volume; | 4258 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4086,6 +4298,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4086 | UUID partItemID; | 4298 | UUID partItemID; |
4087 | foreach (SceneObjectPart part in parts) | 4299 | foreach (SceneObjectPart part in parts) |
4088 | { | 4300 | { |
4301 | //Clone is thread safe | ||
4089 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4302 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4090 | 4303 | ||
4091 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4304 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4300,17 +4513,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4300 | 4513 | ||
4301 | m_host.AddScriptLPS(1); | 4514 | m_host.AddScriptLPS(1); |
4302 | 4515 | ||
4303 | lock (m_host.TaskInventory) | 4516 | m_host.TaskInventory.LockItemsForRead(true); |
4517 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4304 | { | 4518 | { |
4305 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4519 | if (item.Type == 10 && item.ItemID == m_itemID) |
4306 | { | 4520 | { |
4307 | if (item.Type == 10 && item.ItemID == m_itemID) | 4521 | result = item.Name!=null?item.Name:String.Empty; |
4308 | { | 4522 | break; |
4309 | result = item.Name != null ? item.Name : String.Empty; | ||
4310 | break; | ||
4311 | } | ||
4312 | } | 4523 | } |
4313 | } | 4524 | } |
4525 | m_host.TaskInventory.LockItemsForRead(false); | ||
4314 | 4526 | ||
4315 | return result; | 4527 | return result; |
4316 | } | 4528 | } |
@@ -4463,23 +4675,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4463 | { | 4675 | { |
4464 | m_host.AddScriptLPS(1); | 4676 | m_host.AddScriptLPS(1); |
4465 | 4677 | ||
4466 | lock (m_host.TaskInventory) | 4678 | m_host.TaskInventory.LockItemsForRead(true); |
4679 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4467 | { | 4680 | { |
4468 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4681 | if (inv.Value.Name == name) |
4469 | { | 4682 | { |
4470 | if (inv.Value.Name == name) | 4683 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4471 | { | 4684 | { |
4472 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4685 | m_host.TaskInventory.LockItemsForRead(false); |
4473 | { | 4686 | return inv.Value.AssetID.ToString(); |
4474 | return inv.Value.AssetID.ToString(); | 4687 | } |
4475 | } | 4688 | else |
4476 | else | 4689 | { |
4477 | { | 4690 | m_host.TaskInventory.LockItemsForRead(false); |
4478 | return UUID.Zero.ToString(); | 4691 | return UUID.Zero.ToString(); |
4479 | } | ||
4480 | } | 4692 | } |
4481 | } | 4693 | } |
4482 | } | 4694 | } |
4695 | m_host.TaskInventory.LockItemsForRead(false); | ||
4483 | 4696 | ||
4484 | return UUID.Zero.ToString(); | 4697 | return UUID.Zero.ToString(); |
4485 | } | 4698 | } |
@@ -5065,7 +5278,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5065 | public LSL_Integer llGetRegionAgentCount() | 5278 | public LSL_Integer llGetRegionAgentCount() |
5066 | { | 5279 | { |
5067 | m_host.AddScriptLPS(1); | 5280 | m_host.AddScriptLPS(1); |
5068 | return new LSL_Integer(World.GetAvatars().Count); | 5281 | return new LSL_Integer(World.GetRootAgentCount()); |
5069 | } | 5282 | } |
5070 | 5283 | ||
5071 | public LSL_Vector llGetRegionCorner() | 5284 | public LSL_Vector llGetRegionCorner() |
@@ -5994,6 +6207,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5994 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6207 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
5995 | prules.OuterAngle = (float)tempf; | 6208 | prules.OuterAngle = (float)tempf; |
5996 | break; | 6209 | break; |
6210 | |||
6211 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6212 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6213 | prules.InnerAngle = (float)tempf; | ||
6214 | break; | ||
6215 | |||
6216 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6217 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6218 | prules.OuterAngle = (float)tempf; | ||
6219 | break; | ||
5997 | } | 6220 | } |
5998 | 6221 | ||
5999 | } | 6222 | } |
@@ -6032,14 +6255,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6032 | 6255 | ||
6033 | protected UUID GetTaskInventoryItem(string name) | 6256 | protected UUID GetTaskInventoryItem(string name) |
6034 | { | 6257 | { |
6035 | lock (m_host.TaskInventory) | 6258 | m_host.TaskInventory.LockItemsForRead(true); |
6259 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6036 | { | 6260 | { |
6037 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6261 | if (inv.Value.Name == name) |
6038 | { | 6262 | { |
6039 | if (inv.Value.Name == name) | 6263 | m_host.TaskInventory.LockItemsForRead(false); |
6040 | return inv.Key; | 6264 | return inv.Key; |
6041 | } | 6265 | } |
6042 | } | 6266 | } |
6267 | m_host.TaskInventory.LockItemsForRead(false); | ||
6043 | 6268 | ||
6044 | return UUID.Zero; | 6269 | return UUID.Zero; |
6045 | } | 6270 | } |
@@ -6367,22 +6592,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6367 | } | 6592 | } |
6368 | 6593 | ||
6369 | // copy the first script found with this inventory name | 6594 | // copy the first script found with this inventory name |
6370 | lock (m_host.TaskInventory) | 6595 | m_host.TaskInventory.LockItemsForRead(true); |
6596 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6371 | { | 6597 | { |
6372 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6598 | if (inv.Value.Name == name) |
6373 | { | 6599 | { |
6374 | if (inv.Value.Name == name) | 6600 | // make sure the object is a script |
6601 | if (10 == inv.Value.Type) | ||
6375 | { | 6602 | { |
6376 | // make sure the object is a script | 6603 | found = true; |
6377 | if (10 == inv.Value.Type) | 6604 | srcId = inv.Key; |
6378 | { | 6605 | break; |
6379 | found = true; | ||
6380 | srcId = inv.Key; | ||
6381 | break; | ||
6382 | } | ||
6383 | } | 6606 | } |
6384 | } | 6607 | } |
6385 | } | 6608 | } |
6609 | m_host.TaskInventory.LockItemsForRead(false); | ||
6386 | 6610 | ||
6387 | if (!found) | 6611 | if (!found) |
6388 | { | 6612 | { |
@@ -6466,6 +6690,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6466 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6690 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6467 | { | 6691 | { |
6468 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6692 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6693 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6694 | return shapeBlock; | ||
6469 | 6695 | ||
6470 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6696 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6471 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6697 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6536,6 +6762,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6536 | 6762 | ||
6537 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6763 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6538 | { | 6764 | { |
6765 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6766 | return; | ||
6767 | |||
6539 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6768 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6540 | 6769 | ||
6541 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6770 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6585,6 +6814,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6585 | 6814 | ||
6586 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6815 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6587 | { | 6816 | { |
6817 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6818 | return; | ||
6819 | |||
6588 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6820 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6589 | 6821 | ||
6590 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6822 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6627,6 +6859,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6627 | 6859 | ||
6628 | 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) | 6860 | 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) |
6629 | { | 6861 | { |
6862 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6863 | return; | ||
6864 | |||
6630 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6865 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6631 | 6866 | ||
6632 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6867 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6748,6 +6983,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6748 | 6983 | ||
6749 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6984 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6750 | { | 6985 | { |
6986 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6987 | return; | ||
6988 | |||
6751 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6989 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6752 | UUID sculptId; | 6990 | UUID sculptId; |
6753 | 6991 | ||
@@ -6788,7 +7026,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6788 | 7026 | ||
6789 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7027 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6790 | { | 7028 | { |
6791 | m_host.AddScriptLPS(1); | 7029 | m_host.AddScriptLPS(1); |
6792 | 7030 | ||
6793 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7031 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6794 | 7032 | ||
@@ -6803,6 +7041,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6803 | 7041 | ||
6804 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7042 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6805 | { | 7043 | { |
7044 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7045 | return; | ||
7046 | |||
6806 | int idx = 0; | 7047 | int idx = 0; |
6807 | 7048 | ||
6808 | while (idx < rules.Length) | 7049 | while (idx < rules.Length) |
@@ -7634,24 +7875,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7634 | break; | 7875 | break; |
7635 | 7876 | ||
7636 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7877 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7637 | // TODO-------------- | ||
7638 | if (remain < 1) | 7878 | if (remain < 1) |
7639 | return res; | 7879 | return res; |
7880 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7640 | 7881 | ||
7641 | face=(int)rules.GetLSLIntegerItem(idx++); | 7882 | tex = part.Shape.Textures; |
7642 | 7883 | int shiny; | |
7643 | res.Add(new LSL_Integer(0)); | 7884 | if (face == ScriptBaseClass.ALL_SIDES) |
7644 | res.Add(new LSL_Integer(0)); | 7885 | { |
7886 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7887 | { | ||
7888 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7889 | if (shinyness == Shininess.High) | ||
7890 | { | ||
7891 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7892 | } | ||
7893 | else if (shinyness == Shininess.Medium) | ||
7894 | { | ||
7895 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7896 | } | ||
7897 | else if (shinyness == Shininess.Low) | ||
7898 | { | ||
7899 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7900 | } | ||
7901 | else | ||
7902 | { | ||
7903 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7904 | } | ||
7905 | res.Add(new LSL_Integer(shiny)); | ||
7906 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7907 | } | ||
7908 | } | ||
7909 | else | ||
7910 | { | ||
7911 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7912 | if (shinyness == Shininess.High) | ||
7913 | { | ||
7914 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7915 | } | ||
7916 | else if (shinyness == Shininess.Medium) | ||
7917 | { | ||
7918 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7919 | } | ||
7920 | else if (shinyness == Shininess.Low) | ||
7921 | { | ||
7922 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7923 | } | ||
7924 | else | ||
7925 | { | ||
7926 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7927 | } | ||
7928 | res.Add(new LSL_Integer(shiny)); | ||
7929 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7930 | } | ||
7645 | break; | 7931 | break; |
7646 | 7932 | ||
7647 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7933 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7648 | // TODO-------------- | ||
7649 | if (remain < 1) | 7934 | if (remain < 1) |
7650 | return res; | 7935 | return res; |
7936 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7651 | 7937 | ||
7652 | face=(int)rules.GetLSLIntegerItem(idx++); | 7938 | tex = part.Shape.Textures; |
7653 | 7939 | int fullbright; | |
7654 | res.Add(new LSL_Integer(0)); | 7940 | if (face == ScriptBaseClass.ALL_SIDES) |
7941 | { | ||
7942 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7943 | { | ||
7944 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7945 | { | ||
7946 | fullbright = ScriptBaseClass.TRUE; | ||
7947 | } | ||
7948 | else | ||
7949 | { | ||
7950 | fullbright = ScriptBaseClass.FALSE; | ||
7951 | } | ||
7952 | res.Add(new LSL_Integer(fullbright)); | ||
7953 | } | ||
7954 | } | ||
7955 | else | ||
7956 | { | ||
7957 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7958 | { | ||
7959 | fullbright = ScriptBaseClass.TRUE; | ||
7960 | } | ||
7961 | else | ||
7962 | { | ||
7963 | fullbright = ScriptBaseClass.FALSE; | ||
7964 | } | ||
7965 | res.Add(new LSL_Integer(fullbright)); | ||
7966 | } | ||
7655 | break; | 7967 | break; |
7656 | 7968 | ||
7657 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7969 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7672,14 +7984,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7672 | break; | 7984 | break; |
7673 | 7985 | ||
7674 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 7986 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7675 | // TODO-------------- | ||
7676 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 7987 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7677 | if (remain < 1) | 7988 | if (remain < 1) |
7678 | return res; | 7989 | return res; |
7990 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7679 | 7991 | ||
7680 | face=(int)rules.GetLSLIntegerItem(idx++); | 7992 | tex = part.Shape.Textures; |
7681 | 7993 | if (face == ScriptBaseClass.ALL_SIDES) | |
7682 | res.Add(new LSL_Integer(0)); | 7994 | { |
7995 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7996 | { | ||
7997 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
7998 | { | ||
7999 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8000 | } | ||
8001 | else | ||
8002 | { | ||
8003 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8004 | } | ||
8005 | } | ||
8006 | } | ||
8007 | else | ||
8008 | { | ||
8009 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8010 | { | ||
8011 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8012 | } | ||
8013 | else | ||
8014 | { | ||
8015 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8016 | } | ||
8017 | } | ||
7683 | break; | 8018 | break; |
7684 | 8019 | ||
7685 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8020 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7698,13 +8033,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7698 | break; | 8033 | break; |
7699 | 8034 | ||
7700 | case (int)ScriptBaseClass.PRIM_GLOW: | 8035 | case (int)ScriptBaseClass.PRIM_GLOW: |
7701 | // TODO-------------- | ||
7702 | if (remain < 1) | 8036 | if (remain < 1) |
7703 | return res; | 8037 | return res; |
8038 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7704 | 8039 | ||
7705 | face=(int)rules.GetLSLIntegerItem(idx++); | 8040 | tex = part.Shape.Textures; |
7706 | 8041 | float primglow; | |
7707 | res.Add(new LSL_Float(0)); | 8042 | if (face == ScriptBaseClass.ALL_SIDES) |
8043 | { | ||
8044 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8045 | { | ||
8046 | primglow = tex.GetFace((uint)face).Glow; | ||
8047 | res.Add(new LSL_Float(primglow)); | ||
8048 | } | ||
8049 | } | ||
8050 | else | ||
8051 | { | ||
8052 | primglow = tex.GetFace((uint)face).Glow; | ||
8053 | res.Add(new LSL_Float(primglow)); | ||
8054 | } | ||
7708 | break; | 8055 | break; |
7709 | case (int)ScriptBaseClass.PRIM_TEXT: | 8056 | case (int)ScriptBaseClass.PRIM_TEXT: |
7710 | Color4 textColor = part.GetTextColor(); | 8057 | Color4 textColor = part.GetTextColor(); |
@@ -8241,28 +8588,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8241 | { | 8588 | { |
8242 | m_host.AddScriptLPS(1); | 8589 | m_host.AddScriptLPS(1); |
8243 | 8590 | ||
8244 | lock (m_host.TaskInventory) | 8591 | m_host.TaskInventory.LockItemsForRead(true); |
8592 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8245 | { | 8593 | { |
8246 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8594 | if (inv.Value.Name == item) |
8247 | { | 8595 | { |
8248 | if (inv.Value.Name == item) | 8596 | m_host.TaskInventory.LockItemsForRead(false); |
8597 | switch (mask) | ||
8249 | { | 8598 | { |
8250 | switch (mask) | 8599 | case 0: |
8251 | { | 8600 | return (int)inv.Value.BasePermissions; |
8252 | case 0: | 8601 | case 1: |
8253 | return (int)inv.Value.BasePermissions; | 8602 | return (int)inv.Value.CurrentPermissions; |
8254 | case 1: | 8603 | case 2: |
8255 | return (int)inv.Value.CurrentPermissions; | 8604 | return (int)inv.Value.GroupPermissions; |
8256 | case 2: | 8605 | case 3: |
8257 | return (int)inv.Value.GroupPermissions; | 8606 | return (int)inv.Value.EveryonePermissions; |
8258 | case 3: | 8607 | case 4: |
8259 | return (int)inv.Value.EveryonePermissions; | 8608 | return (int)inv.Value.NextPermissions; |
8260 | case 4: | ||
8261 | return (int)inv.Value.NextPermissions; | ||
8262 | } | ||
8263 | } | 8609 | } |
8264 | } | 8610 | } |
8265 | } | 8611 | } |
8612 | m_host.TaskInventory.LockItemsForRead(false); | ||
8266 | 8613 | ||
8267 | return -1; | 8614 | return -1; |
8268 | } | 8615 | } |
@@ -8309,16 +8656,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8309 | { | 8656 | { |
8310 | m_host.AddScriptLPS(1); | 8657 | m_host.AddScriptLPS(1); |
8311 | 8658 | ||
8312 | lock (m_host.TaskInventory) | 8659 | m_host.TaskInventory.LockItemsForRead(true); |
8660 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8313 | { | 8661 | { |
8314 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8662 | if (inv.Value.Name == item) |
8315 | { | 8663 | { |
8316 | if (inv.Value.Name == item) | 8664 | m_host.TaskInventory.LockItemsForRead(false); |
8317 | { | 8665 | return inv.Value.CreatorID.ToString(); |
8318 | return inv.Value.CreatorID.ToString(); | ||
8319 | } | ||
8320 | } | 8666 | } |
8321 | } | 8667 | } |
8668 | m_host.TaskInventory.LockItemsForRead(false); | ||
8322 | 8669 | ||
8323 | llSay(0, "No item name '" + item + "'"); | 8670 | llSay(0, "No item name '" + item + "'"); |
8324 | 8671 | ||
@@ -8578,17 +8925,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8578 | int width = 0; | 8925 | int width = 0; |
8579 | int height = 0; | 8926 | int height = 0; |
8580 | 8927 | ||
8581 | ParcelMediaCommandEnum? commandToSend = null; | 8928 | uint commandToSend = 0; |
8582 | float time = 0.0f; // default is from start | 8929 | float time = 0.0f; // default is from start |
8583 | 8930 | ||
8584 | ScenePresence presence = null; | 8931 | ScenePresence presence = null; |
8585 | 8932 | ||
8586 | for (int i = 0; i < commandList.Data.Length; i++) | 8933 | for (int i = 0; i < commandList.Data.Length; i++) |
8587 | { | 8934 | { |
8588 | ParcelMediaCommandEnum command = (ParcelMediaCommandEnum)commandList.Data[i]; | 8935 | uint command = (uint)(commandList.GetLSLIntegerItem(i)); |
8589 | switch (command) | 8936 | switch (command) |
8590 | { | 8937 | { |
8591 | case ParcelMediaCommandEnum.Agent: | 8938 | case (uint)ParcelMediaCommandEnum.Agent: |
8592 | // we send only to one agent | 8939 | // we send only to one agent |
8593 | if ((i + 1) < commandList.Length) | 8940 | if ((i + 1) < commandList.Length) |
8594 | { | 8941 | { |
@@ -8605,25 +8952,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8605 | } | 8952 | } |
8606 | break; | 8953 | break; |
8607 | 8954 | ||
8608 | case ParcelMediaCommandEnum.Loop: | 8955 | case (uint)ParcelMediaCommandEnum.Loop: |
8609 | loop = 1; | 8956 | loop = 1; |
8610 | commandToSend = command; | 8957 | commandToSend = command; |
8611 | update = true; //need to send the media update packet to set looping | 8958 | update = true; //need to send the media update packet to set looping |
8612 | break; | 8959 | break; |
8613 | 8960 | ||
8614 | case ParcelMediaCommandEnum.Play: | 8961 | case (uint)ParcelMediaCommandEnum.Play: |
8615 | loop = 0; | 8962 | loop = 0; |
8616 | commandToSend = command; | 8963 | commandToSend = command; |
8617 | update = true; //need to send the media update packet to make sure it doesn't loop | 8964 | update = true; //need to send the media update packet to make sure it doesn't loop |
8618 | break; | 8965 | break; |
8619 | 8966 | ||
8620 | case ParcelMediaCommandEnum.Pause: | 8967 | case (uint)ParcelMediaCommandEnum.Pause: |
8621 | case ParcelMediaCommandEnum.Stop: | 8968 | case (uint)ParcelMediaCommandEnum.Stop: |
8622 | case ParcelMediaCommandEnum.Unload: | 8969 | case (uint)ParcelMediaCommandEnum.Unload: |
8623 | commandToSend = command; | 8970 | commandToSend = command; |
8624 | break; | 8971 | break; |
8625 | 8972 | ||
8626 | case ParcelMediaCommandEnum.Url: | 8973 | case (uint)ParcelMediaCommandEnum.Url: |
8627 | if ((i + 1) < commandList.Length) | 8974 | if ((i + 1) < commandList.Length) |
8628 | { | 8975 | { |
8629 | if (commandList.Data[i + 1] is LSL_String) | 8976 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8636,7 +8983,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8636 | } | 8983 | } |
8637 | break; | 8984 | break; |
8638 | 8985 | ||
8639 | case ParcelMediaCommandEnum.Texture: | 8986 | case (uint)ParcelMediaCommandEnum.Texture: |
8640 | if ((i + 1) < commandList.Length) | 8987 | if ((i + 1) < commandList.Length) |
8641 | { | 8988 | { |
8642 | if (commandList.Data[i + 1] is LSL_String) | 8989 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8649,7 +8996,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8649 | } | 8996 | } |
8650 | break; | 8997 | break; |
8651 | 8998 | ||
8652 | case ParcelMediaCommandEnum.Time: | 8999 | case (uint)ParcelMediaCommandEnum.Time: |
8653 | if ((i + 1) < commandList.Length) | 9000 | if ((i + 1) < commandList.Length) |
8654 | { | 9001 | { |
8655 | if (commandList.Data[i + 1] is LSL_Float) | 9002 | if (commandList.Data[i + 1] is LSL_Float) |
@@ -8661,7 +9008,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8661 | } | 9008 | } |
8662 | break; | 9009 | break; |
8663 | 9010 | ||
8664 | case ParcelMediaCommandEnum.AutoAlign: | 9011 | case (uint)ParcelMediaCommandEnum.AutoAlign: |
8665 | if ((i + 1) < commandList.Length) | 9012 | if ((i + 1) < commandList.Length) |
8666 | { | 9013 | { |
8667 | if (commandList.Data[i + 1] is LSL_Integer) | 9014 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8675,7 +9022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8675 | } | 9022 | } |
8676 | break; | 9023 | break; |
8677 | 9024 | ||
8678 | case ParcelMediaCommandEnum.Type: | 9025 | case (uint)ParcelMediaCommandEnum.Type: |
8679 | if ((i + 1) < commandList.Length) | 9026 | if ((i + 1) < commandList.Length) |
8680 | { | 9027 | { |
8681 | if (commandList.Data[i + 1] is LSL_String) | 9028 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8688,7 +9035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8688 | } | 9035 | } |
8689 | break; | 9036 | break; |
8690 | 9037 | ||
8691 | case ParcelMediaCommandEnum.Desc: | 9038 | case (uint)ParcelMediaCommandEnum.Desc: |
8692 | if ((i + 1) < commandList.Length) | 9039 | if ((i + 1) < commandList.Length) |
8693 | { | 9040 | { |
8694 | if (commandList.Data[i + 1] is LSL_String) | 9041 | if (commandList.Data[i + 1] is LSL_String) |
@@ -8701,7 +9048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8701 | } | 9048 | } |
8702 | break; | 9049 | break; |
8703 | 9050 | ||
8704 | case ParcelMediaCommandEnum.Size: | 9051 | case (uint)ParcelMediaCommandEnum.Size: |
8705 | if ((i + 2) < commandList.Length) | 9052 | if ((i + 2) < commandList.Length) |
8706 | { | 9053 | { |
8707 | if (commandList.Data[i + 1] is LSL_Integer) | 9054 | if (commandList.Data[i + 1] is LSL_Integer) |
@@ -8769,7 +9116,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8769 | } | 9116 | } |
8770 | } | 9117 | } |
8771 | 9118 | ||
8772 | if (commandToSend != null) | 9119 | if (commandToSend != 0) |
8773 | { | 9120 | { |
8774 | // the commandList contained a start/stop/... command, too | 9121 | // the commandList contained a start/stop/... command, too |
8775 | if (presence == null) | 9122 | if (presence == null) |
@@ -8847,16 +9194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8847 | { | 9194 | { |
8848 | m_host.AddScriptLPS(1); | 9195 | m_host.AddScriptLPS(1); |
8849 | 9196 | ||
8850 | lock (m_host.TaskInventory) | 9197 | m_host.TaskInventory.LockItemsForRead(true); |
9198 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8851 | { | 9199 | { |
8852 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9200 | if (inv.Value.Name == name) |
8853 | { | 9201 | { |
8854 | if (inv.Value.Name == name) | 9202 | m_host.TaskInventory.LockItemsForRead(false); |
8855 | { | 9203 | return inv.Value.Type; |
8856 | return inv.Value.Type; | ||
8857 | } | ||
8858 | } | 9204 | } |
8859 | } | 9205 | } |
9206 | m_host.TaskInventory.LockItemsForRead(false); | ||
8860 | 9207 | ||
8861 | return -1; | 9208 | return -1; |
8862 | } | 9209 | } |
@@ -8867,15 +9214,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8867 | 9214 | ||
8868 | if (quick_pay_buttons.Data.Length < 4) | 9215 | if (quick_pay_buttons.Data.Length < 4) |
8869 | { | 9216 | { |
8870 | LSLError("List must have at least 4 elements"); | 9217 | int x; |
8871 | return; | 9218 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9219 | { | ||
9220 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9221 | } | ||
8872 | } | 9222 | } |
8873 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9223 | int[] nPrice = new int[5]; |
8874 | 9224 | nPrice[0]=price; | |
8875 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9225 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8876 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9226 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8877 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9227 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8878 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9228 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9229 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8879 | m_host.ParentGroup.HasGroupChanged = true; | 9230 | m_host.ParentGroup.HasGroupChanged = true; |
8880 | } | 9231 | } |
8881 | 9232 | ||
@@ -8887,17 +9238,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8887 | if (invItemID == UUID.Zero) | 9238 | if (invItemID == UUID.Zero) |
8888 | return new LSL_Vector(); | 9239 | return new LSL_Vector(); |
8889 | 9240 | ||
8890 | lock (m_host.TaskInventory) | 9241 | m_host.TaskInventory.LockItemsForRead(true); |
9242 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8891 | { | 9243 | { |
8892 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9244 | m_host.TaskInventory.LockItemsForRead(false); |
8893 | return new LSL_Vector(); | 9245 | return new LSL_Vector(); |
9246 | } | ||
8894 | 9247 | ||
8895 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9248 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8896 | { | 9249 | { |
8897 | ShoutError("No permissions to track the camera"); | 9250 | ShoutError("No permissions to track the camera"); |
8898 | return new LSL_Vector(); | 9251 | m_host.TaskInventory.LockItemsForRead(false); |
8899 | } | 9252 | return new LSL_Vector(); |
8900 | } | 9253 | } |
9254 | m_host.TaskInventory.LockItemsForRead(false); | ||
8901 | 9255 | ||
8902 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9256 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8903 | if (presence != null) | 9257 | if (presence != null) |
@@ -8915,17 +9269,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8915 | if (invItemID == UUID.Zero) | 9269 | if (invItemID == UUID.Zero) |
8916 | return new LSL_Rotation(); | 9270 | return new LSL_Rotation(); |
8917 | 9271 | ||
8918 | lock (m_host.TaskInventory) | 9272 | m_host.TaskInventory.LockItemsForRead(true); |
9273 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8919 | { | 9274 | { |
8920 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9275 | m_host.TaskInventory.LockItemsForRead(false); |
8921 | return new LSL_Rotation(); | 9276 | return new LSL_Rotation(); |
8922 | |||
8923 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8924 | { | ||
8925 | ShoutError("No permissions to track the camera"); | ||
8926 | return new LSL_Rotation(); | ||
8927 | } | ||
8928 | } | 9277 | } |
9278 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
9279 | { | ||
9280 | ShoutError("No permissions to track the camera"); | ||
9281 | m_host.TaskInventory.LockItemsForRead(false); | ||
9282 | return new LSL_Rotation(); | ||
9283 | } | ||
9284 | m_host.TaskInventory.LockItemsForRead(false); | ||
8929 | 9285 | ||
8930 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9286 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8931 | if (presence != null) | 9287 | if (presence != null) |
@@ -9075,14 +9431,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9075 | if (objectID == UUID.Zero) return; | 9431 | if (objectID == UUID.Zero) return; |
9076 | 9432 | ||
9077 | UUID agentID; | 9433 | UUID agentID; |
9078 | lock (m_host.TaskInventory) | 9434 | m_host.TaskInventory.LockItemsForRead(true); |
9079 | { | 9435 | // we need the permission first, to know which avatar we want to set the camera for |
9080 | // we need the permission first, to know which avatar we want to set the camera for | 9436 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9081 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9082 | 9437 | ||
9083 | if (agentID == UUID.Zero) return; | 9438 | if (agentID == UUID.Zero) |
9084 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9439 | { |
9440 | m_host.TaskInventory.LockItemsForRead(false); | ||
9441 | return; | ||
9442 | } | ||
9443 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9444 | { | ||
9445 | m_host.TaskInventory.LockItemsForRead(false); | ||
9446 | return; | ||
9085 | } | 9447 | } |
9448 | m_host.TaskInventory.LockItemsForRead(false); | ||
9086 | 9449 | ||
9087 | ScenePresence presence = World.GetScenePresence(agentID); | 9450 | ScenePresence presence = World.GetScenePresence(agentID); |
9088 | 9451 | ||
@@ -9132,12 +9495,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9132 | 9495 | ||
9133 | // we need the permission first, to know which avatar we want to clear the camera for | 9496 | // we need the permission first, to know which avatar we want to clear the camera for |
9134 | UUID agentID; | 9497 | UUID agentID; |
9135 | lock (m_host.TaskInventory) | 9498 | m_host.TaskInventory.LockItemsForRead(true); |
9499 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9500 | if (agentID == UUID.Zero) | ||
9136 | { | 9501 | { |
9137 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9502 | m_host.TaskInventory.LockItemsForRead(false); |
9138 | if (agentID == UUID.Zero) return; | 9503 | return; |
9139 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9140 | } | 9504 | } |
9505 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9506 | { | ||
9507 | m_host.TaskInventory.LockItemsForRead(false); | ||
9508 | return; | ||
9509 | } | ||
9510 | m_host.TaskInventory.LockItemsForRead(false); | ||
9141 | 9511 | ||
9142 | ScenePresence presence = World.GetScenePresence(agentID); | 9512 | ScenePresence presence = World.GetScenePresence(agentID); |
9143 | 9513 | ||
@@ -9594,15 +9964,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9594 | 9964 | ||
9595 | internal UUID ScriptByName(string name) | 9965 | internal UUID ScriptByName(string name) |
9596 | { | 9966 | { |
9597 | lock (m_host.TaskInventory) | 9967 | m_host.TaskInventory.LockItemsForRead(true); |
9968 | |||
9969 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9598 | { | 9970 | { |
9599 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9971 | if (item.Type == 10 && item.Name == name) |
9600 | { | 9972 | { |
9601 | if (item.Type == 10 && item.Name == name) | 9973 | m_host.TaskInventory.LockItemsForRead(false); |
9602 | return item.ItemID; | 9974 | return item.ItemID; |
9603 | } | 9975 | } |
9604 | } | 9976 | } |
9605 | 9977 | ||
9978 | m_host.TaskInventory.LockItemsForRead(false); | ||
9979 | |||
9606 | return UUID.Zero; | 9980 | return UUID.Zero; |
9607 | } | 9981 | } |
9608 | 9982 | ||
@@ -9643,6 +10017,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9643 | { | 10017 | { |
9644 | m_host.AddScriptLPS(1); | 10018 | m_host.AddScriptLPS(1); |
9645 | 10019 | ||
10020 | //Clone is thread safe | ||
9646 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10021 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9647 | 10022 | ||
9648 | UUID assetID = UUID.Zero; | 10023 | UUID assetID = UUID.Zero; |
@@ -9705,6 +10080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9705 | { | 10080 | { |
9706 | m_host.AddScriptLPS(1); | 10081 | m_host.AddScriptLPS(1); |
9707 | 10082 | ||
10083 | //Clone is thread safe | ||
9708 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10084 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9709 | 10085 | ||
9710 | UUID assetID = UUID.Zero; | 10086 | 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; |