Allow parsing of hexadecimal int constants from strings.
Also fixes a DBNull value in the touch type field crashing the sim
0.6.0-stable
Melanie Thielker 2008-09-10 06:14:38 +00:00
parent b9b996be38
commit a68e34b558
2 changed files with 10 additions and 5 deletions

View File

@ -1226,7 +1226,8 @@ namespace OpenSim.Data.MySQL
prim.SalePrice = Convert.ToInt32(row["SalePrice"]); prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
prim.ClickAction = Convert.ToByte(row["ClickAction"]); if (!row.IsNull("ClickAction"))
prim.ClickAction = Convert.ToByte(row["ClickAction"]);
return prim; return prim;
} }

View File

@ -1337,14 +1337,16 @@ namespace OpenSim.Region.ScriptEngine.Shared
public static explicit operator LSLInteger(LSLString s) 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); Match m = r.Match(s);
string v = m.Groups[0].Value; string v = m.Groups[0].Value;
if (v == String.Empty) if (v == String.Empty)
v = "0"; 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) public static explicit operator LSLString(double d)
@ -1468,14 +1470,16 @@ namespace OpenSim.Region.ScriptEngine.Shared
static public explicit operator LSLInteger(string s) 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); Match m = r.Match(s);
string v = m.Groups[0].Value; string v = m.Groups[0].Value;
if (v == String.Empty) if (v == String.Empty)
v = "0"; 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) static public implicit operator LSLInteger(uint u)