Skip to content

Commit f7f8fc3

Browse files
committed
fix: force met.Numerator to be equals with met.Denominator when met.Numerator <= 0
1 parent 8476cd8 commit f7f8fc3

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎generator/chu/UgcGenerator.cs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ void Dfs(ChuNote n)
9090
private void FillUgcBeats(List<MET> metList)
9191
{
9292
_ugcBeats = [];
93-
foreach (var met in metList)
93+
foreach (var origMet in metList)
9494
{
95-
if (met.Numerator <= 0 || met.Denominator <= 0)
95+
var met = origMet;
96+
if (met.Numerator <= 0)
9697
{
97-
alerts.Add(new Alert(Alert.LEVEL.Warning,
98-
$"UGC Generator忽略无效拍号: {met.Numerator}/{met.Denominator}", met.Time));
99-
continue;
98+
// See https://github.com/MuNET-OSS/MuConvert/pull/7#discussion_r4217218971 ,
99+
// in official game, met.Numerator == 0 means there should be no "beat lines", which cannot be easily implemented in Umiguri.
100+
// But this will cause DivideByZeroException in the `T` function, so we just force met.Numerator to be equals with met.Denominator.
101+
met = met with { Numerator = met.Denominator };
100102
}
101103

102104
if (_ugcBeats.Count == 0)

‎tests/chu/UgcTimeTests.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public void UgcGenerator_IgnoresZeroNumeratorMeterAndKeepsMappingLaterNotes()
118118

119119
var (ugc, alerts) = new UgcGenerator().Generate(chart);
120120

121-
Assert.Single(alerts);
122121
Assert.Contains("@BEAT\t1\t1\t4", ugc);
123122
Assert.DoesNotContain("@BEAT\t9\t0\t4", ugc);
124123
Assert.Contains("#9'0:t01", ugc);

0 commit comments

Comments
 (0)