diff options
Diffstat (limited to '')
13 files changed, 1455 insertions, 429 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs new file mode 100644 index 0000000..99973b4 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,477 @@ | |||
1 | using System; | ||
2 | using System.Reflection; | ||
3 | using System.Collections; | ||
4 | using System.Collections.Generic; | ||
5 | using System.Runtime.Remoting.Lifetime; | ||
6 | using OpenMetaverse; | ||
7 | using Nini.Config; | ||
8 | using OpenSim; | ||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Region.CoreModules.World.Meta7Windlight; | ||
11 | using OpenSim.Region.Framework.Interfaces; | ||
12 | using OpenSim.Region.Framework.Scenes; | ||
13 | using OpenSim.Region.ScriptEngine.Shared; | ||
14 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
15 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
16 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
17 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
18 | |||
19 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
20 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
21 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
22 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
23 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
24 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
25 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
26 | |||
27 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
28 | { | ||
29 | [Serializable] | ||
30 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
31 | { | ||
32 | internal IScriptEngine m_ScriptEngine; | ||
33 | internal SceneObjectPart m_host; | ||
34 | internal uint m_localID; | ||
35 | internal UUID m_itemID; | ||
36 | internal bool m_CMFunctionsEnabled = false; | ||
37 | internal IScriptModuleComms m_comms = null; | ||
38 | |||
39 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
40 | { | ||
41 | m_ScriptEngine = ScriptEngine; | ||
42 | m_host = host; | ||
43 | m_localID = localID; | ||
44 | m_itemID = itemID; | ||
45 | |||
46 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
47 | m_CMFunctionsEnabled = true; | ||
48 | |||
49 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
50 | if (m_comms == null) | ||
51 | m_CMFunctionsEnabled = false; | ||
52 | } | ||
53 | |||
54 | public override Object InitializeLifetimeService() | ||
55 | { | ||
56 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
57 | |||
58 | if (lease.CurrentState == LeaseState.Initial) | ||
59 | { | ||
60 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
61 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
62 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
63 | } | ||
64 | return lease; | ||
65 | } | ||
66 | |||
67 | public Scene World | ||
68 | { | ||
69 | get { return m_ScriptEngine.World; } | ||
70 | } | ||
71 | |||
72 | // | ||
73 | //Dumps an error message on the debug console. | ||
74 | // | ||
75 | |||
76 | internal void CMShoutError(string message) | ||
77 | { | ||
78 | if (message.Length > 1023) | ||
79 | message = message.Substring(0, 1023); | ||
80 | |||
81 | World.SimChat(Utils.StringToBytes(message), | ||
82 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
83 | |||
84 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
85 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// Get the current Windlight scene | ||
90 | /// </summary> | ||
91 | /// <returns>List of windlight parameters</returns> | ||
92 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
93 | { | ||
94 | if (!m_CMFunctionsEnabled) | ||
95 | { | ||
96 | CMShoutError("Careminster functions are not enabled."); | ||
97 | return new LSL_List(); | ||
98 | } | ||
99 | m_host.AddScriptLPS(1); | ||
100 | RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
101 | |||
102 | LSL_List values = new LSL_List(); | ||
103 | int idx = 0; | ||
104 | while (idx < rules.Length) | ||
105 | { | ||
106 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
107 | LSL_List toadd = new LSL_List(); | ||
108 | |||
109 | switch (rule) | ||
110 | { | ||
111 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
112 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
113 | break; | ||
114 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
115 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
116 | break; | ||
117 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
118 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
119 | break; | ||
120 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
121 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
122 | break; | ||
123 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
124 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
125 | break; | ||
126 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
127 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
128 | break; | ||
129 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
130 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
131 | break; | ||
132 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
133 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
134 | break; | ||
135 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
136 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
137 | break; | ||
138 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
139 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
140 | break; | ||
141 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
142 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
143 | break; | ||
144 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
145 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
146 | break; | ||
147 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
148 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
149 | break; | ||
150 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
151 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
152 | break; | ||
153 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
154 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
155 | break; | ||
156 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
157 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
158 | break; | ||
159 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
160 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
161 | break; | ||
162 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
163 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
164 | break; | ||
165 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
166 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
167 | break; | ||
168 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
169 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
170 | break; | ||
171 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
172 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
173 | break; | ||
174 | case (int)ScriptBaseClass.WL_HORIZON: | ||
175 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
176 | break; | ||
177 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
178 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
179 | break; | ||
180 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
181 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
182 | break; | ||
183 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
184 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
185 | break; | ||
186 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
187 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
188 | break; | ||
189 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
190 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
191 | break; | ||
192 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
193 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
194 | break; | ||
195 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
196 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
197 | break; | ||
198 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
199 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
200 | break; | ||
201 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
202 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
203 | break; | ||
204 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
205 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
206 | break; | ||
207 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
208 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
209 | break; | ||
210 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
211 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
212 | break; | ||
213 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
214 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
215 | break; | ||
216 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
217 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
218 | break; | ||
219 | } | ||
220 | |||
221 | if (toadd.Length > 0) | ||
222 | { | ||
223 | values.Add(rule); | ||
224 | values.Add(toadd.Data[0]); | ||
225 | } | ||
226 | idx++; | ||
227 | } | ||
228 | |||
229 | |||
230 | return values; | ||
231 | |||
232 | } | ||
233 | |||
234 | private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) | ||
235 | { | ||
236 | RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
237 | |||
238 | LSL_List values = new LSL_List(); | ||
239 | int idx = 0; | ||
240 | while (idx < rules.Length) | ||
241 | { | ||
242 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
243 | LSL_Types.Quaternion iQ; | ||
244 | LSL_Types.Vector3 iV; | ||
245 | switch (rule) | ||
246 | { | ||
247 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | ||
248 | idx++; | ||
249 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | ||
250 | break; | ||
251 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
252 | idx++; | ||
253 | iQ = rules.GetQuaternionItem(idx); | ||
254 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
255 | break; | ||
256 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
257 | idx++; | ||
258 | iV = rules.GetVector3Item(idx); | ||
259 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
260 | break; | ||
261 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
262 | idx++; | ||
263 | iQ = rules.GetQuaternionItem(idx); | ||
264 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
265 | break; | ||
266 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
267 | idx++; | ||
268 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
269 | break; | ||
270 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
271 | idx++; | ||
272 | iQ = rules.GetQuaternionItem(idx); | ||
273 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
274 | break; | ||
275 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
276 | idx++; | ||
277 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
278 | break; | ||
279 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
280 | idx++; | ||
281 | iV = rules.GetVector3Item(idx); | ||
282 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
283 | break; | ||
284 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
285 | idx++; | ||
286 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
289 | idx++; | ||
290 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
291 | break; | ||
292 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
293 | idx++; | ||
294 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
295 | break; | ||
296 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
297 | idx++; | ||
298 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
299 | break; | ||
300 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
301 | idx++; | ||
302 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
303 | break; | ||
304 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
305 | idx++; | ||
306 | iV = rules.GetVector3Item(idx); | ||
307 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
308 | break; | ||
309 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
310 | idx++; | ||
311 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
312 | break; | ||
313 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
314 | idx++; | ||
315 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
316 | break; | ||
317 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
318 | idx++; | ||
319 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
320 | break; | ||
321 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
322 | idx++; | ||
323 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
324 | break; | ||
325 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
326 | idx++; | ||
327 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
328 | break; | ||
329 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
330 | idx++; | ||
331 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
332 | break; | ||
333 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
334 | idx++; | ||
335 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
336 | break; | ||
337 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
338 | idx++; | ||
339 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
340 | break; | ||
341 | case (int)ScriptBaseClass.WL_HORIZON: | ||
342 | idx++; | ||
343 | iQ = rules.GetQuaternionItem(idx); | ||
344 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
345 | break; | ||
346 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
347 | idx++; | ||
348 | iV = rules.GetVector3Item(idx); | ||
349 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
350 | break; | ||
351 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
352 | idx++; | ||
353 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
354 | break; | ||
355 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
356 | idx++; | ||
357 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
358 | break; | ||
359 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
360 | idx++; | ||
361 | iV = rules.GetVector3Item(idx); | ||
362 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
365 | idx++; | ||
366 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
369 | idx++; | ||
370 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
371 | break; | ||
372 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
373 | idx++; | ||
374 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
375 | break; | ||
376 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
377 | idx++; | ||
378 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
379 | break; | ||
380 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
381 | idx++; | ||
382 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
383 | break; | ||
384 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
385 | idx++; | ||
386 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
387 | break; | ||
388 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
389 | idx++; | ||
390 | iQ = rules.GetQuaternionItem(idx); | ||
391 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
392 | break; | ||
393 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
394 | idx++; | ||
395 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
396 | break; | ||
397 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
398 | idx++; | ||
399 | iV = rules.GetVector3Item(idx); | ||
400 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
401 | break; | ||
402 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
403 | idx++; | ||
404 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
405 | break; | ||
406 | } | ||
407 | idx++; | ||
408 | } | ||
409 | return wl; | ||
410 | } | ||
411 | /// <summary> | ||
412 | /// Set the current Windlight scene | ||
413 | /// </summary> | ||
414 | /// <param name="rules"></param> | ||
415 | /// <returns>success: true or false</returns> | ||
416 | public int cmSetWindlightScene(LSL_List rules) | ||
417 | { | ||
418 | if (!m_CMFunctionsEnabled) | ||
419 | { | ||
420 | CMShoutError("Careminster functions are not enabled."); | ||
421 | return 0; | ||
422 | } | ||
423 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
424 | { | ||
425 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
426 | return 0; | ||
427 | } | ||
428 | int success = 0; | ||
429 | m_host.AddScriptLPS(1); | ||
430 | if (Meta7WindlightModule.EnableWindlight) | ||
431 | { | ||
432 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
433 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
434 | success = 1; | ||
435 | } | ||
436 | else | ||
437 | { | ||
438 | CMShoutError("Windlight module is disabled"); | ||
439 | return 0; | ||
440 | } | ||
441 | return success; | ||
442 | } | ||
443 | /// <summary> | ||
444 | /// Set the current Windlight scene to a target avatar | ||
445 | /// </summary> | ||
446 | /// <param name="rules"></param> | ||
447 | /// <returns>success: true or false</returns> | ||
448 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
449 | { | ||
450 | if (!m_CMFunctionsEnabled) | ||
451 | { | ||
452 | CMShoutError("Careminster functions are not enabled."); | ||
453 | return 0; | ||
454 | } | ||
455 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
456 | { | ||
457 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
458 | return 0; | ||
459 | } | ||
460 | int success = 0; | ||
461 | m_host.AddScriptLPS(1); | ||
462 | if (Meta7WindlightModule.EnableWindlight) | ||
463 | { | ||
464 | RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); | ||
465 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
466 | success = 1; | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | CMShoutError("Windlight module is disabled"); | ||
471 | return 0; | ||
472 | } | ||
473 | return success; | ||
474 | } | ||
475 | |||
476 | } | ||
477 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3ccbb3a..3f630f4 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) |
@@ -2756,10 +2900,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2756 | // the angles of rotation in radians into rotation value | 2900 | // the angles of rotation in radians into rotation value |
2757 | 2901 | ||
2758 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | 2902 | LSL_Types.Quaternion rot = llEuler2Rot(angle); |
2903 | /* | ||
2759 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | 2904 | Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); |
2760 | m_host.startLookAt(rotation, (float)damping, (float)strength); | 2905 | m_host.startLookAt(rotation, (float)damping, (float)strength); |
2906 | This would only work if your physics system contains an APID controller */ | ||
2761 | // Orient the object to the angle calculated | 2907 | // Orient the object to the angle calculated |
2762 | //llSetRot(rot); | 2908 | llSetRot(rot); |
2909 | } | ||
2910 | |||
2911 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
2912 | { | ||
2913 | m_host.AddScriptLPS(1); | ||
2914 | // NotImplemented("llRotLookAt"); | ||
2915 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
2916 | |||
2763 | } | 2917 | } |
2764 | 2918 | ||
2765 | public void llStopLookAt() | 2919 | public void llStopLookAt() |
@@ -2808,13 +2962,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2808 | { | 2962 | { |
2809 | TaskInventoryItem item; | 2963 | TaskInventoryItem item; |
2810 | 2964 | ||
2811 | lock (m_host.TaskInventory) | 2965 | m_host.TaskInventory.LockItemsForRead(true); |
2966 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2812 | { | 2967 | { |
2813 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 2968 | m_host.TaskInventory.LockItemsForRead(false); |
2814 | return; | 2969 | return; |
2815 | else | 2970 | } |
2816 | item = m_host.TaskInventory[InventorySelf()]; | 2971 | else |
2972 | { | ||
2973 | item = m_host.TaskInventory[InventorySelf()]; | ||
2817 | } | 2974 | } |
2975 | m_host.TaskInventory.LockItemsForRead(false); | ||
2818 | 2976 | ||
2819 | if (item.PermsGranter != UUID.Zero) | 2977 | if (item.PermsGranter != UUID.Zero) |
2820 | { | 2978 | { |
@@ -2836,13 +2994,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2836 | { | 2994 | { |
2837 | TaskInventoryItem item; | 2995 | TaskInventoryItem item; |
2838 | 2996 | ||
2997 | m_host.TaskInventory.LockItemsForRead(true); | ||
2839 | lock (m_host.TaskInventory) | 2998 | lock (m_host.TaskInventory) |
2840 | { | 2999 | { |
3000 | |||
2841 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3001 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) |
3002 | { | ||
3003 | m_host.TaskInventory.LockItemsForRead(false); | ||
2842 | return; | 3004 | return; |
3005 | } | ||
2843 | else | 3006 | else |
3007 | { | ||
2844 | item = m_host.TaskInventory[InventorySelf()]; | 3008 | item = m_host.TaskInventory[InventorySelf()]; |
3009 | } | ||
2845 | } | 3010 | } |
3011 | m_host.TaskInventory.LockItemsForRead(false); | ||
2846 | 3012 | ||
2847 | m_host.AddScriptLPS(1); | 3013 | m_host.AddScriptLPS(1); |
2848 | 3014 | ||
@@ -2879,14 +3045,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2879 | 3045 | ||
2880 | TaskInventoryItem item; | 3046 | TaskInventoryItem item; |
2881 | 3047 | ||
2882 | lock (m_host.TaskInventory) | 3048 | m_host.TaskInventory.LockItemsForRead(true); |
3049 | |||
3050 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2883 | { | 3051 | { |
2884 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3052 | m_host.TaskInventory.LockItemsForRead(false); |
2885 | return; | 3053 | return; |
2886 | else | 3054 | } |
2887 | item = m_host.TaskInventory[InventorySelf()]; | 3055 | else |
3056 | { | ||
3057 | item = m_host.TaskInventory[InventorySelf()]; | ||
2888 | } | 3058 | } |
2889 | 3059 | ||
3060 | m_host.TaskInventory.LockItemsForRead(false); | ||
3061 | |||
2890 | if (item.PermsGranter != m_host.OwnerID) | 3062 | if (item.PermsGranter != m_host.OwnerID) |
2891 | return; | 3063 | return; |
2892 | 3064 | ||
@@ -2913,13 +3085,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2913 | 3085 | ||
2914 | TaskInventoryItem item; | 3086 | TaskInventoryItem item; |
2915 | 3087 | ||
2916 | lock (m_host.TaskInventory) | 3088 | m_host.TaskInventory.LockItemsForRead(true); |
3089 | |||
3090 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
2917 | { | 3091 | { |
2918 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3092 | m_host.TaskInventory.LockItemsForRead(false); |
2919 | return; | 3093 | return; |
2920 | else | 3094 | } |
2921 | item = m_host.TaskInventory[InventorySelf()]; | 3095 | else |
3096 | { | ||
3097 | item = m_host.TaskInventory[InventorySelf()]; | ||
2922 | } | 3098 | } |
3099 | m_host.TaskInventory.LockItemsForRead(false); | ||
3100 | |||
2923 | 3101 | ||
2924 | if (item.PermsGranter != m_host.OwnerID) | 3102 | if (item.PermsGranter != m_host.OwnerID) |
2925 | return; | 3103 | return; |
@@ -2956,8 +3134,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2956 | return m_host.OwnerID.ToString(); | 3134 | return m_host.OwnerID.ToString(); |
2957 | } | 3135 | } |
2958 | 3136 | ||
3137 | [DebuggerNonUserCode] | ||
2959 | public void llInstantMessage(string user, string message) | 3138 | public void llInstantMessage(string user, string message) |
2960 | { | 3139 | { |
3140 | UUID result; | ||
3141 | if (!UUID.TryParse(user, out result)) | ||
3142 | { | ||
3143 | throw new Exception(String.Format("An invalid key of '{0} was passed to llInstantMessage", user)); | ||
3144 | return; | ||
3145 | } | ||
3146 | |||
3147 | |||
2961 | m_host.AddScriptLPS(1); | 3148 | m_host.AddScriptLPS(1); |
2962 | 3149 | ||
2963 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 3150 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
@@ -2972,7 +3159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2972 | UUID friendTransactionID = UUID.Random(); | 3159 | UUID friendTransactionID = UUID.Random(); |
2973 | 3160 | ||
2974 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | 3161 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); |
2975 | 3162 | ||
2976 | GridInstantMessage msg = new GridInstantMessage(); | 3163 | GridInstantMessage msg = new GridInstantMessage(); |
2977 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; | 3164 | msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid; |
2978 | msg.toAgentID = new Guid(user); // toAgentID.Guid; | 3165 | msg.toAgentID = new Guid(user); // toAgentID.Guid; |
@@ -3121,13 +3308,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3121 | m_host.AddScriptLPS(1); | 3308 | m_host.AddScriptLPS(1); |
3122 | } | 3309 | } |
3123 | 3310 | ||
3124 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3125 | { | ||
3126 | m_host.AddScriptLPS(1); | ||
3127 | Quaternion rot = new Quaternion((float)target.x, (float)target.y, (float)target.z, (float)target.s); | ||
3128 | m_host.RotLookAt(rot, (float)strength, (float)damping); | ||
3129 | } | ||
3130 | |||
3131 | public LSL_Integer llStringLength(string str) | 3311 | public LSL_Integer llStringLength(string str) |
3132 | { | 3312 | { |
3133 | m_host.AddScriptLPS(1); | 3313 | m_host.AddScriptLPS(1); |
@@ -3151,14 +3331,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3151 | 3331 | ||
3152 | TaskInventoryItem item; | 3332 | TaskInventoryItem item; |
3153 | 3333 | ||
3154 | lock (m_host.TaskInventory) | 3334 | m_host.TaskInventory.LockItemsForRead(true); |
3335 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3155 | { | 3336 | { |
3156 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3337 | m_host.TaskInventory.LockItemsForRead(false); |
3157 | return; | 3338 | return; |
3158 | else | ||
3159 | item = m_host.TaskInventory[InventorySelf()]; | ||
3160 | } | 3339 | } |
3161 | 3340 | else | |
3341 | { | ||
3342 | item = m_host.TaskInventory[InventorySelf()]; | ||
3343 | } | ||
3344 | m_host.TaskInventory.LockItemsForRead(false); | ||
3162 | if (item.PermsGranter == UUID.Zero) | 3345 | if (item.PermsGranter == UUID.Zero) |
3163 | return; | 3346 | return; |
3164 | 3347 | ||
@@ -3188,13 +3371,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3188 | 3371 | ||
3189 | TaskInventoryItem item; | 3372 | TaskInventoryItem item; |
3190 | 3373 | ||
3191 | lock (m_host.TaskInventory) | 3374 | m_host.TaskInventory.LockItemsForRead(true); |
3375 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3192 | { | 3376 | { |
3193 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3377 | m_host.TaskInventory.LockItemsForRead(false); |
3194 | return; | 3378 | return; |
3195 | else | 3379 | } |
3196 | item = m_host.TaskInventory[InventorySelf()]; | 3380 | else |
3381 | { | ||
3382 | item = m_host.TaskInventory[InventorySelf()]; | ||
3197 | } | 3383 | } |
3384 | m_host.TaskInventory.LockItemsForRead(false); | ||
3385 | |||
3198 | 3386 | ||
3199 | if (item.PermsGranter == UUID.Zero) | 3387 | if (item.PermsGranter == UUID.Zero) |
3200 | return; | 3388 | return; |
@@ -3271,10 +3459,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3271 | 3459 | ||
3272 | TaskInventoryItem item; | 3460 | TaskInventoryItem item; |
3273 | 3461 | ||
3274 | lock (m_host.TaskInventory) | 3462 | |
3463 | m_host.TaskInventory.LockItemsForRead(true); | ||
3464 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3465 | { | ||
3466 | m_host.TaskInventory.LockItemsForRead(false); | ||
3467 | return; | ||
3468 | } | ||
3469 | else | ||
3275 | { | 3470 | { |
3276 | item = m_host.TaskInventory[invItemID]; | 3471 | item = m_host.TaskInventory[invItemID]; |
3277 | } | 3472 | } |
3473 | m_host.TaskInventory.LockItemsForRead(false); | ||
3278 | 3474 | ||
3279 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3475 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3280 | { | 3476 | { |
@@ -3306,11 +3502,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3306 | 3502 | ||
3307 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3503 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3308 | { | 3504 | { |
3309 | lock (m_host.TaskInventory) | 3505 | m_host.TaskInventory.LockItemsForWrite(true); |
3310 | { | 3506 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3311 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3507 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3312 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3508 | m_host.TaskInventory.LockItemsForWrite(false); |
3313 | } | ||
3314 | 3509 | ||
3315 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3510 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3316 | "run_time_permissions", new Object[] { | 3511 | "run_time_permissions", new Object[] { |
@@ -3330,11 +3525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3330 | 3525 | ||
3331 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3526 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3332 | { | 3527 | { |
3333 | lock (m_host.TaskInventory) | 3528 | m_host.TaskInventory.LockItemsForWrite(true); |
3334 | { | 3529 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3335 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3530 | m_host.TaskInventory[invItemID].PermsMask = perm; |
3336 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3531 | m_host.TaskInventory.LockItemsForWrite(false); |
3337 | } | ||
3338 | 3532 | ||
3339 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3533 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3340 | "run_time_permissions", new Object[] { | 3534 | "run_time_permissions", new Object[] { |
@@ -3355,11 +3549,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3355 | 3549 | ||
3356 | if (!m_waitingForScriptAnswer) | 3550 | if (!m_waitingForScriptAnswer) |
3357 | { | 3551 | { |
3358 | lock (m_host.TaskInventory) | 3552 | m_host.TaskInventory.LockItemsForWrite(true); |
3359 | { | 3553 | m_host.TaskInventory[invItemID].PermsGranter = agentID; |
3360 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3554 | m_host.TaskInventory[invItemID].PermsMask = 0; |
3361 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3555 | m_host.TaskInventory.LockItemsForWrite(false); |
3362 | } | ||
3363 | 3556 | ||
3364 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3557 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
3365 | m_waitingForScriptAnswer=true; | 3558 | m_waitingForScriptAnswer=true; |
@@ -3394,10 +3587,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3394 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3587 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3395 | llReleaseControls(); | 3588 | llReleaseControls(); |
3396 | 3589 | ||
3397 | lock (m_host.TaskInventory) | 3590 | |
3398 | { | 3591 | m_host.TaskInventory.LockItemsForWrite(true); |
3399 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3592 | m_host.TaskInventory[invItemID].PermsMask = answer; |
3400 | } | 3593 | m_host.TaskInventory.LockItemsForWrite(false); |
3594 | |||
3401 | 3595 | ||
3402 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3596 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3403 | "run_time_permissions", new Object[] { | 3597 | "run_time_permissions", new Object[] { |
@@ -3409,16 +3603,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3409 | { | 3603 | { |
3410 | m_host.AddScriptLPS(1); | 3604 | m_host.AddScriptLPS(1); |
3411 | 3605 | ||
3412 | lock (m_host.TaskInventory) | 3606 | m_host.TaskInventory.LockItemsForRead(true); |
3607 | |||
3608 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3413 | { | 3609 | { |
3414 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3610 | if (item.Type == 10 && item.ItemID == m_itemID) |
3415 | { | 3611 | { |
3416 | if (item.Type == 10 && item.ItemID == m_itemID) | 3612 | m_host.TaskInventory.LockItemsForRead(false); |
3417 | { | 3613 | return item.PermsGranter.ToString(); |
3418 | return item.PermsGranter.ToString(); | ||
3419 | } | ||
3420 | } | 3614 | } |
3421 | } | 3615 | } |
3616 | m_host.TaskInventory.LockItemsForRead(false); | ||
3422 | 3617 | ||
3423 | return UUID.Zero.ToString(); | 3618 | return UUID.Zero.ToString(); |
3424 | } | 3619 | } |
@@ -3427,19 +3622,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3427 | { | 3622 | { |
3428 | m_host.AddScriptLPS(1); | 3623 | m_host.AddScriptLPS(1); |
3429 | 3624 | ||
3430 | lock (m_host.TaskInventory) | 3625 | m_host.TaskInventory.LockItemsForRead(true); |
3626 | |||
3627 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3431 | { | 3628 | { |
3432 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3629 | if (item.Type == 10 && item.ItemID == m_itemID) |
3433 | { | 3630 | { |
3434 | if (item.Type == 10 && item.ItemID == m_itemID) | 3631 | int perms = item.PermsMask; |
3435 | { | 3632 | if (m_automaticLinkPermission) |
3436 | int perms = item.PermsMask; | 3633 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3437 | if (m_automaticLinkPermission) | 3634 | m_host.TaskInventory.LockItemsForRead(false); |
3438 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | 3635 | return perms; |
3439 | return perms; | ||
3440 | } | ||
3441 | } | 3636 | } |
3442 | } | 3637 | } |
3638 | m_host.TaskInventory.LockItemsForRead(false); | ||
3443 | 3639 | ||
3444 | return 0; | 3640 | return 0; |
3445 | } | 3641 | } |
@@ -3472,11 +3668,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3472 | UUID invItemID = InventorySelf(); | 3668 | UUID invItemID = InventorySelf(); |
3473 | 3669 | ||
3474 | TaskInventoryItem item; | 3670 | TaskInventoryItem item; |
3475 | lock (m_host.TaskInventory) | 3671 | m_host.TaskInventory.LockItemsForRead(true); |
3476 | { | 3672 | item = m_host.TaskInventory[invItemID]; |
3477 | item = m_host.TaskInventory[invItemID]; | 3673 | m_host.TaskInventory.LockItemsForRead(false); |
3478 | } | 3674 | |
3479 | |||
3480 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3675 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3481 | && !m_automaticLinkPermission) | 3676 | && !m_automaticLinkPermission) |
3482 | { | 3677 | { |
@@ -3529,16 +3724,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3529 | m_host.AddScriptLPS(1); | 3724 | m_host.AddScriptLPS(1); |
3530 | UUID invItemID = InventorySelf(); | 3725 | UUID invItemID = InventorySelf(); |
3531 | 3726 | ||
3532 | lock (m_host.TaskInventory) | 3727 | m_host.TaskInventory.LockItemsForRead(true); |
3533 | { | ||
3534 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3728 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3535 | && !m_automaticLinkPermission) | 3729 | && !m_automaticLinkPermission) |
3536 | { | 3730 | { |
3537 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3731 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
3732 | m_host.TaskInventory.LockItemsForRead(false); | ||
3538 | return; | 3733 | return; |
3539 | } | 3734 | } |
3540 | } | 3735 | m_host.TaskInventory.LockItemsForRead(false); |
3541 | 3736 | ||
3542 | if (linknum < ScriptBaseClass.LINK_THIS) | 3737 | if (linknum < ScriptBaseClass.LINK_THIS) |
3543 | return; | 3738 | return; |
3544 | 3739 | ||
@@ -3715,17 +3910,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3715 | m_host.AddScriptLPS(1); | 3910 | m_host.AddScriptLPS(1); |
3716 | int count = 0; | 3911 | int count = 0; |
3717 | 3912 | ||
3718 | lock (m_host.TaskInventory) | 3913 | m_host.TaskInventory.LockItemsForRead(true); |
3914 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3719 | { | 3915 | { |
3720 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3916 | if (inv.Value.Type == type || type == -1) |
3721 | { | 3917 | { |
3722 | if (inv.Value.Type == type || type == -1) | 3918 | count = count + 1; |
3723 | { | ||
3724 | count = count + 1; | ||
3725 | } | ||
3726 | } | 3919 | } |
3727 | } | 3920 | } |
3728 | 3921 | ||
3922 | m_host.TaskInventory.LockItemsForRead(false); | ||
3729 | return count; | 3923 | return count; |
3730 | } | 3924 | } |
3731 | 3925 | ||
@@ -3734,16 +3928,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3734 | m_host.AddScriptLPS(1); | 3928 | m_host.AddScriptLPS(1); |
3735 | ArrayList keys = new ArrayList(); | 3929 | ArrayList keys = new ArrayList(); |
3736 | 3930 | ||
3737 | lock (m_host.TaskInventory) | 3931 | m_host.TaskInventory.LockItemsForRead(true); |
3932 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3738 | { | 3933 | { |
3739 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3934 | if (inv.Value.Type == type || type == -1) |
3740 | { | 3935 | { |
3741 | if (inv.Value.Type == type || type == -1) | 3936 | keys.Add(inv.Value.Name); |
3742 | { | ||
3743 | keys.Add(inv.Value.Name); | ||
3744 | } | ||
3745 | } | 3937 | } |
3746 | } | 3938 | } |
3939 | m_host.TaskInventory.LockItemsForRead(false); | ||
3747 | 3940 | ||
3748 | if (keys.Count == 0) | 3941 | if (keys.Count == 0) |
3749 | { | 3942 | { |
@@ -3780,20 +3973,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3780 | } | 3973 | } |
3781 | 3974 | ||
3782 | // move the first object found with this inventory name | 3975 | // move the first object found with this inventory name |
3783 | lock (m_host.TaskInventory) | 3976 | m_host.TaskInventory.LockItemsForRead(true); |
3977 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3784 | { | 3978 | { |
3785 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 3979 | if (inv.Value.Name == inventory) |
3786 | { | 3980 | { |
3787 | if (inv.Value.Name == inventory) | 3981 | found = true; |
3788 | { | 3982 | objId = inv.Key; |
3789 | found = true; | 3983 | assetType = inv.Value.Type; |
3790 | objId = inv.Key; | 3984 | objName = inv.Value.Name; |
3791 | assetType = inv.Value.Type; | 3985 | break; |
3792 | objName = inv.Value.Name; | ||
3793 | break; | ||
3794 | } | ||
3795 | } | 3986 | } |
3796 | } | 3987 | } |
3988 | m_host.TaskInventory.LockItemsForRead(false); | ||
3797 | 3989 | ||
3798 | if (!found) | 3990 | if (!found) |
3799 | { | 3991 | { |
@@ -3829,33 +4021,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3829 | 4021 | ||
3830 | if (m_TransferModule != null) | 4022 | if (m_TransferModule != null) |
3831 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 4023 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
4024 | |||
4025 | //This delay should only occur when giving inventory to avatars. | ||
4026 | ScriptSleep(3000); | ||
3832 | } | 4027 | } |
3833 | else | 4028 | else |
3834 | { | 4029 | { |
3835 | // destination is an object | 4030 | // destination is an object |
3836 | World.MoveTaskInventoryItem(destId, m_host, objId); | 4031 | World.MoveTaskInventoryItem(destId, m_host, objId); |
3837 | } | 4032 | } |
3838 | ScriptSleep(3000); | 4033 | |
3839 | } | 4034 | } |
3840 | 4035 | ||
4036 | [DebuggerNonUserCode] | ||
3841 | public void llRemoveInventory(string name) | 4037 | public void llRemoveInventory(string name) |
3842 | { | 4038 | { |
3843 | m_host.AddScriptLPS(1); | 4039 | m_host.AddScriptLPS(1); |
3844 | 4040 | ||
3845 | lock (m_host.TaskInventory) | 4041 | m_host.TaskInventory.LockItemsForRead(true); |
4042 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3846 | { | 4043 | { |
3847 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4044 | if (item.Name == name) |
3848 | { | 4045 | { |
3849 | if (item.Name == name) | 4046 | if (item.ItemID == m_itemID) |
3850 | { | 4047 | throw new ScriptDeleteException(); |
3851 | if (item.ItemID == m_itemID) | 4048 | else |
3852 | throw new ScriptDeleteException(); | 4049 | m_host.Inventory.RemoveInventoryItem(item.ItemID); |
3853 | else | 4050 | |
3854 | m_host.Inventory.RemoveInventoryItem(item.ItemID); | 4051 | m_host.TaskInventory.LockItemsForRead(false); |
3855 | return; | 4052 | return; |
3856 | } | ||
3857 | } | 4053 | } |
3858 | } | 4054 | } |
4055 | m_host.TaskInventory.LockItemsForRead(false); | ||
3859 | } | 4056 | } |
3860 | 4057 | ||
3861 | public void llSetText(string text, LSL_Vector color, double alpha) | 4058 | public void llSetText(string text, LSL_Vector color, double alpha) |
@@ -3944,6 +4141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3944 | { | 4141 | { |
3945 | m_host.AddScriptLPS(1); | 4142 | m_host.AddScriptLPS(1); |
3946 | 4143 | ||
4144 | //Clone is thread safe | ||
3947 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 4145 | TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
3948 | 4146 | ||
3949 | foreach (TaskInventoryItem item in itemDictionary.Values) | 4147 | foreach (TaskInventoryItem item in itemDictionary.Values) |
@@ -3997,6 +4195,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3997 | ScenePresence presence = World.GetScenePresence(agentId); | 4195 | ScenePresence presence = World.GetScenePresence(agentId); |
3998 | if (presence != null) | 4196 | if (presence != null) |
3999 | { | 4197 | { |
4198 | // agent must not be a god | ||
4199 | if (presence.GodLevel >= 200) return; | ||
4200 | |||
4000 | // agent must be over the owners land | 4201 | // agent must be over the owners land |
4001 | if (m_host.OwnerID == World.LandChannel.GetLandObject( | 4202 | if (m_host.OwnerID == World.LandChannel.GetLandObject( |
4002 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 4203 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
@@ -4057,17 +4258,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4057 | UUID soundId = UUID.Zero; | 4258 | UUID soundId = UUID.Zero; |
4058 | if (!UUID.TryParse(impact_sound, out soundId)) | 4259 | if (!UUID.TryParse(impact_sound, out soundId)) |
4059 | { | 4260 | { |
4060 | lock (m_host.TaskInventory) | 4261 | m_host.TaskInventory.LockItemsForRead(true); |
4262 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4061 | { | 4263 | { |
4062 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4264 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) |
4063 | { | 4265 | { |
4064 | if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) | 4266 | soundId = item.AssetID; |
4065 | { | 4267 | break; |
4066 | soundId = item.AssetID; | ||
4067 | break; | ||
4068 | } | ||
4069 | } | 4268 | } |
4070 | } | 4269 | } |
4270 | m_host.TaskInventory.LockItemsForRead(false); | ||
4071 | } | 4271 | } |
4072 | m_host.CollisionSound = soundId; | 4272 | m_host.CollisionSound = soundId; |
4073 | m_host.CollisionSoundVolume = (float)impact_volume; | 4273 | m_host.CollisionSoundVolume = (float)impact_volume; |
@@ -4113,6 +4313,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4113 | UUID partItemID; | 4313 | UUID partItemID; |
4114 | foreach (SceneObjectPart part in parts) | 4314 | foreach (SceneObjectPart part in parts) |
4115 | { | 4315 | { |
4316 | //Clone is thread safe | ||
4116 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); | 4317 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); |
4117 | 4318 | ||
4118 | foreach (TaskInventoryItem item in itemsDictionary.Values) | 4319 | foreach (TaskInventoryItem item in itemsDictionary.Values) |
@@ -4327,17 +4528,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4327 | 4528 | ||
4328 | m_host.AddScriptLPS(1); | 4529 | m_host.AddScriptLPS(1); |
4329 | 4530 | ||
4330 | lock (m_host.TaskInventory) | 4531 | m_host.TaskInventory.LockItemsForRead(true); |
4532 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
4331 | { | 4533 | { |
4332 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 4534 | if (item.Type == 10 && item.ItemID == m_itemID) |
4333 | { | 4535 | { |
4334 | if (item.Type == 10 && item.ItemID == m_itemID) | 4536 | result = item.Name!=null?item.Name:String.Empty; |
4335 | { | 4537 | break; |
4336 | result = item.Name != null ? item.Name : String.Empty; | ||
4337 | break; | ||
4338 | } | ||
4339 | } | 4538 | } |
4340 | } | 4539 | } |
4540 | m_host.TaskInventory.LockItemsForRead(false); | ||
4341 | 4541 | ||
4342 | return result; | 4542 | return result; |
4343 | } | 4543 | } |
@@ -4490,23 +4690,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4490 | { | 4690 | { |
4491 | m_host.AddScriptLPS(1); | 4691 | m_host.AddScriptLPS(1); |
4492 | 4692 | ||
4493 | lock (m_host.TaskInventory) | 4693 | m_host.TaskInventory.LockItemsForRead(true); |
4694 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
4494 | { | 4695 | { |
4495 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 4696 | if (inv.Value.Name == name) |
4496 | { | 4697 | { |
4497 | if (inv.Value.Name == name) | 4698 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) |
4498 | { | 4699 | { |
4499 | if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) | 4700 | m_host.TaskInventory.LockItemsForRead(false); |
4500 | { | 4701 | return inv.Value.AssetID.ToString(); |
4501 | return inv.Value.AssetID.ToString(); | 4702 | } |
4502 | } | 4703 | else |
4503 | else | 4704 | { |
4504 | { | 4705 | m_host.TaskInventory.LockItemsForRead(false); |
4505 | return UUID.Zero.ToString(); | 4706 | return UUID.Zero.ToString(); |
4506 | } | ||
4507 | } | 4707 | } |
4508 | } | 4708 | } |
4509 | } | 4709 | } |
4710 | m_host.TaskInventory.LockItemsForRead(false); | ||
4510 | 4711 | ||
4511 | return UUID.Zero.ToString(); | 4712 | return UUID.Zero.ToString(); |
4512 | } | 4713 | } |
@@ -6059,14 +6260,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6059 | 6260 | ||
6060 | protected UUID GetTaskInventoryItem(string name) | 6261 | protected UUID GetTaskInventoryItem(string name) |
6061 | { | 6262 | { |
6062 | lock (m_host.TaskInventory) | 6263 | m_host.TaskInventory.LockItemsForRead(true); |
6264 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6063 | { | 6265 | { |
6064 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6266 | if (inv.Value.Name == name) |
6065 | { | 6267 | { |
6066 | if (inv.Value.Name == name) | 6268 | m_host.TaskInventory.LockItemsForRead(false); |
6067 | return inv.Key; | 6269 | return inv.Key; |
6068 | } | 6270 | } |
6069 | } | 6271 | } |
6272 | m_host.TaskInventory.LockItemsForRead(false); | ||
6070 | 6273 | ||
6071 | return UUID.Zero; | 6274 | return UUID.Zero; |
6072 | } | 6275 | } |
@@ -6394,22 +6597,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6394 | } | 6597 | } |
6395 | 6598 | ||
6396 | // copy the first script found with this inventory name | 6599 | // copy the first script found with this inventory name |
6397 | lock (m_host.TaskInventory) | 6600 | m_host.TaskInventory.LockItemsForRead(true); |
6601 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
6398 | { | 6602 | { |
6399 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 6603 | if (inv.Value.Name == name) |
6400 | { | 6604 | { |
6401 | if (inv.Value.Name == name) | 6605 | // make sure the object is a script |
6606 | if (10 == inv.Value.Type) | ||
6402 | { | 6607 | { |
6403 | // make sure the object is a script | 6608 | found = true; |
6404 | if (10 == inv.Value.Type) | 6609 | srcId = inv.Key; |
6405 | { | 6610 | break; |
6406 | found = true; | ||
6407 | srcId = inv.Key; | ||
6408 | break; | ||
6409 | } | ||
6410 | } | 6611 | } |
6411 | } | 6612 | } |
6412 | } | 6613 | } |
6614 | m_host.TaskInventory.LockItemsForRead(false); | ||
6413 | 6615 | ||
6414 | if (!found) | 6616 | if (!found) |
6415 | { | 6617 | { |
@@ -6493,6 +6695,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6493 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 6695 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) |
6494 | { | 6696 | { |
6495 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6697 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6698 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6699 | return shapeBlock; | ||
6496 | 6700 | ||
6497 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && | 6701 | if (holeshape != (int)ScriptBaseClass.PRIM_HOLE_DEFAULT && |
6498 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && | 6702 | holeshape != (int)ScriptBaseClass.PRIM_HOLE_CIRCLE && |
@@ -6563,6 +6767,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6563 | 6767 | ||
6564 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 6768 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) |
6565 | { | 6769 | { |
6770 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6771 | return; | ||
6772 | |||
6566 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6773 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6567 | 6774 | ||
6568 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6775 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6612,6 +6819,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6612 | 6819 | ||
6613 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 6820 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) |
6614 | { | 6821 | { |
6822 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6823 | return; | ||
6824 | |||
6615 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6825 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6616 | 6826 | ||
6617 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6827 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6654,6 +6864,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6654 | 6864 | ||
6655 | 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) | 6865 | 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) |
6656 | { | 6866 | { |
6867 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6868 | return; | ||
6869 | |||
6657 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 6870 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
6658 | 6871 | ||
6659 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 6872 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); |
@@ -6775,6 +6988,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6775 | 6988 | ||
6776 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 6989 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) |
6777 | { | 6990 | { |
6991 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
6992 | return; | ||
6993 | |||
6778 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 6994 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
6779 | UUID sculptId; | 6995 | UUID sculptId; |
6780 | 6996 | ||
@@ -6815,7 +7031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6815 | 7031 | ||
6816 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7032 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
6817 | { | 7033 | { |
6818 | m_host.AddScriptLPS(1); | 7034 | m_host.AddScriptLPS(1); |
6819 | 7035 | ||
6820 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 7036 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6821 | 7037 | ||
@@ -6830,6 +7046,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6830 | 7046 | ||
6831 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) | 7047 | protected void SetPrimParams(SceneObjectPart part, LSL_List rules) |
6832 | { | 7048 | { |
7049 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | ||
7050 | return; | ||
7051 | |||
6833 | int idx = 0; | 7052 | int idx = 0; |
6834 | 7053 | ||
6835 | while (idx < rules.Length) | 7054 | while (idx < rules.Length) |
@@ -7661,24 +7880,95 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7661 | break; | 7880 | break; |
7662 | 7881 | ||
7663 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7882 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7664 | // TODO-------------- | ||
7665 | if (remain < 1) | 7883 | if (remain < 1) |
7666 | return res; | 7884 | return res; |
7885 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7667 | 7886 | ||
7668 | face=(int)rules.GetLSLIntegerItem(idx++); | 7887 | tex = part.Shape.Textures; |
7669 | 7888 | int shiny; | |
7670 | res.Add(new LSL_Integer(0)); | 7889 | if (face == ScriptBaseClass.ALL_SIDES) |
7671 | res.Add(new LSL_Integer(0)); | 7890 | { |
7891 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7892 | { | ||
7893 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7894 | if (shinyness == Shininess.High) | ||
7895 | { | ||
7896 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7897 | } | ||
7898 | else if (shinyness == Shininess.Medium) | ||
7899 | { | ||
7900 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7901 | } | ||
7902 | else if (shinyness == Shininess.Low) | ||
7903 | { | ||
7904 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7905 | } | ||
7906 | else | ||
7907 | { | ||
7908 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7909 | } | ||
7910 | res.Add(new LSL_Integer(shiny)); | ||
7911 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7912 | } | ||
7913 | } | ||
7914 | else | ||
7915 | { | ||
7916 | Shininess shinyness = tex.GetFace((uint)face).Shiny; | ||
7917 | if (shinyness == Shininess.High) | ||
7918 | { | ||
7919 | shiny = ScriptBaseClass.PRIM_SHINY_HIGH; | ||
7920 | } | ||
7921 | else if (shinyness == Shininess.Medium) | ||
7922 | { | ||
7923 | shiny = ScriptBaseClass.PRIM_SHINY_MEDIUM; | ||
7924 | } | ||
7925 | else if (shinyness == Shininess.Low) | ||
7926 | { | ||
7927 | shiny = ScriptBaseClass.PRIM_SHINY_LOW; | ||
7928 | } | ||
7929 | else | ||
7930 | { | ||
7931 | shiny = ScriptBaseClass.PRIM_SHINY_NONE; | ||
7932 | } | ||
7933 | res.Add(new LSL_Integer(shiny)); | ||
7934 | res.Add(new LSL_Integer((int)tex.GetFace((uint)face).Bump)); | ||
7935 | } | ||
7672 | break; | 7936 | break; |
7673 | 7937 | ||
7674 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7938 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7675 | // TODO-------------- | ||
7676 | if (remain < 1) | 7939 | if (remain < 1) |
7677 | return res; | 7940 | return res; |
7941 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7678 | 7942 | ||
7679 | face=(int)rules.GetLSLIntegerItem(idx++); | 7943 | tex = part.Shape.Textures; |
7680 | 7944 | int fullbright; | |
7681 | res.Add(new LSL_Integer(0)); | 7945 | if (face == ScriptBaseClass.ALL_SIDES) |
7946 | { | ||
7947 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
7948 | { | ||
7949 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7950 | { | ||
7951 | fullbright = ScriptBaseClass.TRUE; | ||
7952 | } | ||
7953 | else | ||
7954 | { | ||
7955 | fullbright = ScriptBaseClass.FALSE; | ||
7956 | } | ||
7957 | res.Add(new LSL_Integer(fullbright)); | ||
7958 | } | ||
7959 | } | ||
7960 | else | ||
7961 | { | ||
7962 | if (tex.GetFace((uint)face).Fullbright == true) | ||
7963 | { | ||
7964 | fullbright = ScriptBaseClass.TRUE; | ||
7965 | } | ||
7966 | else | ||
7967 | { | ||
7968 | fullbright = ScriptBaseClass.FALSE; | ||
7969 | } | ||
7970 | res.Add(new LSL_Integer(fullbright)); | ||
7971 | } | ||
7682 | break; | 7972 | break; |
7683 | 7973 | ||
7684 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7974 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
@@ -7699,14 +7989,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7699 | break; | 7989 | break; |
7700 | 7990 | ||
7701 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 7991 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
7702 | // TODO-------------- | ||
7703 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 7992 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
7704 | if (remain < 1) | 7993 | if (remain < 1) |
7705 | return res; | 7994 | return res; |
7995 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7706 | 7996 | ||
7707 | face=(int)rules.GetLSLIntegerItem(idx++); | 7997 | tex = part.Shape.Textures; |
7708 | 7998 | if (face == ScriptBaseClass.ALL_SIDES) | |
7709 | res.Add(new LSL_Integer(0)); | 7999 | { |
8000 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8001 | { | ||
8002 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8003 | { | ||
8004 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8005 | } | ||
8006 | else | ||
8007 | { | ||
8008 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8009 | } | ||
8010 | } | ||
8011 | } | ||
8012 | else | ||
8013 | { | ||
8014 | if (tex.GetFace((uint)face).TexMapType == MappingType.Planar) | ||
8015 | { | ||
8016 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_PLANAR)); | ||
8017 | } | ||
8018 | else | ||
8019 | { | ||
8020 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
8021 | } | ||
8022 | } | ||
7710 | break; | 8023 | break; |
7711 | 8024 | ||
7712 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 8025 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
@@ -7725,13 +8038,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7725 | break; | 8038 | break; |
7726 | 8039 | ||
7727 | case (int)ScriptBaseClass.PRIM_GLOW: | 8040 | case (int)ScriptBaseClass.PRIM_GLOW: |
7728 | // TODO-------------- | ||
7729 | if (remain < 1) | 8041 | if (remain < 1) |
7730 | return res; | 8042 | return res; |
8043 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
7731 | 8044 | ||
7732 | face=(int)rules.GetLSLIntegerItem(idx++); | 8045 | tex = part.Shape.Textures; |
7733 | 8046 | float primglow; | |
7734 | res.Add(new LSL_Float(0)); | 8047 | if (face == ScriptBaseClass.ALL_SIDES) |
8048 | { | ||
8049 | for (face = 0; face < GetNumberOfSides(part); face++) | ||
8050 | { | ||
8051 | primglow = tex.GetFace((uint)face).Glow; | ||
8052 | res.Add(new LSL_Float(primglow)); | ||
8053 | } | ||
8054 | } | ||
8055 | else | ||
8056 | { | ||
8057 | primglow = tex.GetFace((uint)face).Glow; | ||
8058 | res.Add(new LSL_Float(primglow)); | ||
8059 | } | ||
7735 | break; | 8060 | break; |
7736 | case (int)ScriptBaseClass.PRIM_TEXT: | 8061 | case (int)ScriptBaseClass.PRIM_TEXT: |
7737 | Color4 textColor = part.GetTextColor(); | 8062 | Color4 textColor = part.GetTextColor(); |
@@ -8268,28 +8593,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8268 | { | 8593 | { |
8269 | m_host.AddScriptLPS(1); | 8594 | m_host.AddScriptLPS(1); |
8270 | 8595 | ||
8271 | lock (m_host.TaskInventory) | 8596 | m_host.TaskInventory.LockItemsForRead(true); |
8597 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8272 | { | 8598 | { |
8273 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8599 | if (inv.Value.Name == item) |
8274 | { | 8600 | { |
8275 | if (inv.Value.Name == item) | 8601 | m_host.TaskInventory.LockItemsForRead(false); |
8602 | switch (mask) | ||
8276 | { | 8603 | { |
8277 | switch (mask) | 8604 | case 0: |
8278 | { | 8605 | return (int)inv.Value.BasePermissions; |
8279 | case 0: | 8606 | case 1: |
8280 | return (int)inv.Value.BasePermissions; | 8607 | return (int)inv.Value.CurrentPermissions; |
8281 | case 1: | 8608 | case 2: |
8282 | return (int)inv.Value.CurrentPermissions; | 8609 | return (int)inv.Value.GroupPermissions; |
8283 | case 2: | 8610 | case 3: |
8284 | return (int)inv.Value.GroupPermissions; | 8611 | return (int)inv.Value.EveryonePermissions; |
8285 | case 3: | 8612 | case 4: |
8286 | return (int)inv.Value.EveryonePermissions; | 8613 | return (int)inv.Value.NextPermissions; |
8287 | case 4: | ||
8288 | return (int)inv.Value.NextPermissions; | ||
8289 | } | ||
8290 | } | 8614 | } |
8291 | } | 8615 | } |
8292 | } | 8616 | } |
8617 | m_host.TaskInventory.LockItemsForRead(false); | ||
8293 | 8618 | ||
8294 | return -1; | 8619 | return -1; |
8295 | } | 8620 | } |
@@ -8336,16 +8661,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8336 | { | 8661 | { |
8337 | m_host.AddScriptLPS(1); | 8662 | m_host.AddScriptLPS(1); |
8338 | 8663 | ||
8339 | lock (m_host.TaskInventory) | 8664 | m_host.TaskInventory.LockItemsForRead(true); |
8665 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8340 | { | 8666 | { |
8341 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 8667 | if (inv.Value.Name == item) |
8342 | { | 8668 | { |
8343 | if (inv.Value.Name == item) | 8669 | m_host.TaskInventory.LockItemsForRead(false); |
8344 | { | 8670 | return inv.Value.CreatorID.ToString(); |
8345 | return inv.Value.CreatorID.ToString(); | ||
8346 | } | ||
8347 | } | 8671 | } |
8348 | } | 8672 | } |
8673 | m_host.TaskInventory.LockItemsForRead(false); | ||
8349 | 8674 | ||
8350 | llSay(0, "No item name '" + item + "'"); | 8675 | llSay(0, "No item name '" + item + "'"); |
8351 | 8676 | ||
@@ -8878,16 +9203,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8878 | { | 9203 | { |
8879 | m_host.AddScriptLPS(1); | 9204 | m_host.AddScriptLPS(1); |
8880 | 9205 | ||
8881 | lock (m_host.TaskInventory) | 9206 | m_host.TaskInventory.LockItemsForRead(true); |
9207 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
8882 | { | 9208 | { |
8883 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 9209 | if (inv.Value.Name == name) |
8884 | { | 9210 | { |
8885 | if (inv.Value.Name == name) | 9211 | m_host.TaskInventory.LockItemsForRead(false); |
8886 | { | 9212 | return inv.Value.Type; |
8887 | return inv.Value.Type; | ||
8888 | } | ||
8889 | } | 9213 | } |
8890 | } | 9214 | } |
9215 | m_host.TaskInventory.LockItemsForRead(false); | ||
8891 | 9216 | ||
8892 | return -1; | 9217 | return -1; |
8893 | } | 9218 | } |
@@ -8898,15 +9223,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8898 | 9223 | ||
8899 | if (quick_pay_buttons.Data.Length < 4) | 9224 | if (quick_pay_buttons.Data.Length < 4) |
8900 | { | 9225 | { |
8901 | LSLError("List must have at least 4 elements"); | 9226 | int x; |
8902 | return; | 9227 | for (x=quick_pay_buttons.Data.Length; x<= 4; x++) |
9228 | { | ||
9229 | quick_pay_buttons.Add(ScriptBaseClass.PAY_HIDE); | ||
9230 | } | ||
8903 | } | 9231 | } |
8904 | m_host.ParentGroup.RootPart.PayPrice[0]=price; | 9232 | int[] nPrice = new int[5]; |
8905 | 9233 | nPrice[0]=price; | |
8906 | m_host.ParentGroup.RootPart.PayPrice[1]=(LSL_Integer)quick_pay_buttons.Data[0]; | 9234 | nPrice[1] = (LSL_Integer)quick_pay_buttons.Data[0]; |
8907 | m_host.ParentGroup.RootPart.PayPrice[2]=(LSL_Integer)quick_pay_buttons.Data[1]; | 9235 | nPrice[2] = (LSL_Integer)quick_pay_buttons.Data[1]; |
8908 | m_host.ParentGroup.RootPart.PayPrice[3]=(LSL_Integer)quick_pay_buttons.Data[2]; | 9236 | nPrice[3] = (LSL_Integer)quick_pay_buttons.Data[2]; |
8909 | m_host.ParentGroup.RootPart.PayPrice[4]=(LSL_Integer)quick_pay_buttons.Data[3]; | 9237 | nPrice[4] = (LSL_Integer)quick_pay_buttons.Data[3]; |
9238 | m_host.ParentGroup.RootPart.PayPrice = nPrice; | ||
8910 | m_host.ParentGroup.HasGroupChanged = true; | 9239 | m_host.ParentGroup.HasGroupChanged = true; |
8911 | } | 9240 | } |
8912 | 9241 | ||
@@ -8918,17 +9247,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8918 | if (invItemID == UUID.Zero) | 9247 | if (invItemID == UUID.Zero) |
8919 | return new LSL_Vector(); | 9248 | return new LSL_Vector(); |
8920 | 9249 | ||
8921 | lock (m_host.TaskInventory) | 9250 | m_host.TaskInventory.LockItemsForRead(true); |
9251 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8922 | { | 9252 | { |
8923 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9253 | m_host.TaskInventory.LockItemsForRead(false); |
8924 | return new LSL_Vector(); | 9254 | return new LSL_Vector(); |
9255 | } | ||
8925 | 9256 | ||
8926 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 9257 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
8927 | { | 9258 | { |
8928 | ShoutError("No permissions to track the camera"); | 9259 | ShoutError("No permissions to track the camera"); |
8929 | return new LSL_Vector(); | 9260 | m_host.TaskInventory.LockItemsForRead(false); |
8930 | } | 9261 | return new LSL_Vector(); |
8931 | } | 9262 | } |
9263 | m_host.TaskInventory.LockItemsForRead(false); | ||
8932 | 9264 | ||
8933 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9265 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8934 | if (presence != null) | 9266 | if (presence != null) |
@@ -8946,17 +9278,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8946 | if (invItemID == UUID.Zero) | 9278 | if (invItemID == UUID.Zero) |
8947 | return new LSL_Rotation(); | 9279 | return new LSL_Rotation(); |
8948 | 9280 | ||
8949 | lock (m_host.TaskInventory) | 9281 | m_host.TaskInventory.LockItemsForRead(true); |
9282 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
8950 | { | 9283 | { |
8951 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 9284 | m_host.TaskInventory.LockItemsForRead(false); |
8952 | return new LSL_Rotation(); | 9285 | return new LSL_Rotation(); |
8953 | |||
8954 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
8955 | { | ||
8956 | ShoutError("No permissions to track the camera"); | ||
8957 | return new LSL_Rotation(); | ||
8958 | } | ||
8959 | } | 9286 | } |
9287 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
9288 | { | ||
9289 | ShoutError("No permissions to track the camera"); | ||
9290 | m_host.TaskInventory.LockItemsForRead(false); | ||
9291 | return new LSL_Rotation(); | ||
9292 | } | ||
9293 | m_host.TaskInventory.LockItemsForRead(false); | ||
8960 | 9294 | ||
8961 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 9295 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
8962 | if (presence != null) | 9296 | if (presence != null) |
@@ -9106,14 +9440,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9106 | if (objectID == UUID.Zero) return; | 9440 | if (objectID == UUID.Zero) return; |
9107 | 9441 | ||
9108 | UUID agentID; | 9442 | UUID agentID; |
9109 | lock (m_host.TaskInventory) | 9443 | m_host.TaskInventory.LockItemsForRead(true); |
9110 | { | 9444 | // we need the permission first, to know which avatar we want to set the camera for |
9111 | // we need the permission first, to know which avatar we want to set the camera for | 9445 | agentID = m_host.TaskInventory[invItemID].PermsGranter; |
9112 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9113 | 9446 | ||
9114 | if (agentID == UUID.Zero) return; | 9447 | if (agentID == UUID.Zero) |
9115 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | 9448 | { |
9449 | m_host.TaskInventory.LockItemsForRead(false); | ||
9450 | return; | ||
9116 | } | 9451 | } |
9452 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9453 | { | ||
9454 | m_host.TaskInventory.LockItemsForRead(false); | ||
9455 | return; | ||
9456 | } | ||
9457 | m_host.TaskInventory.LockItemsForRead(false); | ||
9117 | 9458 | ||
9118 | ScenePresence presence = World.GetScenePresence(agentID); | 9459 | ScenePresence presence = World.GetScenePresence(agentID); |
9119 | 9460 | ||
@@ -9163,12 +9504,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9163 | 9504 | ||
9164 | // we need the permission first, to know which avatar we want to clear the camera for | 9505 | // we need the permission first, to know which avatar we want to clear the camera for |
9165 | UUID agentID; | 9506 | UUID agentID; |
9166 | lock (m_host.TaskInventory) | 9507 | m_host.TaskInventory.LockItemsForRead(true); |
9508 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
9509 | if (agentID == UUID.Zero) | ||
9510 | { | ||
9511 | m_host.TaskInventory.LockItemsForRead(false); | ||
9512 | return; | ||
9513 | } | ||
9514 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | ||
9167 | { | 9515 | { |
9168 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 9516 | m_host.TaskInventory.LockItemsForRead(false); |
9169 | if (agentID == UUID.Zero) return; | 9517 | return; |
9170 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; | ||
9171 | } | 9518 | } |
9519 | m_host.TaskInventory.LockItemsForRead(false); | ||
9172 | 9520 | ||
9173 | ScenePresence presence = World.GetScenePresence(agentID); | 9521 | ScenePresence presence = World.GetScenePresence(agentID); |
9174 | 9522 | ||
@@ -9625,15 +9973,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9625 | 9973 | ||
9626 | internal UUID ScriptByName(string name) | 9974 | internal UUID ScriptByName(string name) |
9627 | { | 9975 | { |
9628 | lock (m_host.TaskInventory) | 9976 | m_host.TaskInventory.LockItemsForRead(true); |
9977 | |||
9978 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
9629 | { | 9979 | { |
9630 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 9980 | if (item.Type == 10 && item.Name == name) |
9631 | { | 9981 | { |
9632 | if (item.Type == 10 && item.Name == name) | 9982 | m_host.TaskInventory.LockItemsForRead(false); |
9633 | return item.ItemID; | 9983 | return item.ItemID; |
9634 | } | 9984 | } |
9635 | } | 9985 | } |
9636 | 9986 | ||
9987 | m_host.TaskInventory.LockItemsForRead(false); | ||
9988 | |||
9637 | return UUID.Zero; | 9989 | return UUID.Zero; |
9638 | } | 9990 | } |
9639 | 9991 | ||
@@ -9674,6 +10026,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9674 | { | 10026 | { |
9675 | m_host.AddScriptLPS(1); | 10027 | m_host.AddScriptLPS(1); |
9676 | 10028 | ||
10029 | //Clone is thread safe | ||
9677 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10030 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9678 | 10031 | ||
9679 | UUID assetID = UUID.Zero; | 10032 | UUID assetID = UUID.Zero; |
@@ -9736,6 +10089,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9736 | { | 10089 | { |
9737 | m_host.AddScriptLPS(1); | 10090 | m_host.AddScriptLPS(1); |
9738 | 10091 | ||
10092 | //Clone is thread safe | ||
9739 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); | 10093 | TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); |
9740 | 10094 | ||
9741 | UUID assetID = UUID.Zero; | 10095 | 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 7e68cc7..9474bab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -719,18 +719,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
719 | if (target != null) | 719 | if (target != null) |
720 | { | 720 | { |
721 | UUID animID=UUID.Zero; | 721 | UUID animID=UUID.Zero; |
722 | lock (m_host.TaskInventory) | 722 | m_host.TaskInventory.LockItemsForRead(true); |
723 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
723 | { | 724 | { |
724 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 725 | if (inv.Value.Name == animation) |
725 | { | 726 | { |
726 | if (inv.Value.Name == animation) | 727 | if (inv.Value.Type == (int)AssetType.Animation) |
727 | { | 728 | animID = inv.Value.AssetID; |
728 | if (inv.Value.Type == (int)AssetType.Animation) | 729 | continue; |
729 | animID = inv.Value.AssetID; | ||
730 | continue; | ||
731 | } | ||
732 | } | 730 | } |
733 | } | 731 | } |
732 | m_host.TaskInventory.LockItemsForRead(false); | ||
734 | if (animID == UUID.Zero) | 733 | if (animID == UUID.Zero) |
735 | target.Animator.AddAnimation(animation, m_host.UUID); | 734 | target.Animator.AddAnimation(animation, m_host.UUID); |
736 | else | 735 | else |
@@ -752,18 +751,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
752 | if (target != null) | 751 | if (target != null) |
753 | { | 752 | { |
754 | UUID animID=UUID.Zero; | 753 | UUID animID=UUID.Zero; |
755 | lock (m_host.TaskInventory) | 754 | m_host.TaskInventory.LockItemsForRead(true); |
755 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
756 | { | 756 | { |
757 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 757 | if (inv.Value.Name == animation) |
758 | { | 758 | { |
759 | if (inv.Value.Name == animation) | 759 | if (inv.Value.Type == (int)AssetType.Animation) |
760 | { | 760 | animID = inv.Value.AssetID; |
761 | if (inv.Value.Type == (int)AssetType.Animation) | 761 | continue; |
762 | animID = inv.Value.AssetID; | ||
763 | continue; | ||
764 | } | ||
765 | } | 762 | } |
766 | } | 763 | } |
764 | m_host.TaskInventory.LockItemsForRead(false); | ||
767 | 765 | ||
768 | if (animID == UUID.Zero) | 766 | if (animID == UUID.Zero) |
769 | target.Animator.RemoveAnimation(animation); | 767 | target.Animator.RemoveAnimation(animation); |
@@ -1532,6 +1530,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1532 | 1530 | ||
1533 | if (!UUID.TryParse(name, out assetID)) | 1531 | if (!UUID.TryParse(name, out assetID)) |
1534 | { | 1532 | { |
1533 | m_host.TaskInventory.LockItemsForRead(true); | ||
1535 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1534 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1536 | { | 1535 | { |
1537 | if (item.Type == 7 && item.Name == name) | 1536 | if (item.Type == 7 && item.Name == name) |
@@ -1539,6 +1538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1539 | assetID = item.AssetID; | 1538 | assetID = item.AssetID; |
1540 | } | 1539 | } |
1541 | } | 1540 | } |
1541 | m_host.TaskInventory.LockItemsForRead(false); | ||
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | if (assetID == UUID.Zero) | 1544 | if (assetID == UUID.Zero) |
@@ -1585,6 +1585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1585 | 1585 | ||
1586 | if (!UUID.TryParse(name, out assetID)) | 1586 | if (!UUID.TryParse(name, out assetID)) |
1587 | { | 1587 | { |
1588 | m_host.TaskInventory.LockItemsForRead(true); | ||
1588 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1589 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1589 | { | 1590 | { |
1590 | if (item.Type == 7 && item.Name == name) | 1591 | if (item.Type == 7 && item.Name == name) |
@@ -1592,6 +1593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1592 | assetID = item.AssetID; | 1593 | assetID = item.AssetID; |
1593 | } | 1594 | } |
1594 | } | 1595 | } |
1596 | m_host.TaskInventory.LockItemsForRead(false); | ||
1595 | } | 1597 | } |
1596 | 1598 | ||
1597 | if (assetID == UUID.Zero) | 1599 | if (assetID == UUID.Zero) |
@@ -1642,6 +1644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1642 | 1644 | ||
1643 | if (!UUID.TryParse(name, out assetID)) | 1645 | if (!UUID.TryParse(name, out assetID)) |
1644 | { | 1646 | { |
1647 | m_host.TaskInventory.LockItemsForRead(true); | ||
1645 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1648 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1646 | { | 1649 | { |
1647 | if (item.Type == 7 && item.Name == name) | 1650 | if (item.Type == 7 && item.Name == name) |
@@ -1649,6 +1652,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1649 | assetID = item.AssetID; | 1652 | assetID = item.AssetID; |
1650 | } | 1653 | } |
1651 | } | 1654 | } |
1655 | m_host.TaskInventory.LockItemsForRead(false); | ||
1652 | } | 1656 | } |
1653 | 1657 | ||
1654 | if (assetID == UUID.Zero) | 1658 | if (assetID == UUID.Zero) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..2fd33fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs | |||
@@ -109,25 +109,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
109 | if (Timers.Count == 0) | 109 | if (Timers.Count == 0) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | Dictionary<string, TimerClass>.ValueCollection tvals; | ||
112 | lock (TimerListLock) | 113 | lock (TimerListLock) |
113 | { | 114 | { |
114 | // Go through all timers | 115 | // Go through all timers |
115 | Dictionary<string, TimerClass>.ValueCollection tvals = Timers.Values; | 116 | tvals = Timers.Values; |
116 | foreach (TimerClass ts in tvals) | 117 | } |
118 | |||
119 | foreach (TimerClass ts in tvals) | ||
120 | { | ||
121 | // Time has passed? | ||
122 | if (ts.next < DateTime.Now.Ticks) | ||
117 | { | 123 | { |
118 | // Time has passed? | 124 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); |
119 | if (ts.next < DateTime.Now.Ticks) | 125 | // Add it to queue |
120 | { | 126 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, |
121 | //m_log.Debug("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next); | 127 | new EventParams("timer", new Object[0], |
122 | // Add it to queue | 128 | new DetectParams[0])); |
123 | m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, | 129 | // set next interval |
124 | new EventParams("timer", new Object[0], | 130 | |
125 | new DetectParams[0])); | 131 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
126 | // set next interval | 132 | ts.next = DateTime.Now.Ticks + ts.interval; |
127 | |||
128 | //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | ||
129 | ts.next = DateTime.Now.Ticks + ts.interval; | ||
130 | } | ||
131 | } | 133 | } |
132 | } | 134 | } |
133 | } | 135 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..ef990a1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,21 @@ | |||
1 | using System.Collections; | ||
2 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
3 | |||
4 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
5 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
6 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
7 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
8 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
9 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
10 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
11 | |||
12 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
13 | { | ||
14 | public interface ICM_Api | ||
15 | { | ||
16 | // Windlight Functions | ||
17 | LSL_List cmGetWindlightScene(LSL_List rules); | ||
18 | int cmSetWindlightScene(LSL_List rules); | ||
19 | int cmSetWindlightSceneTargeted(LSL_List rules, key target); | ||
20 | } | ||
21 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 60b8050..f5921e1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
80 | // Avatar Info Commands | 80 | // Avatar Info Commands |
81 | string osGetAgentIP(string agent); | 81 | string osGetAgentIP(string agent); |
82 | LSL_List osGetAgents(); | 82 | LSL_List osGetAgents(); |
83 | 83 | ||
84 | // Teleport commands | 84 | // Teleport commands |
85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 85 | void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); | 86 | void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs new file mode 100644 index 0000000..522c020 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | public const int WL_SUN_MOON_POSITION = 36; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..5bc3a88 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public ICM_Api m_CM_Functions; | ||
52 | |||
53 | public void ApiTypeCM(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is ICM_Api)) | ||
56 | return; | ||
57 | |||
58 | m_CM_Functions = (ICM_Api)api; | ||
59 | } | ||
60 | |||
61 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
62 | { | ||
63 | return m_CM_Functions.cmGetWindlightScene(rules); | ||
64 | } | ||
65 | |||
66 | public int cmSetWindlightScene(LSL_List rules) | ||
67 | { | ||
68 | return m_CM_Functions.cmSetWindlightScene(rules); | ||
69 | } | ||
70 | |||
71 | public int cmSetWindlightSceneTargeted(LSL_List rules, key target) | ||
72 | { | ||
73 | return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 9615315..943d7a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using OpenSim.Region.ScriptEngine.Shared; | 33 | using OpenSim.Region.ScriptEngine.Shared; |
@@ -132,6 +133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
132 | return (eventFlags); | 133 | return (eventFlags); |
133 | } | 134 | } |
134 | 135 | ||
136 | [DebuggerNonUserCode] | ||
135 | public void ExecuteEvent(string state, string FunctionName, object[] args) | 137 | public void ExecuteEvent(string state, string FunctionName, object[] args) |
136 | { | 138 | { |
137 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 139 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/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 d30d2dc..6ecafd4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | ||
30 | using System.Runtime.Remoting; | 31 | using System.Runtime.Remoting; |
31 | using System.Runtime.Remoting.Lifetime; | 32 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Threading; | 33 | using System.Threading; |
@@ -237,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
237 | 238 | ||
238 | if (part != null) | 239 | if (part != null) |
239 | { | 240 | { |
240 | lock (part.TaskInventory) | 241 | part.TaskInventory.LockItemsForRead(true); |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | ||
241 | { | 243 | { |
242 | if (part.TaskInventory.ContainsKey(m_ItemID)) | 244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; |
243 | { | ||
244 | m_thisScriptTask = part.TaskInventory[m_ItemID]; | ||
245 | } | ||
246 | } | 245 | } |
246 | part.TaskInventory.LockItemsForRead(false); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | ApiManager am = new ApiManager(); | 249 | ApiManager am = new ApiManager(); |
@@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
428 | { | 428 | { |
429 | int permsMask; | 429 | int permsMask; |
430 | UUID permsGranter; | 430 | UUID permsGranter; |
431 | lock (part.TaskInventory) | 431 | part.TaskInventory.LockItemsForRead(true); |
432 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | ||
432 | { | 433 | { |
433 | if (!part.TaskInventory.ContainsKey(m_ItemID)) | 434 | part.TaskInventory.LockItemsForRead(false); |
434 | return; | 435 | return; |
435 | |||
436 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
437 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
438 | } | 436 | } |
437 | permsGranter = part.TaskInventory[m_ItemID].PermsGranter; | ||
438 | permsMask = part.TaskInventory[m_ItemID].PermsMask; | ||
439 | part.TaskInventory.LockItemsForRead(false); | ||
439 | 440 | ||
440 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) | 441 | if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) |
441 | { | 442 | { |
@@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
544 | return true; | 545 | return true; |
545 | } | 546 | } |
546 | 547 | ||
548 | [DebuggerNonUserCode] //Prevents the debugger from farting in this function | ||
547 | public void SetState(string state) | 549 | public void SetState(string state) |
548 | { | 550 | { |
549 | if (state == State) | 551 | if (state == State) |
@@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
555 | new DetectParams[0])); | 557 | new DetectParams[0])); |
556 | PostEvent(new EventParams("state_entry", new Object[0], | 558 | PostEvent(new EventParams("state_entry", new Object[0], |
557 | new DetectParams[0])); | 559 | new DetectParams[0])); |
558 | 560 | ||
559 | throw new EventAbortException(); | 561 | throw new EventAbortException(); |
560 | } | 562 | } |
561 | 563 | ||
@@ -638,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
638 | /// <returns></returns> | 640 | /// <returns></returns> |
639 | public object EventProcessor() | 641 | public object EventProcessor() |
640 | { | 642 | { |
643 | |||
644 | EventParams data = null; | ||
645 | |||
646 | lock (m_EventQueue) | ||
647 | { | ||
641 | lock (m_Script) | 648 | lock (m_Script) |
642 | { | 649 | { |
643 | EventParams data = null; | 650 | data = (EventParams) m_EventQueue.Dequeue(); |
644 | 651 | if (data == null) // Shouldn't happen | |
645 | lock (m_EventQueue) | ||
646 | { | 652 | { |
647 | data = (EventParams) m_EventQueue.Dequeue(); | 653 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) |
648 | if (data == null) // Shouldn't happen | ||
649 | { | 654 | { |
650 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 655 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
651 | { | ||
652 | m_CurrentResult = m_Engine.QueueEventHandler(this); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | m_CurrentResult = null; | ||
657 | } | ||
658 | return 0; | ||
659 | } | 656 | } |
660 | 657 | else | |
661 | if (data.EventName == "timer") | ||
662 | m_TimerQueued = false; | ||
663 | if (data.EventName == "control") | ||
664 | { | 658 | { |
665 | if (m_ControlEventsInQueue > 0) | 659 | m_CurrentResult = null; |
666 | m_ControlEventsInQueue--; | ||
667 | } | 660 | } |
668 | if (data.EventName == "collision") | 661 | return 0; |
669 | m_CollisionInQueue = false; | ||
670 | } | 662 | } |
671 | |||
672 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
673 | 663 | ||
674 | m_DetectParams = data.DetectParams; | 664 | if (data.EventName == "timer") |
675 | 665 | m_TimerQueued = false; | |
676 | if (data.EventName == "state") // Hardcoded state change | 666 | if (data.EventName == "control") |
677 | { | 667 | { |
678 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", | 668 | if (m_ControlEventsInQueue > 0) |
679 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); | 669 | m_ControlEventsInQueue--; |
680 | m_State=data.Params[0].ToString(); | 670 | } |
681 | AsyncCommandManager.RemoveScript(m_Engine, | 671 | if (data.EventName == "collision") |
682 | m_LocalID, m_ItemID); | 672 | m_CollisionInQueue = false; |
673 | } | ||
674 | } | ||
675 | lock(m_Script) | ||
676 | { | ||
677 | |||
678 | //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); | ||
683 | 679 | ||
684 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 680 | m_DetectParams = data.DetectParams; |
685 | m_LocalID); | 681 | |
686 | if (part != null) | 682 | if (data.EventName == "state") // Hardcoded state change |
687 | { | 683 | { |
688 | part.SetScriptEvents(m_ItemID, | 684 | // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", |
689 | (int)m_Script.GetStateEventFlags(State)); | 685 | // m_PrimName, m_ScriptName, data.Params[0].ToString()); |
690 | } | 686 | m_State=data.Params[0].ToString(); |
687 | AsyncCommandManager.RemoveScript(m_Engine, | ||
688 | m_LocalID, m_ItemID); | ||
689 | |||
690 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | ||
691 | m_LocalID); | ||
692 | if (part != null) | ||
693 | { | ||
694 | part.SetScriptEvents(m_ItemID, | ||
695 | (int)m_Script.GetStateEventFlags(State)); | ||
691 | } | 696 | } |
692 | else | 697 | } |
698 | else | ||
699 | { | ||
700 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | ||
701 | data.EventName == "control") // Don't freeze avies! | ||
693 | { | 702 | { |
694 | if (m_Engine.World.PipeEventsForScript(m_LocalID) || | 703 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( |
695 | data.EventName == "control") // Don't freeze avies! | 704 | m_LocalID); |
696 | { | 705 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", |
697 | SceneObjectPart part = m_Engine.World.GetSceneObjectPart( | 706 | // m_PrimName, m_ScriptName, data.EventName, m_State); |
698 | m_LocalID); | ||
699 | // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", | ||
700 | // m_PrimName, m_ScriptName, data.EventName, m_State); | ||
701 | 707 | ||
702 | try | 708 | try |
703 | { | 709 | { |
704 | m_CurrentEvent = data.EventName; | 710 | m_CurrentEvent = data.EventName; |
705 | m_EventStart = DateTime.Now; | 711 | m_EventStart = DateTime.Now; |
706 | m_InEvent = true; | 712 | m_InEvent = true; |
707 | 713 | ||
708 | m_Script.ExecuteEvent(State, data.EventName, data.Params); | 714 | m_Script.ExecuteEvent(State, data.EventName, data.Params); |
709 | 715 | ||
710 | m_InEvent = false; | 716 | m_InEvent = false; |
711 | m_CurrentEvent = String.Empty; | 717 | m_CurrentEvent = String.Empty; |
712 | 718 | ||
713 | if (m_SaveState) | 719 | if (m_SaveState) |
714 | { | 720 | { |
715 | // This will be the very first event we deliver | 721 | // This will be the very first event we deliver |
716 | // (state_entry) in default state | 722 | // (state_entry) in default state |
717 | // | 723 | // |
718 | 724 | ||
719 | SaveState(m_Assembly); | 725 | SaveState(m_Assembly); |
720 | 726 | ||
721 | m_SaveState = false; | 727 | m_SaveState = false; |
722 | } | ||
723 | } | 728 | } |
724 | catch (Exception e) | 729 | } |
725 | { | 730 | catch (Exception e) |
726 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); | 731 | { |
727 | m_InEvent = false; | 732 | // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); |
728 | m_CurrentEvent = String.Empty; | 733 | m_InEvent = false; |
734 | m_CurrentEvent = String.Empty; | ||
729 | 735 | ||
730 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) | 736 | if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) |
731 | { | 737 | { |
732 | try | 738 | try |
733 | { | ||
734 | // DISPLAY ERROR INWORLD | ||
735 | string text = FormatException(e); | ||
736 | |||
737 | if (text.Length > 1000) | ||
738 | text = text.Substring(0, 1000); | ||
739 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
740 | ChatTypeEnum.DebugChannel, 2147483647, | ||
741 | part.AbsolutePosition, | ||
742 | part.Name, part.UUID, false); | ||
743 | } | ||
744 | catch (Exception) | ||
745 | { | ||
746 | } | ||
747 | // catch (Exception e2) // LEGIT: User Scripting | ||
748 | // { | ||
749 | // m_log.Error("[SCRIPT]: "+ | ||
750 | // "Error displaying error in-world: " + | ||
751 | // e2.ToString()); | ||
752 | // m_log.Error("[SCRIPT]: " + | ||
753 | // "Errormessage: Error compiling script:\r\n" + | ||
754 | // e.ToString()); | ||
755 | // } | ||
756 | } | ||
757 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
758 | { | 739 | { |
759 | m_InSelfDelete = true; | 740 | // DISPLAY ERROR INWORLD |
760 | if (part != null && part.ParentGroup != null) | 741 | string text = FormatException(e); |
761 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | 742 | |
743 | if (text.Length > 1000) | ||
744 | text = text.Substring(0, 1000); | ||
745 | m_Engine.World.SimChat(Utils.StringToBytes(text), | ||
746 | ChatTypeEnum.DebugChannel, 2147483647, | ||
747 | part.AbsolutePosition, | ||
748 | part.Name, part.UUID, false); | ||
762 | } | 749 | } |
763 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | 750 | catch (Exception) |
764 | { | 751 | { |
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
768 | } | 752 | } |
753 | // catch (Exception e2) // LEGIT: User Scripting | ||
754 | // { | ||
755 | // m_log.Error("[SCRIPT]: "+ | ||
756 | // "Error displaying error in-world: " + | ||
757 | // e2.ToString()); | ||
758 | // m_log.Error("[SCRIPT]: " + | ||
759 | // "Errormessage: Error compiling script:\r\n" + | ||
760 | // e.ToString()); | ||
761 | // } | ||
762 | } | ||
763 | else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) | ||
764 | { | ||
765 | m_InSelfDelete = true; | ||
766 | if (part != null && part.ParentGroup != null) | ||
767 | m_Engine.World.DeleteSceneObject(part.ParentGroup, false); | ||
768 | } | ||
769 | else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) | ||
770 | { | ||
771 | m_InSelfDelete = true; | ||
772 | if (part != null && part.ParentGroup != null) | ||
773 | part.Inventory.RemoveInventoryItem(m_ItemID); | ||
769 | } | 774 | } |
770 | } | 775 | } |
771 | } | 776 | } |
777 | } | ||
772 | 778 | ||
773 | lock (m_EventQueue) | 779 | lock (m_EventQueue) |
780 | { | ||
781 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | ||
774 | { | 782 | { |
775 | if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) | 783 | m_CurrentResult = m_Engine.QueueEventHandler(this); |
776 | { | 784 | } |
777 | m_CurrentResult = m_Engine.QueueEventHandler(this); | 785 | else |
778 | } | 786 | { |
779 | else | 787 | m_CurrentResult = null; |
780 | { | ||
781 | m_CurrentResult = null; | ||
782 | } | ||
783 | } | 788 | } |
789 | } | ||
784 | 790 | ||
785 | m_DetectParams = null; | 791 | m_DetectParams = null; |
786 | 792 | ||
787 | return 0; | 793 | return 0; |
788 | } | 794 | } |
789 | } | 795 | } |
790 | 796 | ||
791 | public int EventTime() | 797 | public int EventTime() |
@@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
824 | new Object[0], new DetectParams[0])); | 830 | new Object[0], new DetectParams[0])); |
825 | } | 831 | } |
826 | 832 | ||
833 | [DebuggerNonUserCode] //Stops the VS debugger from farting in this function | ||
827 | public void ApiResetScript() | 834 | public void ApiResetScript() |
828 | { | 835 | { |
829 | // bool running = Running; | 836 | // bool running = Running; |