From f6fa4ada4ea8680e49a47e2b9a5741c8d33ef74d Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 28 Jul 2008 07:46:53 +0000 Subject: When casting strings to int, use double.Parse() as strings may be floats. With this commit, issue 1822 should be fixed. --- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common/LSL_Types.cs') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 74c9935..d0a5079 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -1172,7 +1172,8 @@ namespace OpenSim.Region.ScriptEngine.Common public static explicit operator LSLInteger(LSLString s) { - return new LSLInteger(Convert.ToInt32(s.m_string)); + // double.Parse() used because s could be "123.9" for example. + return new LSLInteger(double.Parse(s.m_string)); } public static explicit operator LSLString(double d) @@ -1283,7 +1284,8 @@ namespace OpenSim.Region.ScriptEngine.Common static public explicit operator LSLInteger(string s) { - return new LSLInteger(int.Parse(s)); + // double.Parse() used because s could be "123.9" for example. + return new LSLInteger(double.Parse(s)); } static public implicit operator LSLInteger(uint u) -- cgit v1.1