diff options
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | 369 |
1 files changed, 328 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index b13a5ae..3406aea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -265,169 +265,438 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
265 | int idx = 0; | 265 | int idx = 0; |
266 | while (idx < rules.Length) | 266 | while (idx < rules.Length) |
267 | { | 267 | { |
268 | 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 | |||
269 | LSL_Types.Quaternion iQ; | 279 | LSL_Types.Quaternion iQ; |
270 | LSL_Types.Vector3 iV; | 280 | LSL_Types.Vector3 iV; |
271 | switch (rule) | 281 | switch (rule) |
272 | { | 282 | { |
273 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | 283 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: |
274 | idx++; | 284 | idx++; |
275 | 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 | } | ||
276 | break; | 293 | break; |
277 | case (int)ScriptBaseClass.WL_AMBIENT: | 294 | case (int)ScriptBaseClass.WL_AMBIENT: |
278 | idx++; | 295 | idx++; |
279 | 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 | } | ||
280 | 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); |
281 | break; | 305 | break; |
282 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | 306 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: |
283 | idx++; | 307 | idx++; |
284 | 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 | } | ||
285 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | 316 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
286 | break; | 317 | break; |
287 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | 318 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: |
288 | idx++; | 319 | idx++; |
289 | 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 | } | ||
290 | 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); |
291 | break; | 329 | break; |
292 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | 330 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: |
293 | idx++; | 331 | idx++; |
294 | 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 | } | ||
295 | break; | 340 | break; |
296 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | 341 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: |
297 | idx++; | 342 | idx++; |
298 | 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 | } | ||
299 | 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); |
300 | break; | 352 | break; |
301 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | 353 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: |
302 | idx++; | 354 | idx++; |
303 | 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 | } | ||
304 | break; | 363 | break; |
305 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | 364 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
306 | idx++; | 365 | idx++; |
307 | 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 | } | ||
308 | wl.cloudDetailXYDensity = iV; | 374 | wl.cloudDetailXYDensity = iV; |
309 | break; | 375 | break; |
310 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | 376 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
311 | idx++; | 377 | idx++; |
312 | 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 | } | ||
313 | break; | 386 | break; |
314 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | 387 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: |
315 | idx++; | 388 | idx++; |
316 | 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 | } | ||
317 | break; | 397 | break; |
318 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | 398 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: |
319 | idx++; | 399 | idx++; |
320 | 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 | } | ||
321 | break; | 408 | break; |
322 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | 409 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: |
323 | idx++; | 410 | idx++; |
324 | 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 | } | ||
325 | break; | 419 | break; |
326 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | 420 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: |
327 | idx++; | 421 | idx++; |
328 | 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 | } | ||
329 | break; | 430 | break; |
330 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | 431 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
331 | idx++; | 432 | idx++; |
332 | 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 | } | ||
333 | wl.cloudXYDensity = iV; | 441 | wl.cloudXYDensity = iV; |
334 | break; | 442 | break; |
335 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | 443 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
336 | idx++; | 444 | idx++; |
337 | 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 | } | ||
338 | break; | 453 | break; |
339 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | 454 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: |
340 | idx++; | 455 | idx++; |
341 | 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 | } | ||
342 | break; | 464 | break; |
343 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | 465 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: |
344 | idx++; | 466 | idx++; |
345 | 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 | } | ||
346 | break; | 475 | break; |
347 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | 476 | case (int)ScriptBaseClass.WL_EAST_ANGLE: |
348 | idx++; | 477 | idx++; |
349 | 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 | } | ||
350 | break; | 486 | break; |
351 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | 487 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: |
352 | idx++; | 488 | idx++; |
353 | 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 | } | ||
354 | break; | 497 | break; |
355 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | 498 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: |
356 | idx++; | 499 | idx++; |
357 | 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 | } | ||
358 | break; | 508 | break; |
359 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | 509 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: |
360 | idx++; | 510 | idx++; |
361 | 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 | } | ||
362 | break; | 519 | break; |
363 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | 520 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: |
364 | idx++; | 521 | idx++; |
365 | 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 | } | ||
366 | break; | 530 | break; |
367 | case (int)ScriptBaseClass.WL_HORIZON: | 531 | case (int)ScriptBaseClass.WL_HORIZON: |
368 | idx++; | 532 | idx++; |
369 | 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 | } | ||
370 | 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); |
371 | break; | 542 | break; |
372 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | 543 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: |
373 | idx++; | 544 | idx++; |
374 | 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 | } | ||
375 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | 553 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
376 | break; | 554 | break; |
377 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | 555 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: |
378 | idx++; | 556 | idx++; |
379 | 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 | } | ||
380 | break; | 565 | break; |
381 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | 566 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: |
382 | idx++; | 567 | idx++; |
383 | 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 | } | ||
384 | break; | 576 | break; |
385 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | 577 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
386 | idx++; | 578 | idx++; |
387 | 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 | } | ||
388 | wl.reflectionWaveletScale = iV; | 587 | wl.reflectionWaveletScale = iV; |
389 | break; | 588 | break; |
390 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | 589 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
391 | idx++; | 590 | idx++; |
392 | 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 | } | ||
393 | break; | 599 | break; |
394 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | 600 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: |
395 | idx++; | 601 | idx++; |
396 | 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 | } | ||
397 | break; | 610 | break; |
398 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | 611 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: |
399 | idx++; | 612 | idx++; |
400 | 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 | } | ||
401 | break; | 621 | break; |
402 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | 622 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: |
403 | idx++; | 623 | idx++; |
404 | 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 | } | ||
405 | break; | 632 | break; |
406 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | 633 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: |
407 | idx++; | 634 | idx++; |
408 | 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 | } | ||
409 | break; | 643 | break; |
410 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | 644 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: |
411 | idx++; | 645 | idx++; |
412 | 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 | } | ||
413 | break; | 654 | break; |
414 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | 655 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: |
415 | idx++; | 656 | idx++; |
416 | iQ = rules.GetQuaternionItem(idx); | 657 | iQ = rules.GetQuaternionItem(idx); |
417 | 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 | } | ||
418 | break; | 666 | break; |
419 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | 667 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: |
420 | idx++; | 668 | idx++; |
421 | 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 | } | ||
422 | break; | 677 | break; |
423 | case (int)ScriptBaseClass.WL_WATER_COLOR: | 678 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
424 | idx++; | 679 | idx++; |
425 | 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 | } | ||
426 | wl.waterColor = iV; | 688 | wl.waterColor = iV; |
427 | break; | 689 | break; |
428 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | 690 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
429 | idx++; | 691 | idx++; |
430 | 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 | } | ||
431 | break; | 700 | break; |
432 | } | 701 | } |
433 | idx++; | 702 | idx++; |
@@ -464,7 +733,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
464 | 733 | ||
465 | if (LightShareModule.EnableWindlight) | 734 | if (LightShareModule.EnableWindlight) |
466 | { | 735 | { |
467 | 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 | } | ||
468 | wl.valid = true; | 746 | wl.valid = true; |
469 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | 747 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); |
470 | success = 1; | 748 | success = 1; |
@@ -532,8 +810,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
532 | m_host.AddScriptLPS(1); | 810 | m_host.AddScriptLPS(1); |
533 | 811 | ||
534 | if (LightShareModule.EnableWindlight) | 812 | if (LightShareModule.EnableWindlight) |
535 | { | 813 | { |
536 | 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 | } | ||
537 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | 824 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); |
538 | success = 1; | 825 | success = 1; |
539 | } | 826 | } |