From a68e34b5587723899cbc20e6e27a47ad01234718 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 10 Sep 2008 06:14:38 +0000 Subject: Mantis #511 Allow parsing of hexadecimal int constants from strings. Also fixes a DBNull value in the touch type field crashing the sim --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 004b53e..9f69ebb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1337,14 +1337,16 @@ namespace OpenSim.Region.ScriptEngine.Shared public static explicit operator LSLInteger(LSLString s) { - Regex r = new Regex("^[ ]*-?[0-9][0-9]*"); + Regex r = new Regex("^[ ]*-?[0-9][0-9xX]?[0-9a-fA-F]*"); Match m = r.Match(s); string v = m.Groups[0].Value; if (v == String.Empty) v = "0"; - return new LSLInteger(int.Parse(v)); + if (v.Contains("x") || v.Contains("X")) + return new LSLInteger(int.Parse(v.Substring(2), System.Globalization.NumberStyles.HexNumber)); + return new LSLInteger(int.Parse(v, System.Globalization.NumberStyles.Integer)); } public static explicit operator LSLString(double d) @@ -1468,14 +1470,16 @@ namespace OpenSim.Region.ScriptEngine.Shared static public explicit operator LSLInteger(string s) { - Regex r = new Regex("^[ ]*-?[0-9][0-9]*"); + Regex r = new Regex("^[ ]*-?[0-9][0-9xX]?[0-9a-fA-F]*"); Match m = r.Match(s); string v = m.Groups[0].Value; if (v == String.Empty) v = "0"; - return new LSLInteger(int.Parse(v)); + if (v.Contains("x") || v.Contains("X")) + return new LSLInteger(int.Parse(v.Substring(2), System.Globalization.NumberStyles.HexNumber)); + return new LSLInteger(int.Parse(v, System.Globalization.NumberStyles.Integer)); } static public implicit operator LSLInteger(uint u) -- cgit v1.1