aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs91
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs67
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs25
4 files changed, 165 insertions, 28 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 1a73c3e..af04951 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -521,7 +521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
521 521
522 if ((item = GetScriptByName(name)) != UUID.Zero) 522 if ((item = GetScriptByName(name)) != UUID.Zero)
523 { 523 {
524 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); 524 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true, item == m_item.ItemID);
525 } 525 }
526 else 526 else
527 { 527 {
@@ -14358,6 +14358,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
14358 return contacts.ToArray(); 14358 return contacts.ToArray();
14359 } 14359 }
14360 14360
14361 private ContactResult? GroundIntersection2(Vector3 rayStart, Vector3 rayEnd)
14362 {
14363 // get work copies
14364 float sx = rayStart.X;
14365 float ex = rayEnd.X;
14366 float sy = rayStart.Y;
14367 float ey = rayEnd.Y;
14368
14369 float dx = ex - sx;
14370 float dy = ey - sy;
14371
14372 // region size info
14373 float rsx = World.RegionInfo.RegionSizeX;
14374
14375 float tmp;
14376
14377 // region bounds
14378 if(sx < 0)
14379 {
14380 if(ex < 0) // totally outside
14381 return null;
14382 if(dx <= 0) // out and going away
14383 return null;
14384 else if(ex >= rsx)
14385 ex = rsx - 0.001f;
14386 tmp = -sx / dx;
14387 sy += dy * dx;
14388 sx = 0;
14389 }
14390 else if(sx >= rsx)
14391 {
14392 if(ex >= rsx) // totally outside
14393 return null;
14394 if(dx >= 0) // out and going away
14395 return null;
14396 else if(ex < 0)
14397 ex = 0;
14398 tmp = (rsx - sx) / dx;
14399 sy += dy * dx;
14400 sx = rsx - 0.001f;
14401 }
14402
14403 float rsy = World.RegionInfo.RegionSizeY;
14404 if(sy < 0)
14405 {
14406 if(dy <= 0) // out and going away
14407 return null;
14408 else if(ey >= rsy)
14409 ey = rsy - 0.001f;
14410 tmp = -sy / dy;
14411 sx += dy * dx;
14412 sy = 0;
14413 }
14414 else if(sy >= rsy)
14415 {
14416 if(dy >= 0) // out and going away
14417 return null;
14418 else if(ey < 0)
14419 ey = 0;
14420 tmp = (rsy - sy) / dy;
14421 sx += dy * dx;
14422 sy = rsy - 0.001f;
14423 }
14424
14425 if(sx < 0 || sx >= rsx)
14426 return null;
14427
14428 float sz = rayStart.Z;
14429 float ez = rayEnd.Z;
14430 float dz = ez - sz;
14431
14432 float dist = dx * dx + dy * dy + dz * dz;
14433 if(dist < 0.001)
14434 return null;
14435 dist = (float)Math.Sqrt(dist);
14436 tmp = 1.0f / dist;
14437 Vector3 rayn = new Vector3(dx * tmp, dy * tmp, dz * tmp);
14438
14439 ContactResult? result = null;
14440
14441
14442
14443 return result;
14444 }
14445
14361 private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) 14446 private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd)
14362 { 14447 {
14363 double[,] heightfield = World.Heightmap.GetDoubles(); 14448 double[,] heightfield = World.Heightmap.GetDoubles();
@@ -16024,8 +16109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
16024 catch (InvalidCastException e) 16109 catch (InvalidCastException e)
16025 { 16110 {
16026 Error(originFunc,string.Format( 16111 Error(originFunc,string.Format(
16027 " error running rule #{1}: arg #{2} ", 16112 " error running rule #{0}: arg #{1} {2}",
16028 rulesParsed, idx - idxStart) + e.Message); 16113 rulesParsed, idx - idxStart, e.Message));
16029 } 16114 }
16030 finally 16115 finally
16031 { 16116 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index e5e43f8..8cd065b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -295,7 +295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
295 idx++; 295 idx++;
296 try 296 try
297 { 297 {
298 iQ = rules.GetQuaternionItem(idx); 298 iQ = rules.GetVector4Item(idx);
299 } 299 }
300 catch (InvalidCastException) 300 catch (InvalidCastException)
301 { 301 {
@@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
319 idx++; 319 idx++;
320 try 320 try
321 { 321 {
322 iQ = rules.GetQuaternionItem(idx); 322 iQ = rules.GetVector4Item(idx);
323 } 323 }
324 catch (InvalidCastException) 324 catch (InvalidCastException)
325 { 325 {
@@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
342 idx++; 342 idx++;
343 try 343 try
344 { 344 {
345 iQ = rules.GetQuaternionItem(idx); 345 iQ = rules.GetVector4Item(idx);
346 } 346 }
347 catch (InvalidCastException) 347 catch (InvalidCastException)
348 { 348 {
@@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
532 idx++; 532 idx++;
533 try 533 try
534 { 534 {
535 iQ = rules.GetQuaternionItem(idx); 535 iQ = rules.GetVector4Item(idx);
536 } 536 }
537 catch (InvalidCastException) 537 catch (InvalidCastException)
538 { 538 {
@@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
654 break; 654 break;
655 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: 655 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
656 idx++; 656 idx++;
657 iQ = rules.GetQuaternionItem(idx); 657 iQ = rules.GetVector4Item(idx);
658 try 658 try
659 { 659 {
660 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 660 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 611df58..d725907 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -924,26 +924,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
924 { 924 {
925 try 925 try
926 { 926 {
927 // DISPLAY ERROR INWORLD 927
928 string text = FormatException(e); 928 if(e.InnerException != null && e.InnerException is ScriptException)
929 929 {
930 if (text.Length > 1000) 930 string text = e.InnerException.Message +
931 text = text.Substring(0, 1000); 931 "(script: " + ScriptName +
932 Engine.World.SimChat(Utils.StringToBytes(text), 932 " event: " + data.EventName +
933 ChatTypeEnum.DebugChannel, 2147483647, 933 " at " + Part.AbsolutePosition + ")";
934 Part.AbsolutePosition, 934 if (text.Length > 1000)
935 Part.Name, Part.UUID, false); 935 text = text.Substring(0, 1000);
936 936 Engine.World.SimChat(Utils.StringToBytes(text),
937 937 ChatTypeEnum.DebugChannel, 2147483647,
938 m_log.Debug(string.Format( 938 Part.AbsolutePosition,
939 "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", 939 Part.Name, Part.UUID, false);
940 ScriptName, 940 m_log.Debug(string.Format(
941 data.EventName, 941 "[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}",
942 PrimName, 942 e.InnerException.Message,
943 Part.UUID, 943 data.EventName,
944 Part.AbsolutePosition, 944 PrimName,
945 Part.ParentGroup.Scene.Name), 945 Part.UUID,
946 e); 946 Part.AbsolutePosition,
947 Part.ParentGroup.Scene.Name));
948
949 }
950 else
951 {
952
953 // DISPLAY ERROR INWORLD
954 string text = FormatException(e);
955
956 if (text.Length > 1000)
957 text = text.Substring(0, 1000);
958 Engine.World.SimChat(Utils.StringToBytes(text),
959 ChatTypeEnum.DebugChannel, 2147483647,
960 Part.AbsolutePosition,
961 Part.Name, Part.UUID, false);
962
963
964 m_log.Debug(string.Format(
965 "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ",
966 ScriptName,
967 data.EventName,
968 PrimName,
969 Part.UUID,
970 Part.AbsolutePosition,
971 Part.ParentGroup.Scene.Name),
972 e);
973 }
947 } 974 }
948 catch (Exception) 975 catch (Exception)
949 { 976 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index c36e7c6..738a814 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -700,6 +700,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
700 } 700 }
701 } 701 }
702 702
703 // use LSL_Types.Quaternion to parse and store a vector4 for lightShare
704 public LSL_Types.Quaternion GetVector4Item(int itemIndex)
705 {
706 if (Data[itemIndex] is LSL_Types.Quaternion)
707 {
708 LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex];
709 return q;
710 }
711 else if(Data[itemIndex] is OpenMetaverse.Quaternion)
712 {
713 LSL_Types.Quaternion q = new LSL_Types.Quaternion(
714 (OpenMetaverse.Quaternion)Data[itemIndex]);
715 q.Normalize();
716 return q;
717 }
718 else
719 {
720 throw new InvalidCastException(string.Format(
721 "{0} expected but {1} given",
722 typeof(LSL_Types.Quaternion).Name,
723 Data[itemIndex] != null ?
724 Data[itemIndex].GetType().Name : "null"));
725 }
726 }
727
703 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) 728 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
704 { 729 {
705 if (Data[itemIndex] is LSL_Types.Quaternion) 730 if (Data[itemIndex] is LSL_Types.Quaternion)