Skip to content

Commit d73adf0

Browse files
committed
fix: float.Parse应该使用CultureInfo.InvariantCulture
1 parent 1c1957d commit d73adf0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

MaiChartManager/Services/MaidataImportService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.RegularExpressions;
1+
using System.Globalization;
2+
using System.Text.RegularExpressions;
23
using MaiChartManager.Models;
34
using MaiChartManager.Utils;
45
using MaiLib;
@@ -56,7 +57,7 @@ private static string Add1Bar(string maidata, float bpm)
5657
{
5758
var regex = BpmTagRegex();
5859
var bpmStr = regex.Match(maidata).Value;
59-
if (Math.Abs(float.Parse(bpmStr[1..^1]) - bpm) < 0.001f) // 本质是比较maidata中声明的(bpm)和我们参数传进来的bpm是否不等。以防浮点运算误差使用了range比较。
60+
if (Math.Abs(float.Parse(bpmStr[1..^1], CultureInfo.InvariantCulture) - bpm) < 0.001f) // 本质是比较maidata中声明的(bpm)和我们参数传进来的bpm是否不等。以防浮点运算误差使用了range比较。
6061
{
6162
// 如果相等的话,则把新的小节插在bpmStr后面即可
6263
// 这里使用 {4},,,, 而不是 {1}, 因为要是谱面一开始根本没有写 {x} 的话,默认是 {4}。要是用了 {1}, 会覆盖默认的 {4}

0 commit comments

Comments
 (0)