aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs431
1 files changed, 373 insertions, 58 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index ceb4660..e5e43f8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -30,6 +30,7 @@ using System.Reflection;
30using System.Collections; 30using System.Collections;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime; 32using System.Runtime.Remoting.Lifetime;
33using System.Threading;
33using OpenMetaverse; 34using OpenMetaverse;
34using Nini.Config; 35using Nini.Config;
35using OpenSim; 36using OpenSim;
@@ -61,9 +62,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
61 internal bool m_LSFunctionsEnabled = false; 62 internal bool m_LSFunctionsEnabled = false;
62 internal IScriptModuleComms m_comms = null; 63 internal IScriptModuleComms m_comms = null;
63 64
64 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 65 public void Initialize(
66 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
65 { 67 {
66 m_ScriptEngine = ScriptEngine; 68 m_ScriptEngine = scriptEngine;
67 m_host = host; 69 m_host = host;
68 70
69 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) 71 if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
@@ -92,10 +94,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
92 get { return m_ScriptEngine.World; } 94 get { return m_ScriptEngine.World; }
93 } 95 }
94 96
95 // 97 /// <summary>
96 //Dumps an error message on the debug console. 98 /// Dumps an error message on the debug console.
97 // 99 /// </summary>
98
99 internal void LSShoutError(string message) 100 internal void LSShoutError(string message)
100 { 101 {
101 if (message.Length > 1023) 102 if (message.Length > 1023)
@@ -264,175 +265,445 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
264 int idx = 0; 265 int idx = 0;
265 while (idx < rules.Length) 266 while (idx < rules.Length)
266 { 267 {
267 uint rule = (uint)rules.GetLSLIntegerItem(idx); 268 uint rule;
269
270 try
271 {
272 rule = (uint)rules.GetLSLIntegerItem(idx);
273 }
274 catch (InvalidCastException)
275 {
276 throw new InvalidCastException(string.Format("Error running rule type: arg #{0} - parameter type must be integer", idx));
277 }
278
268 LSL_Types.Quaternion iQ; 279 LSL_Types.Quaternion iQ;
269 LSL_Types.Vector3 iV; 280 LSL_Types.Vector3 iV;
270 switch (rule) 281 switch (rule)
271 { 282 {
272 case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: 283 case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
273 idx++; 284 idx++;
274 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); 285 try
286 {
287 wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
288 }
289 catch (InvalidCastException)
290 {
291 throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_POSITION: arg #{0} - parameter 1 must be float", idx));
292 }
275 break; 293 break;
276 case (int)ScriptBaseClass.WL_AMBIENT: 294 case (int)ScriptBaseClass.WL_AMBIENT:
277 idx++; 295 idx++;
278 iQ = rules.GetQuaternionItem(idx); 296 try
297 {
298 iQ = rules.GetQuaternionItem(idx);
299 }
300 catch (InvalidCastException)
301 {
302 throw new InvalidCastException(string.Format("Error running rule WL_AMBIENT: arg #{0} - parameter 1 must be rotation", idx));
303 }
279 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 304 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
280 break; 305 break;
281 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: 306 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
282 idx++; 307 idx++;
283 iV = rules.GetVector3Item(idx); 308 try
309 {
310 iV = rules.GetVector3Item(idx);
311 }
312 catch (InvalidCastException)
313 {
314 throw new InvalidCastException(string.Format("Error running rule WL_BIG_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx));
315 }
284 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); 316 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
285 break; 317 break;
286 case (int)ScriptBaseClass.WL_BLUE_DENSITY: 318 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
287 idx++; 319 idx++;
288 iQ = rules.GetQuaternionItem(idx); 320 try
321 {
322 iQ = rules.GetQuaternionItem(idx);
323 }
324 catch (InvalidCastException)
325 {
326 throw new InvalidCastException(string.Format("Error running rule WL_BLUE_DENSITY: arg #{0} - parameter 1 must be rotation", idx));
327 }
289 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 328 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
290 break; 329 break;
291 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: 330 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
292 idx++; 331 idx++;
293 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); 332 try
333 {
334 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
335 }
336 catch (InvalidCastException)
337 {
338 throw new InvalidCastException(string.Format("Error running rule WL_BLUR_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
339 }
294 break; 340 break;
295 case (int)ScriptBaseClass.WL_CLOUD_COLOR: 341 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
296 idx++; 342 idx++;
297 iQ = rules.GetQuaternionItem(idx); 343 try
344 {
345 iQ = rules.GetQuaternionItem(idx);
346 }
347 catch (InvalidCastException)
348 {
349 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COLOR: arg #{0} - parameter 1 must be rotation", idx));
350 }
298 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 351 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
299 break; 352 break;
300 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: 353 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
301 idx++; 354 idx++;
302 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); 355 try
356 {
357 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
358 }
359 catch (InvalidCastException)
360 {
361 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_COVERAGE: arg #{0} - parameter 1 must be float", idx));
362 }
303 break; 363 break;
304 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: 364 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
305 idx++; 365 idx++;
306 iV = rules.GetVector3Item(idx); 366 try
367 {
368 iV = rules.GetVector3Item(idx);
369 }
370 catch (InvalidCastException)
371 {
372 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_DETAIL_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx));
373 }
307 wl.cloudDetailXYDensity = iV; 374 wl.cloudDetailXYDensity = iV;
308 break; 375 break;
309 case (int)ScriptBaseClass.WL_CLOUD_SCALE: 376 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
310 idx++; 377 idx++;
311 wl.cloudScale = (float)rules.GetLSLFloatItem(idx); 378 try
379 {
380 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
381 }
382 catch (InvalidCastException)
383 {
384 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCALE: arg #{0} - parameter 1 must be float", idx));
385 }
312 break; 386 break;
313 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: 387 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
314 idx++; 388 idx++;
315 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); 389 try
390 {
391 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
392 }
393 catch (InvalidCastException)
394 {
395 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_X: arg #{0} - parameter 1 must be float", idx));
396 }
316 break; 397 break;
317 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: 398 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
318 idx++; 399 idx++;
319 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 400 try
401 {
402 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
403 }
404 catch (InvalidCastException)
405 {
406 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx));
407 }
320 break; 408 break;
321 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: 409 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
322 idx++; 410 idx++;
323 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); 411 try
412 {
413 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
414 }
415 catch (InvalidCastException)
416 {
417 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y: arg #{0} - parameter 1 must be float", idx));
418 }
324 break; 419 break;
325 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: 420 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
326 idx++; 421 idx++;
327 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 422 try
423 {
424 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
425 }
426 catch (InvalidCastException)
427 {
428 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_SCROLL_Y_LOCK: arg #{0} - parameter 1 must be integer", idx));
429 }
328 break; 430 break;
329 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: 431 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
330 idx++; 432 idx++;
331 iV = rules.GetVector3Item(idx); 433 try
434 {
435 iV = rules.GetVector3Item(idx);
436 }
437 catch (InvalidCastException)
438 {
439 throw new InvalidCastException(string.Format("Error running rule WL_CLOUD_XY_DENSITY: arg #{0} - parameter 1 must be vector", idx));
440 }
332 wl.cloudXYDensity = iV; 441 wl.cloudXYDensity = iV;
333 break; 442 break;
334 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: 443 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
335 idx++; 444 idx++;
336 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); 445 try
446 {
447 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
448 }
449 catch (InvalidCastException)
450 {
451 throw new InvalidCastException(string.Format("Error running rule WL_DENSITY_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
452 }
337 break; 453 break;
338 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: 454 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
339 idx++; 455 idx++;
340 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); 456 try
457 {
458 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
459 }
460 catch (InvalidCastException)
461 {
462 throw new InvalidCastException(string.Format("Error running rule WL_DISTANCE_MULTIPLIER: arg #{0} - parameter 1 must be float", idx));
463 }
341 break; 464 break;
342 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: 465 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
343 idx++; 466 idx++;
344 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; 467 try
468 {
469 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
470 }
471 catch (InvalidCastException)
472 {
473 throw new InvalidCastException(string.Format("Error running rule WL_DRAW_CLASSIC_CLOUDS: arg #{0} - parameter 1 must be integer", idx));
474 }
345 break; 475 break;
346 case (int)ScriptBaseClass.WL_EAST_ANGLE: 476 case (int)ScriptBaseClass.WL_EAST_ANGLE:
347 idx++; 477 idx++;
348 wl.eastAngle = (float)rules.GetLSLFloatItem(idx); 478 try
479 {
480 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
481 }
482 catch (InvalidCastException)
483 {
484 throw new InvalidCastException(string.Format("Error running rule WL_EAST_ANGLE: arg #{0} - parameter 1 must be float", idx));
485 }
349 break; 486 break;
350 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: 487 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
351 idx++; 488 idx++;
352 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); 489 try
490 {
491 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
492 }
493 catch (InvalidCastException)
494 {
495 throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_OFFSET: arg #{0} - parameter 1 must be float", idx));
496 }
353 break; 497 break;
354 case (int)ScriptBaseClass.WL_FRESNEL_SCALE: 498 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
355 idx++; 499 idx++;
356 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); 500 try
501 {
502 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
503 }
504 catch (InvalidCastException)
505 {
506 throw new InvalidCastException(string.Format("Error running rule WL_FRESNEL_SCALE: arg #{0} - parameter 1 must be float", idx));
507 }
357 break; 508 break;
358 case (int)ScriptBaseClass.WL_HAZE_DENSITY: 509 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
359 idx++; 510 idx++;
360 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); 511 try
512 {
513 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
514 }
515 catch (InvalidCastException)
516 {
517 throw new InvalidCastException(string.Format("Error running rule WL_HAZE_DENSITY: arg #{0} - parameter 1 must be float", idx));
518 }
361 break; 519 break;
362 case (int)ScriptBaseClass.WL_HAZE_HORIZON: 520 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
363 idx++; 521 idx++;
364 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); 522 try
523 {
524 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
525 }
526 catch (InvalidCastException)
527 {
528 throw new InvalidCastException(string.Format("Error running rule WL_HAZE_HORIZON: arg #{0} - parameter 1 must be float", idx));
529 }
365 break; 530 break;
366 case (int)ScriptBaseClass.WL_HORIZON: 531 case (int)ScriptBaseClass.WL_HORIZON:
367 idx++; 532 idx++;
368 iQ = rules.GetQuaternionItem(idx); 533 try
534 {
535 iQ = rules.GetQuaternionItem(idx);
536 }
537 catch (InvalidCastException)
538 {
539 throw new InvalidCastException(string.Format("Error running rule WL_HORIZON: arg #{0} - parameter 1 must be rotation", idx));
540 }
369 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 541 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
370 break; 542 break;
371 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: 543 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
372 idx++; 544 idx++;
373 iV = rules.GetVector3Item(idx); 545 try
546 {
547 iV = rules.GetVector3Item(idx);
548 }
549 catch (InvalidCastException)
550 {
551 throw new InvalidCastException(string.Format("Error running rule WL_LITTLE_WAVE_DIRECTION: arg #{0} - parameter 1 must be vector", idx));
552 }
374 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); 553 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
375 break; 554 break;
376 case (int)ScriptBaseClass.WL_MAX_ALTITUDE: 555 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
377 idx++; 556 idx++;
378 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; 557 try
558 {
559 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
560 }
561 catch (InvalidCastException)
562 {
563 throw new InvalidCastException(string.Format("Error running rule WL_MAX_ALTITUDE: arg #{0} - parameter 1 must be integer", idx));
564 }
379 break; 565 break;
380 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: 566 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
381 idx++; 567 idx++;
382 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); 568 try
569 {
570 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
571 }
572 catch (ArgumentException)
573 {
574 throw new InvalidCastException(string.Format("Error running rule WL_NORMAL_MAP_TEXTURE: arg #{0} - parameter 1 must be key", idx));
575 }
383 break; 576 break;
384 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: 577 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
385 idx++; 578 idx++;
386 iV = rules.GetVector3Item(idx); 579 try
580 {
581 iV = rules.GetVector3Item(idx);
582 }
583 catch (InvalidCastException)
584 {
585 throw new InvalidCastException(string.Format("Error running rule WL_REFLECTION_WAVELET_SCALE: arg #{0} - parameter 1 must be vector", idx));
586 }
387 wl.reflectionWaveletScale = iV; 587 wl.reflectionWaveletScale = iV;
388 break; 588 break;
389 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: 589 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
390 idx++; 590 idx++;
391 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); 591 try
592 {
593 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
594 }
595 catch (InvalidCastException)
596 {
597 throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_ABOVE: arg #{0} - parameter 1 must be float", idx));
598 }
392 break; 599 break;
393 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: 600 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
394 idx++; 601 idx++;
395 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); 602 try
603 {
604 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
605 }
606 catch (InvalidCastException)
607 {
608 throw new InvalidCastException(string.Format("Error running rule WL_REFRACT_SCALE_BELOW: arg #{0} - parameter 1 must be float", idx));
609 }
396 break; 610 break;
397 case (int)ScriptBaseClass.WL_SCENE_GAMMA: 611 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
398 idx++; 612 idx++;
399 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); 613 try
614 {
615 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
616 }
617 catch (InvalidCastException)
618 {
619 throw new InvalidCastException(string.Format("Error running rule WL_SCENE_GAMMA: arg #{0} - parameter 1 must be float", idx));
620 }
400 break; 621 break;
401 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: 622 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
402 idx++; 623 idx++;
403 wl.starBrightness = (float)rules.GetLSLFloatItem(idx); 624 try
625 {
626 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
627 }
628 catch (InvalidCastException)
629 {
630 throw new InvalidCastException(string.Format("Error running rule WL_STAR_BRIGHTNESS: arg #{0} - parameter 1 must be float", idx));
631 }
404 break; 632 break;
405 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: 633 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
406 idx++; 634 idx++;
407 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); 635 try
636 {
637 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
638 }
639 catch (InvalidCastException)
640 {
641 throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_FOCUS: arg #{0} - parameter 1 must be float", idx));
642 }
408 break; 643 break;
409 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: 644 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
410 idx++; 645 idx++;
411 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); 646 try
647 {
648 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
649 }
650 catch (InvalidCastException)
651 {
652 throw new InvalidCastException(string.Format("Error running rule WL_SUN_GLOW_SIZE: arg #{0} - parameter 1 must be float", idx));
653 }
412 break; 654 break;
413 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: 655 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
414 idx++; 656 idx++;
415 iQ = rules.GetQuaternionItem(idx); 657 iQ = rules.GetQuaternionItem(idx);
416 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 658 try
659 {
660 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
661 }
662 catch (InvalidCastException)
663 {
664 throw new InvalidCastException(string.Format("Error running rule WL_SUN_MOON_COLOR: arg #{0} - parameter 1 must be rotation", idx));
665 }
417 break; 666 break;
418 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: 667 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
419 idx++; 668 idx++;
420 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); 669 try
670 {
671 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
672 }
673 catch (InvalidCastException)
674 {
675 throw new InvalidCastException(string.Format("Error running rule WL_UNDERWATER_FOG_MODIFIER: arg #{0} - parameter 1 must be float", idx));
676 }
421 break; 677 break;
422 case (int)ScriptBaseClass.WL_WATER_COLOR: 678 case (int)ScriptBaseClass.WL_WATER_COLOR:
423 idx++; 679 idx++;
424 iV = rules.GetVector3Item(idx); 680 try
681 {
682 iV = rules.GetVector3Item(idx);
683 }
684 catch (InvalidCastException)
685 {
686 throw new InvalidCastException(string.Format("Error running rule WL_WATER_COLOR: arg #{0} - parameter 1 must be vector", idx));
687 }
425 wl.waterColor = iV; 688 wl.waterColor = iV;
426 break; 689 break;
427 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: 690 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
428 idx++; 691 idx++;
429 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); 692 try
693 {
694 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
695 }
696 catch (InvalidCastException)
697 {
698 throw new InvalidCastException(string.Format("Error running rule WL_WATER_FOG_DENSITY_EXPONENT: arg #{0} - parameter 1 must be float", idx));
699 }
430 break; 700 break;
431 } 701 }
432 idx++; 702 idx++;
433 } 703 }
434 return wl; 704 return wl;
435 } 705 }
706
436 /// <summary> 707 /// <summary>
437 /// Set the current Windlight scene 708 /// Set the current Windlight scene
438 /// </summary> 709 /// </summary>
@@ -445,16 +716,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
445 LSShoutError("LightShare functions are not enabled."); 716 LSShoutError("LightShare functions are not enabled.");
446 return 0; 717 return 0;
447 } 718 }
448 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 719
720 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
449 { 721 {
450 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 722 ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
451 return 0; 723
724 if (sp == null || sp.GodLevel < 200)
725 {
726 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
727 return 0;
728 }
452 } 729 }
730
453 int success = 0; 731 int success = 0;
454 m_host.AddScriptLPS(1); 732 m_host.AddScriptLPS(1);
733
455 if (LightShareModule.EnableWindlight) 734 if (LightShareModule.EnableWindlight)
456 { 735 {
457 RegionLightShareData wl = getWindlightProfileFromRules(rules); 736 RegionLightShareData wl;
737 try
738 {
739 wl = getWindlightProfileFromRules(rules);
740 }
741 catch(InvalidCastException e)
742 {
743 LSShoutError(e.Message);
744 return 0;
745 }
458 wl.valid = true; 746 wl.valid = true;
459 m_host.ParentGroup.Scene.StoreWindlightProfile(wl); 747 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
460 success = 1; 748 success = 1;
@@ -464,8 +752,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
464 LSShoutError("Windlight module is disabled"); 752 LSShoutError("Windlight module is disabled");
465 return 0; 753 return 0;
466 } 754 }
755
467 return success; 756 return success;
468 } 757 }
758
469 public void lsClearWindlightScene() 759 public void lsClearWindlightScene()
470 { 760 {
471 if (!m_LSFunctionsEnabled) 761 if (!m_LSFunctionsEnabled)
@@ -473,17 +763,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
473 LSShoutError("LightShare functions are not enabled."); 763 LSShoutError("LightShare functions are not enabled.");
474 return; 764 return;
475 } 765 }
476 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 766
767 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
477 { 768 {
478 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); 769 ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
479 return; 770
771 if (sp == null || sp.GodLevel < 200)
772 {
773 LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
774 return;
775 }
480 } 776 }
481 777
482 m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false; 778 m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false;
483 if (m_host.ParentGroup.Scene.SimulationDataService != null) 779 if (m_host.ParentGroup.Scene.SimulationDataService != null)
484 m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID); 780 m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID);
781
485 m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile(); 782 m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile();
486 } 783 }
784
487 /// <summary> 785 /// <summary>
488 /// Set the current Windlight scene to a target avatar 786 /// Set the current Windlight scene to a target avatar
489 /// </summary> 787 /// </summary>
@@ -496,16 +794,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
496 LSShoutError("LightShare functions are not enabled."); 794 LSShoutError("LightShare functions are not enabled.");
497 return 0; 795 return 0;
498 } 796 }
499 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) 797
798 if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID))
500 { 799 {
501 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); 800 ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
502 return 0; 801
802 if (sp == null || sp.GodLevel < 200)
803 {
804 LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
805 return 0;
806 }
503 } 807 }
808
504 int success = 0; 809 int success = 0;
505 m_host.AddScriptLPS(1); 810 m_host.AddScriptLPS(1);
811
506 if (LightShareModule.EnableWindlight) 812 if (LightShareModule.EnableWindlight)
507 { 813 {
508 RegionLightShareData wl = getWindlightProfileFromRules(rules); 814 RegionLightShareData wl;
815 try
816 {
817 wl = getWindlightProfileFromRules(rules);
818 }
819 catch(InvalidCastException e)
820 {
821 LSShoutError(e.Message);
822 return 0;
823 }
509 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); 824 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
510 success = 1; 825 success = 1;
511 } 826 }
@@ -514,8 +829,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
514 LSShoutError("Windlight module is disabled"); 829 LSShoutError("Windlight module is disabled");
515 return 0; 830 return 0;
516 } 831 }
832
517 return success; 833 return success;
518 } 834 }
519
520 } 835 }
521} 836}