diff --git a/libsecondlife/AssetSystem/AssetWearable.cs b/libsecondlife/AssetSystem/AssetWearable.cs index 98626de8..cfa5cdd0 100644 --- a/libsecondlife/AssetSystem/AssetWearable.cs +++ b/libsecondlife/AssetSystem/AssetWearable.cs @@ -284,9 +284,6 @@ namespace libsecondlife.AssetSystem /// internal void UpdateFromAssetData() { - Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us"); - Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us"); - if ( AssetData == null || AssetData.Length == 0) { return; @@ -417,12 +414,10 @@ namespace libsecondlife.AssetSystem try { int id = Int32.Parse(fields[0]); - float weight; Single.Parse(fields[1], System.Globalization.NumberStyles.Float); - if (Single.TryParse(fields[1], System.Globalization.NumberStyles.Float, new CultureInfo("en-us").NumberFormat, out weight) == false) - { - weight = 0.0f; - } + float weight = 0.0f; + Single.TryParse(fields[1], System.Globalization.NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat, out weight); _Parameters[id] = weight; } catch (Exception) diff --git a/libsecondlife/Helpers.cs b/libsecondlife/Helpers.cs index e69e85c7..3c8e95b2 100644 --- a/libsecondlife/Helpers.cs +++ b/libsecondlife/Helpers.cs @@ -109,6 +109,12 @@ namespace libsecondlife public static System.Security.Cryptography.MD5 MD5Builder = new System.Security.Cryptography.MD5CryptoServiceProvider(); + /// Provide a single instance of the CultureInfo class to + /// help parsing in situations where Second Life assumes an en-us + /// culture + public static readonly System.Globalization.CultureInfo EnUsCulture = + new System.Globalization.CultureInfo("en-us"); + /// /// Converts an unsigned integer to a hexadecimal string /// diff --git a/libsecondlife/LLSD.cs b/libsecondlife/LLSD.cs index ddb0f4f6..2f0117a4 100644 --- a/libsecondlife/LLSD.cs +++ b/libsecondlife/LLSD.cs @@ -529,7 +529,8 @@ namespace libsecondlife double value; endPos = FindEnd(llsd, 1); - if (Double.TryParse(llsd.Substring(1, endPos - 1), out value)) + if (Double.TryParse(llsd.Substring(1, endPos - 1), System.Globalization.NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); diff --git a/libsecondlife/NameValue.cs b/libsecondlife/NameValue.cs index add697ba..99115569 100644 --- a/libsecondlife/NameValue.cs +++ b/libsecondlife/NameValue.cs @@ -213,7 +213,7 @@ namespace libsecondlife case ValueType.F32: { float temp = 0.0f; - Single.TryParse(value, out temp); + Single.TryParse(value, System.Globalization.NumberStyles.Float, Helpers.EnUsCulture.NumberFormat, out temp); Value = temp; break; } diff --git a/libsecondlife/Simulator.cs b/libsecondlife/Simulator.cs index a1c50935..aa934d86 100644 --- a/libsecondlife/Simulator.cs +++ b/libsecondlife/Simulator.cs @@ -840,16 +840,13 @@ namespace libsecondlife #endregion FireCallbacks - if (Client.Settings.DEBUG) + int workerThreads, completionPortThreads; + ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); + if (workerThreads == 0 || completionPortThreads == 0) { - int workerThreads, completionPortThreads; - ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); - if (workerThreads == 0 || completionPortThreads == 0) - { - Client.Log(String.Format( - "Thread starvation, packets will be dropped. WorkerThreads: {0}, CompletionPortThreads: {1}", - workerThreads, completionPortThreads), Helpers.LogLevel.Error); - } + Client.Log(String.Format( + "Thread starvation, packets will be dropped. WorkerThreads: {0}, CompletionPortThreads: {1}", + workerThreads, completionPortThreads), Helpers.LogLevel.Error); } } diff --git a/libsecondlife/VisualParamGenerator/VisualParamGenerator.cs b/libsecondlife/VisualParamGenerator/VisualParamGenerator.cs index cb08bd2e..e3f14793 100644 --- a/libsecondlife/VisualParamGenerator/VisualParamGenerator.cs +++ b/libsecondlife/VisualParamGenerator/VisualParamGenerator.cs @@ -8,6 +8,9 @@ namespace VisualParamGenerator { class VisualParamGenerator { + public static readonly System.Globalization.CultureInfo EnUsCulture = + new System.Globalization.CultureInfo("en-us"); + static void Main(string[] args) { if (args.Length < 3) @@ -109,12 +112,15 @@ namespace VisualParamGenerator if (node.Attributes["label_max"] != null) label_max = node.Attributes["label_max"].Value; - float min = Single.Parse(node.Attributes["value_min"].Value); - float max = Single.Parse(node.Attributes["value_max"].Value); + float min = Single.Parse(node.Attributes["value_min"].Value, + System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat); + float max = Single.Parse(node.Attributes["value_max"].Value, + System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat); float def; if (node.Attributes["value_default"] != null) - def = Single.Parse(node.Attributes["value_default"].Value); + def = Single.Parse(node.Attributes["value_default"].Value, + System.Globalization.NumberStyles.Float, EnUsCulture.NumberFormat); else def = min; diff --git a/libsecondlife/libsecondlife.Utilities/Appearance.cs b/libsecondlife/libsecondlife.Utilities/Appearance.cs index f7a9be65..be04d789 100644 --- a/libsecondlife/libsecondlife.Utilities/Appearance.cs +++ b/libsecondlife/libsecondlife.Utilities/Appearance.cs @@ -277,7 +277,8 @@ namespace libsecondlife.Utilities.Appearance try { int id = Int32.Parse(fields[0]); - float weight = Single.Parse(fields[1]); + float weight = Single.Parse(fields[1], System.Globalization.NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat); Params[id] = weight; } diff --git a/libsecondlife/libsecondlife.Utilities/Assets.cs b/libsecondlife/libsecondlife.Utilities/Assets.cs index b7e962fb..bc2deef8 100644 --- a/libsecondlife/libsecondlife.Utilities/Assets.cs +++ b/libsecondlife/libsecondlife.Utilities/Assets.cs @@ -387,8 +387,8 @@ namespace libsecondlife.Utilities.Assets /// /// /// - public void RequestUpload(LLUUID transactionID, AssetType type, byte[] data, - bool tempFile, bool storeLocal, bool isPriority) + public void RequestUpload(LLUUID transactionID, AssetType type, byte[] data, bool tempFile, bool storeLocal, + bool isPriority) { if (!Transfers.ContainsKey(transactionID)) { @@ -485,7 +485,7 @@ namespace libsecondlife.Utilities.Assets else { Client.Log("Received a TransferInfo packet with a SourceType of " + transfer.Source.ToString() + - " and a Params field length of " + info.TransferInfo.Params.Length, + " and a Params field length of " + info.TransferInfo.Params.Length, Helpers.LogLevel.Warning); } } @@ -723,7 +723,7 @@ namespace libsecondlife.Utilities.Assets } // The header is downloaded, we can insert this data in to the proper position - Array.Copy(image.ImageData.Data, 0, transfer.AssetData, transfer.InitialDataSize + + Array.Copy(image.ImageData.Data, 0, transfer.AssetData, transfer.InitialDataSize + (1000 * (image.ImageID.Packet - 1)), image.ImageData.Data.Length); transfer.Transferred += image.ImageData.Data.Length;