diff --git a/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs index a9a38df..7193697 100644 --- a/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs @@ -1,4 +1,5 @@ -using System.Drawing; +using System.Drawing; +using System.Globalization; using System.Reflection; using System.Text; using Cysharp.Text; @@ -288,7 +289,7 @@ public sealed class VirtualParadiseParticleEmitterObject : VirtualParadiseObject } else if (property.PropertyType != typeof(string)) { - value = Convert.ChangeType(value, property.PropertyType); + value = Convert.ChangeType(value, property.PropertyType, CultureInfo.InvariantCulture); } property.SetValue(this, value); diff --git a/VpSharp/src/Entities/VirtualParadisePathObject.cs b/VpSharp/src/Entities/VirtualParadisePathObject.cs index 50f7a15..cc4f781 100644 --- a/VpSharp/src/Entities/VirtualParadisePathObject.cs +++ b/VpSharp/src/Entities/VirtualParadisePathObject.cs @@ -1,4 +1,5 @@ -using System.Numerics; +using System.Globalization; +using System.Numerics; using System.Text; using Cysharp.Text; using VpSharp.Extensions; @@ -81,8 +82,8 @@ public sealed class VirtualParadisePathObject : VirtualParadiseObject int spaceIndex = chars[index..].IndexOf(' '); int newLineIndex = chars[index..].IndexOf('\n'); - int pathType = int.Parse(chars[index..(index + spaceIndex)]); - int closed = int.Parse(chars[(index + spaceIndex + 1)..(index + newLineIndex)]); + int pathType = int.Parse(chars[index..(index + spaceIndex)], provider: CultureInfo.InvariantCulture); + int closed = int.Parse(chars[(index + spaceIndex + 1)..(index + newLineIndex)], provider: CultureInfo.InvariantCulture); index += newLineIndex; // points from here onwards diff --git a/VpSharp/src/Extensions/SpanExtensions.cs b/VpSharp/src/Extensions/SpanExtensions.cs index 04e94ca..44af69b 100644 --- a/VpSharp/src/Extensions/SpanExtensions.cs +++ b/VpSharp/src/Extensions/SpanExtensions.cs @@ -1,3 +1,4 @@ +using System.Globalization; using System.Numerics; using System.Text; using Cysharp.Text; @@ -10,21 +11,21 @@ internal static class SpanExtensions { Span chars = stackalloc char[value.Length]; Encoding.UTF8.GetChars(value, chars); - return double.Parse(chars.Trim()); + return double.Parse(chars.Trim(), provider: CultureInfo.InvariantCulture); } public static int ToInt32(this ReadOnlySpan value) { Span chars = stackalloc char[value.Length]; Encoding.UTF8.GetChars(value, chars); - return int.Parse(chars.Trim()); + return int.Parse(chars.Trim(), provider: CultureInfo.InvariantCulture); } public static float ToSingle(this ReadOnlySpan value) { Span chars = stackalloc char[value.Length]; Encoding.UTF8.GetChars(value, chars); - return float.Parse(chars.Trim()); + return float.Parse(chars.Trim(), provider: CultureInfo.InvariantCulture); } public static Vector2 ToVector2(this ReadOnlySpan value) diff --git a/VpSharp/src/Internal/ValueConverters/HexToColorConverter.cs b/VpSharp/src/Internal/ValueConverters/HexToColorConverter.cs index fe1be2b..152a404 100644 --- a/VpSharp/src/Internal/ValueConverters/HexToColorConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/HexToColorConverter.cs @@ -13,13 +13,13 @@ internal sealed class HexToColorConverter : ValueConverter Span buffer = stackalloc char[2]; reader.Read(buffer); - int r = int.Parse(buffer, NumberStyles.HexNumber); + int r = int.Parse(buffer, NumberStyles.HexNumber, CultureInfo.InvariantCulture); reader.Read(buffer); - int g = int.Parse(buffer, NumberStyles.HexNumber); + int g = int.Parse(buffer, NumberStyles.HexNumber, CultureInfo.InvariantCulture); reader.Read(buffer); - int b = int.Parse(buffer, NumberStyles.HexNumber); + int b = int.Parse(buffer, NumberStyles.HexNumber, CultureInfo.InvariantCulture); result = Color.FromArgb(r, g, b); } diff --git a/VpSharp/src/Internal/ValueConverters/IntToEnumConverter.cs b/VpSharp/src/Internal/ValueConverters/IntToEnumConverter.cs index 36aa98b..85ee16d 100644 --- a/VpSharp/src/Internal/ValueConverters/IntToEnumConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/IntToEnumConverter.cs @@ -1,3 +1,5 @@ +using System.Globalization; + namespace VpSharp.Internal.ValueConverters; #pragma warning disable CA1812 @@ -8,13 +10,13 @@ internal sealed class IntToEnumConverter : ValueConverter /// public override void Deserialize(TextReader reader, out T result) { - int value = int.Parse(reader.ReadToEnd()); - result = (T)Convert.ChangeType(value, typeof(T)); + int value = int.Parse(reader.ReadToEnd(), provider: CultureInfo.InvariantCulture); + result = (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture); } /// public override void Serialize(TextWriter writer, T value) { - writer.Write(Convert.ToInt32(value)); + writer.Write(Convert.ToInt32(value, CultureInfo.InvariantCulture)); } } diff --git a/VpSharp/src/Internal/ValueConverters/WorldSettingsConverter.cs b/VpSharp/src/Internal/ValueConverters/WorldSettingsConverter.cs index f05af81..f0eff3e 100644 --- a/VpSharp/src/Internal/ValueConverters/WorldSettingsConverter.cs +++ b/VpSharp/src/Internal/ValueConverters/WorldSettingsConverter.cs @@ -128,7 +128,7 @@ internal static class WorldSettingsConverter } else if (propertyType.IsEnum && int.TryParse(value, out int result)) { - propertyValue = Convert.ChangeType(result, propertyType); + propertyValue = Convert.ChangeType(result, propertyType, CultureInfo.InvariantCulture); } }