From 61978649ec1642f1c0bf0a3aa6492cebefab85d3 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 2 Sep 2008 03:43:18 +0000 Subject: Change some chat output functions so that text is truncated at 1000 chars to avoid the exception thrown by libomv at 1100 chars. Change string->int conversion so it copes with non-numeric chars after the number and no longer uses a float to parse the value. --- OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs | 5 ++++- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 6 +++--- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 9 ++++++++- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs index f98633f..1493e32 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs @@ -161,6 +161,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat string message = e.Message; LLUUID fromID = e.SenderUUID; + if(message.Length >= 1000) // libomv limit + message = message.Substring(0, 1000); + if (e.Sender != null) { avatar = scene.GetScenePresence(e.Sender.AgentId); @@ -240,4 +243,4 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 8ce1413..6b674f3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -517,9 +517,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance try { // DISPLAY ERROR INWORLD - string text = "Runtime error:\n" + e.ToString(); - if (text.Length > 1400) - text = text.Substring(0, 1400); + string text = "Runtime error:\n" + e.InnerException.ToString(); + if (text.Length > 1000) + text = text.Substring(0, 1000); m_Engine.World.SimChat(Helpers.StringToField(text), ChatTypeEnum.DebugChannel, 2147483647, part.AbsolutePosition, diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index babb759..23177e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1394,8 +1394,15 @@ namespace OpenSim.Region.ScriptEngine.Shared static public explicit operator LSLInteger(string s) { + Regex r = new Regex("^[0-9][0-9]*"); + Match m = r.Match(s); + string v = m.Groups[0].Value; + + if (v == String.Empty) + v = "0"; + // double.Parse() used because s could be "123.9" for example. - return new LSLInteger(double.Parse(s)); + return new LSLInteger(int.Parse(v)); } static public implicit operator LSLInteger(uint u) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a33554c..f9f8883 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -432,8 +432,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine { // DISPLAY ERROR INWORLD string text = "Error compiling script:\r\n" + e.Message.ToString(); - if (text.Length > 1400) - text = text.Substring(0, 1400); + if (text.Length > 1000) + text = text.Substring(0, 1000); World.SimChat(Helpers.StringToField(text), ChatTypeEnum.DebugChannel, 2147483647, part.AbsolutePosition, -- cgit v1.1