From 00800c59d35662d65aeb61a17de0d56fa6196509 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Feb 2010 23:13:35 +0000 Subject: Apply last two patches from http://opensimulator.org/mantis/view.php?id=3522 These patch should allow people using systems that do not have their locale set to En_US or similar to use OpenSim without suffering effects such as being a million miles up in the air on login. The problem was caused by parsing strings without forcing that parse to be En_US (hence different decimal and digit group symbols were causing problems). Thanks very much to VikingErik for doing the legwork on this fix and phacelia for spotting it in the first place. --- .../Shared/Instance/ScriptSerializer.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 32 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs index bf3d335..bcdc7bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs @@ -389,7 +389,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance break; case "MinEventDelay": double minEventDelay = 0.0; - double.TryParse(part.InnerText, out minEventDelay); + double.TryParse(part.InnerText, NumberStyles.Float, Culture.NumberFormatInfo, out minEventDelay); instance.MinEventDelay = minEventDelay; break; } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index faf9c40..e87b1f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -72,9 +72,9 @@ namespace OpenSim.Region.ScriptEngine.Shared return; } bool res; - res = Double.TryParse(tmps[0], out x); - res = res & Double.TryParse(tmps[1], out y); - res = res & Double.TryParse(tmps[2], out z); + res = Double.TryParse(tmps[0], NumberStyles.Float, Culture.NumberFormatInfo, out x); + res = res & Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y); + res = res & Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z); } #endregion @@ -309,10 +309,10 @@ namespace OpenSim.Region.ScriptEngine.Shared return; } bool res; - res = Double.TryParse(tmps[0], NumberStyles.Float, Culture.FormatProvider, out x); - res = res & Double.TryParse(tmps[1], NumberStyles.Float, Culture.FormatProvider, out y); - res = res & Double.TryParse(tmps[2], NumberStyles.Float, Culture.FormatProvider, out z); - res = res & Double.TryParse(tmps[3], NumberStyles.Float, Culture.FormatProvider, out s); + res = Double.TryParse(tmps[0], NumberStyles.Float, Culture.NumberFormatInfo, out x); + res = res & Double.TryParse(tmps[1], NumberStyles.Float, Culture.NumberFormatInfo, out y); + res = res & Double.TryParse(tmps[2], NumberStyles.Float, Culture.NumberFormatInfo, out z); + res = res & Double.TryParse(tmps[3], NumberStyles.Float, Culture.NumberFormatInfo, out s); if (x == 0 && y == 0 && z == 0 && s == 0) s = 1; } @@ -1015,7 +1015,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(Data[i].ToString(), out entry)) + if (double.TryParse(Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { if (entry < minimum) minimum = entry; } @@ -1029,7 +1029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(Data[i].ToString(), out entry)) + if (double.TryParse(Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { if (entry > maximum) maximum = entry; } @@ -1048,7 +1048,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(Data[i].ToString(), out entry)) + if (double.TryParse(Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { count++; } @@ -1062,7 +1062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < src.Data.Length - 1; i++) { - if (double.TryParse(src.Data[i].ToString(), out entry)) + if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { ret.Add(entry); } @@ -1076,7 +1076,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(Data[i].ToString(), out entry)) + if (double.TryParse(Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { sum = sum + entry; } @@ -1090,7 +1090,7 @@ namespace OpenSim.Region.ScriptEngine.Shared double entry; for (int i = 0; i < Data.Length; i++) { - if (double.TryParse(Data[i].ToString(), out entry)) + if (double.TryParse(Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry)) { sum = sum + Math.Pow(entry, 2); } @@ -1213,11 +1213,11 @@ namespace OpenSim.Region.ScriptEngine.Shared { double a; double b; - if (!double.TryParse(x.ToString(), out a)) + if (!double.TryParse(x.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out a)) { a = 0.0; } - if (!double.TryParse(y.ToString(), out b)) + if (!double.TryParse(y.ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out b)) { b = 0.0; } @@ -1857,7 +1857,7 @@ namespace OpenSim.Region.ScriptEngine.Shared else if (v.EndsWith(".")) v = v + "0"; - this.value = double.Parse(v, System.Globalization.NumberStyles.Float, Culture.FormatProvider); + this.value = double.Parse(v, System.Globalization.NumberStyles.Float, Culture.NumberFormatInfo); } #endregion -- cgit v1.1