From 6c44dceced81f3ae0a7650f8186f17b15dd55fe0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Nov 2016 13:39:49 +0000 Subject: change display and log of normal script errors --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 67 +++++++++++++++------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') 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 { try { - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - Part.AbsolutePosition, - Part.Name, Part.UUID, false); - - - m_log.Debug(string.Format( - "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", - ScriptName, - data.EventName, - PrimName, - Part.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name), - e); + + if(e.InnerException != null && e.InnerException is ScriptException) + { + string text = e.InnerException.Message + + "(script: " + ScriptName + + " event: " + data.EventName + + " at " + Part.AbsolutePosition + ")"; + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}", + e.InnerException.Message, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name)); + + } + else + { + + // DISPLAY ERROR INWORLD + string text = FormatException(e); + + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + + + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", + ScriptName, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name), + e); + } } catch (Exception) { -- cgit v1.1 From d1baa3e0c3b1783a68061980ffd8b9693c5a474a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 22:39:52 +0000 Subject: fix some invalid string.format arguments --- .../Shared/Api/Implementation/LSL_Api.cs | 89 +++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1a73c3e..bafee28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -14358,6 +14358,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return contacts.ToArray(); } + private ContactResult? GroundIntersection2(Vector3 rayStart, Vector3 rayEnd) + { + // get work copies + float sx = rayStart.X; + float ex = rayEnd.X; + float sy = rayStart.Y; + float ey = rayEnd.Y; + + float dx = ex - sx; + float dy = ey - sy; + + // region size info + float rsx = World.RegionInfo.RegionSizeX; + + float tmp; + + // region bounds + if(sx < 0) + { + if(ex < 0) // totally outside + return null; + if(dx <= 0) // out and going away + return null; + else if(ex >= rsx) + ex = rsx - 0.001f; + tmp = -sx / dx; + sy += dy * dx; + sx = 0; + } + else if(sx >= rsx) + { + if(ex >= rsx) // totally outside + return null; + if(dx >= 0) // out and going away + return null; + else if(ex < 0) + ex = 0; + tmp = (rsx - sx) / dx; + sy += dy * dx; + sx = rsx - 0.001f; + } + + float rsy = World.RegionInfo.RegionSizeY; + if(sy < 0) + { + if(dy <= 0) // out and going away + return null; + else if(ey >= rsy) + ey = rsy - 0.001f; + tmp = -sy / dy; + sx += dy * dx; + sy = 0; + } + else if(sy >= rsy) + { + if(dy >= 0) // out and going away + return null; + else if(ey < 0) + ey = 0; + tmp = (rsy - sy) / dy; + sx += dy * dx; + sy = rsy - 0.001f; + } + + if(sx < 0 || sx >= rsx) + return null; + + float sz = rayStart.Z; + float ez = rayEnd.Z; + float dz = ez - sz; + + float dist = dx * dx + dy * dy + dz * dz; + if(dist < 0.001) + return null; + dist = (float)Math.Sqrt(dist); + tmp = 1.0f / dist; + Vector3 rayn = new Vector3(dx * tmp, dy * tmp, dz * tmp); + + ContactResult? result = null; + + + + return result; + } + private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) { double[,] heightfield = World.Heightmap.GetDoubles(); @@ -16024,8 +16109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api catch (InvalidCastException e) { Error(originFunc,string.Format( - " error running rule #{1}: arg #{2} ", - rulesParsed, idx - idxStart) + e.Message); + " error running rule #{0}: arg #{1} {2}", + rulesParsed, idx - idxStart, e.Message)); } finally { -- cgit v1.1 From 4ebb4e371f44e8e8e9612d8e5eaab274263a2f89 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 13 Nov 2016 19:25:32 +0000 Subject: prevent self call to llSetScriptState(ownname,FALSE) from blocking entire engine --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bafee28..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 if ((item = GetScriptByName(name)) != UUID.Zero) { - m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); + m_ScriptEngine.SetScriptState(item, run == 0 ? false : true, item == m_item.ItemID); } else { -- cgit v1.1 From 05ba77fd3b72bb29a1f57245f8cd4ddeb6a19fb8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Nov 2016 03:47:48 +0000 Subject: fix parsing of a vector4 and storing on a lsl quaternion needed for lightShare scripts --- .../Shared/Api/Implementation/LS_Api.cs | 10 ++++----- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') 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 idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: idx++; - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); try { wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); 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 } } + // use LSL_Types.Quaternion to parse and store a vector4 for lightShare + public LSL_Types.Quaternion GetVector4Item(int itemIndex) + { + if (Data[itemIndex] is LSL_Types.Quaternion) + { + LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex]; + return q; + } + else if(Data[itemIndex] is OpenMetaverse.Quaternion) + { + LSL_Types.Quaternion q = new LSL_Types.Quaternion( + (OpenMetaverse.Quaternion)Data[itemIndex]); + q.Normalize(); + return q; + } + else + { + throw new InvalidCastException(string.Format( + "{0} expected but {1} given", + typeof(LSL_Types.Quaternion).Name, + Data[itemIndex] != null ? + Data[itemIndex].GetType().Name : "null")); + } + } + public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) { if (Data[itemIndex] is LSL_Types.Quaternion) -- cgit v1.1