Repository navigation
Handle zero C2S meter in UGC export - #7
dudehacker wants to merge 1 commit into
Conversation
审查者指南导出器现在可以通过在节拍图构建期间发出警告并忽略无效的零值拍号,避免因时序相关问题导致的崩溃;必要时会回退到有效的默认拍号,并增加回归测试以确认后续音符的时序仍然正确。 具备容错能力的 UGC 节拍图导出时序图sequenceDiagram
participant Serialize
participant FillUgcBeats
participant Alerts
participant BeatMap
participant Notes
Serialize->>FillUgcBeats: FillUgcBeats(metList)
loop each meter
alt Numerator <= 0 or Denominator <= 0
FillUgcBeats->>Alerts: Add(Alert.Warning)
FillUgcBeats-->>FillUgcBeats: Ignore invalid meter
else Valid meter
FillUgcBeats->>BeatMap: Add valid beat entry
end
end
opt No valid beat entries
FillUgcBeats->>BeatMap: Add default 4/4 entry
end
FillUgcBeats-->>Serialize: Return beat map
Serialize->>Notes: Serialize note timing using beat map
文件级变更
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's GuideThe exporter now avoids timing-related crashes from invalid zero-valued meters by warning and ignoring them during beat-map construction, falls back to a valid default meter when necessary, and adds regression coverage confirming later note timing remains correct. Sequence diagram for resilient UGC beat-map exportsequenceDiagram
participant Serialize
participant FillUgcBeats
participant Alerts
participant BeatMap
participant Notes
Serialize->>FillUgcBeats: FillUgcBeats(metList)
loop each meter
alt Numerator <= 0 or Denominator <= 0
FillUgcBeats->>Alerts: Add(Alert.Warning)
FillUgcBeats-->>FillUgcBeats: Ignore invalid meter
else Valid meter
FillUgcBeats->>BeatMap: Add valid beat entry
end
end
opt No valid beat entries
FillUgcBeats->>BeatMap: Add default 4/4 entry
end
FillUgcBeats-->>Serialize: Return beat map
Serialize->>Notes: Serialize note timing using beat map
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="generator/chu/UgcGenerator.cs">
<violation number="1" location="generator/chu/UgcGenerator.cs:97">
P3: 新增的告警文案是硬编码中文,没有走 Locale 资源。README「多语言 (i18n)」一节要求新增/修改 key 必须维护 zh、zh-Hant、en 三种一级语言,同文件 `AirColor` 中的告警也使用了 `Locale.C2SUnsupportedAirColor`(i18n/Locale.resx、Locale.zh.resx、Locale.zh-Hant.resx 等均有对应 key)。建议改为 `Locale` 资源 key 并补三种语言的翻译。</violation>
<violation number="2" location="generator/chu/UgcGenerator.cs:123">
P3: 新增的「全部拍号无效/为空时兜底补 (0,4,4)」分支没有任何测试覆盖。现有测试 `UgcGenerator_IgnoresZeroNumeratorMeterAndKeepsMappingLaterNotes` 的 metList 是 [4/4@0, 1/4@1, 0/4@3],0/4 出现在中间,跳过它之后 `_ugcBeats` 仍有 2 项,不会走到这个 count==0 的分支。本 PR 修复的核心崩溃场景(C2S 起始小节就是 0/4 拍号、或整张谱没有有效 MET)正是靠这一行兜底,建议补一个 metList 为空或全部为无效拍号的用例,断言不崩溃且输出仅含 `@BEAT 0 4 4`。</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| { | ||
| if (met.Numerator <= 0 || met.Denominator <= 0) | ||
| { | ||
| alerts.Add(new Alert(Alert.LEVEL.Warning, |
There was a problem hiding this comment.
P3: 新增的告警文案是硬编码中文,没有走 Locale 资源。README「多语言 (i18n)」一节要求新增/修改 key 必须维护 zh、zh-Hant、en 三种一级语言,同文件 AirColor 中的告警也使用了 Locale.C2SUnsupportedAirColor(i18n/Locale.resx、Locale.zh.resx、Locale.zh-Hant.resx 等均有对应 key)。建议改为 Locale 资源 key 并补三种语言的翻译。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At generator/chu/UgcGenerator.cs, line 97:
<comment>新增的告警文案是硬编码中文,没有走 Locale 资源。README「多语言 (i18n)」一节要求新增/修改 key 必须维护 zh、zh-Hant、en 三种一级语言,同文件 `AirColor` 中的告警也使用了 `Locale.C2SUnsupportedAirColor`(i18n/Locale.resx、Locale.zh.resx、Locale.zh-Hant.resx 等均有对应 key)。建议改为 `Locale` 资源 key 并补三种语言的翻译。</comment>
<file context>
@@ -86,12 +86,19 @@ void Dfs(ChuNote n)
{
+ if (met.Numerator <= 0 || met.Denominator <= 0)
+ {
+ alerts.Add(new Alert(Alert.LEVEL.Warning,
+ $"UGC Generator忽略无效拍号: {met.Numerator}/{met.Denominator}", met.Time));
+ continue;
</file context>
| _ugcBeats.Add((ugcBar, met.Numerator, met.Denominator)); | ||
| } | ||
|
|
||
| if (_ugcBeats.Count == 0) _ugcBeats.Add((0, 4, 4)); |
There was a problem hiding this comment.
P3: 新增的「全部拍号无效/为空时兜底补 (0,4,4)」分支没有任何测试覆盖。现有测试 UgcGenerator_IgnoresZeroNumeratorMeterAndKeepsMappingLaterNotes 的 metList 是 [4/4@0, 1/4@1, 0/4@3],0/4 出现在中间,跳过它之后 _ugcBeats 仍有 2 项,不会走到这个 count==0 的分支。本 PR 修复的核心崩溃场景(C2S 起始小节就是 0/4 拍号、或整张谱没有有效 MET)正是靠这一行兜底,建议补一个 metList 为空或全部为无效拍号的用例,断言不崩溃且输出仅含 @BEAT 0 4 4。
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At generator/chu/UgcGenerator.cs, line 123:
<comment>新增的「全部拍号无效/为空时兜底补 (0,4,4)」分支没有任何测试覆盖。现有测试 `UgcGenerator_IgnoresZeroNumeratorMeterAndKeepsMappingLaterNotes` 的 metList 是 [4/4@0, 1/4@1, 0/4@3],0/4 出现在中间,跳过它之后 `_ugcBeats` 仍有 2 项,不会走到这个 count==0 的分支。本 PR 修复的核心崩溃场景(C2S 起始小节就是 0/4 拍号、或整张谱没有有效 MET)正是靠这一行兜底,建议补一个 metList 为空或全部为无效拍号的用例,断言不崩溃且输出仅含 `@BEAT 0 4 4`。</comment>
<file context>
@@ -112,13 +119,15 @@ private void FillUgcBeats(List<MET> metList)
_ugcBeats.Add((ugcBar, met.Numerator, met.Denominator));
}
+
+ if (_ugcBeats.Count == 0) _ugcBeats.Add((0, 4, 4));
}
</file context>
fix crashes due to timing issue
example chart:
2503_03.zip
Sourcery 总结
使 UGC 导出能够稳健处理无效拍号,同时保留有效的节拍和音符时序。
错误修复:
增强功能:
测试:
Original summary in English
Summary by Sourcery
Make UGC export robust against invalid time signatures while preserving valid beat and note timing.
Bug Fixes:
Enhancements:
Tests: