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/Data/MySQL/MySQLRegionData.cs | 3 ++- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 920a001..9c36d49 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -1226,7 +1226,8 @@ namespace OpenSim.Data.MySQL prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); - prim.ClickAction = Convert.ToByte(row["ClickAction"]); + if (!row.IsNull("ClickAction")) + prim.ClickAction = Convert.ToByte(row["ClickAction"]); return prim; } 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