Skip to content

Commit

Permalink
Fix for globalization issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AshtonMemer committed Jan 20, 2024
1 parent 43395fd commit bd389ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Data/Bms.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Nodes;
using System.Globalization;
using System.Text.Json.Nodes;
using CustomAlbums.Utilities;
using Il2CppAssets.Scripts.GameCore.Managers;
using Il2CppAssets.Scripts.PeroTools.Commons;
Expand Down Expand Up @@ -304,7 +305,7 @@ public float Bpm
get
{
var bpmString = Info["BPM"]?.GetValue<string>() ?? Info["BPM01"]?.GetValue<string>() ?? string.Empty;
return !float.TryParse(bpmString, out var bpm) ? 0f : bpm;
return !float.TryParse(bpmString, NumberStyles.None, CultureInfo.InvariantCulture, out var bpm) ? 0f : bpm;
}
}

Expand Down
5 changes: 3 additions & 2 deletions Patches/AssetPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Nodes;
Expand Down Expand Up @@ -288,7 +289,7 @@ private static IntPtr LoadFromNamePatch(IntPtr instance, IntPtr assetNamePtr, In

Logger.Msg($"Loading {assetName}!");

if (assetName.StartsWith("ALBUM") && int.TryParse(assetName.AsSpan(5), out var albumNum) &&
if (assetName.StartsWith("ALBUM") && int.TryParse(assetName.AsSpan(5), NumberStyles.Number, CultureInfo.InvariantCulture, out var albumNum) &&
albumNum != AlbumManager.Uid + 1)
{
// If done loading albums, we've found the maximum actual album
Expand Down
7 changes: 4 additions & 3 deletions Utilities/Json.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using Il2CppNewtonsoft.Json;
Expand Down Expand Up @@ -53,12 +54,12 @@ public static T Il2CppJsonDeserialize<T>(string text)
/// <returns>The decimal value</returns>
public static decimal GetValueAsDecimal(this JsonNode node)
{
return decimal.TryParse(node.ToString(), out var result) ? result : 0M;
return decimal.TryParse(node.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out var result) ? result : 0M;
}

public static Decimal GetValueAsIl2CppDecimal(this JsonNode node)
{
return decimal.TryParse(node.ToString(), out var result)
return decimal.TryParse(node.ToString(), NumberStyles.Number, CultureInfo.InvariantCulture, out var result)
? (Decimal)(float)result
: Decimal.Zero;
}
Expand Down

0 comments on commit bd389ea

Please sign in to comment.