mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Mantis #511
Allow parsing of hexadecimal int constants from strings. Also fixes a DBNull value in the touch type field crashing the sim
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user