Skip to content

Handle zero C2S meter in UGC export - #7

Merged
Starrah merged 3 commits into
MuNET-OSS:masterfrom
dudehacker:fix/c2s-zero-meter-timing
Oct 8, 2026
Merged

Starrah merged 3 commits into
MuNET-OSS:masterfrom
dudehacker:fix/c2s-zero-meter-timing

Conversation

@dudehacker

@dudehacker dudehacker commented Oct 7, 2026 •

Copy link
Copy Markdown

fix crashes due to timing issue

example chart:
2503_03.zip

Review in cubic

Sourcery 总结

使 UGC 导出能够稳健处理无效拍号,同时保留有效的节拍和音符时序。

错误修复:

  • 防止当谱面包含分子为零或其他无效拍号值时,UGC 导出崩溃以及时序映射错误。

增强功能:

  • 忽略无效拍号,并在没有剩余有效拍号时提供默认节拍映射,从而保留后续音符的时序。

测试:

  • 增加对分子为零和分母为零拍号的覆盖测试,包括警报生成和后续音符时序。
Original summary in English

Sourcery 摘要

在无效节拍定义的情况下增强 UGC 导出的稳定性,同时保留音符的时序。

错误修复:

  • 防止因无效节拍(包括分子或分母为零)导致的 UGC 导出崩溃和时序映射错误。

改进:

  • 当不存在有效的节拍条目时提供默认节拍映射,从而保留后续音符的时序。

测试:

  • 增加对无效节拍、生成的警报、节拍输出以及后续音符时序的测试覆盖。
Original summary in English

Sourcery 总结

使 UGC 导出能够稳健处理无效的节拍定义,同时保留音符的时间信息。

错误修复:

  • 防止当谱面包含无效节拍(包括分子或分母为零)时,UGC 导出崩溃以及时间映射错误。

增强功能:

  • 忽略不支持的节拍值,并在没有可用节拍时提供默认节拍映射,从而保留后续音符的时间信息。

测试:

  • 增加对无效节拍、生成的警告、节拍输出以及后续音符时间信息的覆盖。
Original summary in English

Sourcery 总结

增强 UGC 导出功能,使其能够稳健处理无效的拍号定义,同时保留音符的时间安排。

错误修复:

  • 当谱面包含无效拍号(包括分子或分母为零)时,防止 UGC 导出崩溃和时间映射错误。

改进:

  • 忽略不支持的拍号值,并在没有有效拍号可用时提供默认节拍映射,以保留后续音符的时间安排。

测试:

  • 增加对无效拍号、生成的警报、节拍输出以及后续音符时间安排的测试覆盖。
Original summary in English

Summary by Sourcery

Make UGC export robust against invalid meter definitions while preserving note timing.

Bug Fixes:

  • Prevent UGC export crashes and timing-mapping errors when charts contain invalid meters, including zero numerators or denominators.

Enhancements:

  • Preserve subsequent note timing by ignoring unsupported meter values and providing a default beat mapping when no valid meters are available.

Tests:

  • Add coverage for invalid meters, generated alerts, beat output, and subsequent note timing.

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

审查者指南

导出器现在可以通过在节拍图构建期间发出警告并忽略无效的零值拍号,避免因时序相关问题导致的崩溃;必要时会回退到有效的默认拍号,并增加回归测试以确认后续音符的时序仍然正确。

具备容错能力的 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
Loading

文件级变更

变更 详细信息 文件
使 UGC 节拍图生成能够适应无效拍号,包括值为零的 C2S 分子。
  • 跳过分子或分母为非正数的拍号,并在该拍号对应的时间点发出警告提醒。
  • 当不再存在有效拍号时,提供一个默认的 4/4 节拍条目,同时保留后续有效拍号的映射。
generator/chu/UgcGenerator.cs
增加针对无效拍号导出和音符时序保留的回归测试。
  • 构建一个在有效拍号前后都包含分子为零的拍号的谱面。
  • 验证仅产生一条警告、忽略无效节拍输出、保留有效节拍映射,并且后续音符会以预期的 UGC 位置进行序列化。
tests/chu/UgcTimeTests.cs

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以回复审查评论并使用 @sourcery-ai issue,从该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此命令会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,以忽略所有现有的 Sourcery 审查。如果你想通过新的审查重新开始,这个命令尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

The 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 export

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
Loading

File-Level Changes

Change Details Files
Make UGC beat-map generation resilient to invalid meters, including zero C2S numerators.
  • Skip meters with non-positive numerators or denominators and emit a warning alert at the meter time.
  • Provide a default 4/4 beat entry when no valid meters remain, while preserving subsequent valid meter mappings.
generator/chu/UgcGenerator.cs
Add regression coverage for invalid-meter export and note timing preservation.
  • Build a chart containing zero numerator meters before and after a valid meter.
  • Verify one warning is produced, invalid beat output is omitted, the valid beat mapping remains, and a later note serializes at the expected UGC position.
tests/chu/UgcTimeTests.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Oct 7, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我已经审阅了你的更改,看起来很棒!

Sourcery 评估

已批准。


Sourcery 对开源项目免费——如果你喜欢我们的审阅结果,请考虑分享它们 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread generator/chu/UgcGenerator.cs Outdated
Comment thread generator/chu/UgcGenerator.cs
@Starrah
Starrah self-requested a review October 7, 2026 17:11
Comment thread generator/chu/UgcGenerator.cs Outdated
_ugcBeats = [];
foreach (var met in metList)
{
if (met.Numerator <= 0 || met.Denominator <= 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, your example 2503_03.zip is the first time that I know, MET line's numerator can be zero, so thank you very much. Since in the official game, MET controls the "beat line" interval, so I think by using MET x x 4 0, the official chart designer may want to implement that there is no "beat lines".
Thus, in my opinion, rather than directly ignore the MET line when met.Numerator <= 0, a better plan is forcing met.Numerator to be equal with met.Denominator. This behaves as turning MET x x 4 0 into MET x x 4 4, just recovering the dropped "beat lines" while keeping the denominator.
I may make the changes mentioned above by myself.

@Starrah Starrah Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implement the changes I proposed above in 457d827 .

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (changes from recent commits).

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:96">
P1: `Denominator` 为 0 时该分支不会修正或跳过拍号,随后 `T` 会用零分母构造 `Rational`,导致导出仍然抛异常。请在写入 `_ugcBeats` 前对 `Denominator <= 0` 发出警告并跳过该条目。</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

foreach (var origMet in metList)
{
var met = origMet;
if (met.Numerator <= 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Denominator 为 0 时该分支不会修正或跳过拍号,随后 T 会用零分母构造 Rational,导致导出仍然抛异常。请在写入 _ugcBeats 前对 Denominator <= 0 发出警告并跳过该条目。

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 96:

<comment>`Denominator` 为 0 时该分支不会修正或跳过拍号,随后 `T` 会用零分母构造 `Rational`,导致导出仍然抛异常。请在写入 `_ugcBeats` 前对 `Denominator <= 0` 发出警告并跳过该条目。</comment>

<file context>
@@ -90,13 +90,15 @@ void Dfs(ChuNote n)
         {
-            if (met.Numerator <= 0 || met.Denominator <= 0)
+            var met = origMet;
+            if (met.Numerator <= 0)
             {
-                alerts.Add(new Alert(Alert.LEVEL.Warning,
</file context>
Suggested change
if (met.Numerator <= 0)
if (met.Denominator <= 0)
{
alerts.Add(new Alert(Alert.LEVEL.Warning,
$"UGC Generator忽略无效拍号: {met.Numerator}/{met.Denominator}", met.Time));
continue;
}
if (met.Numerator <= 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前为止没见过Denominator为0的情况,我想也没有意义,所以如果真的遇到的话,我觉得报个错是合理的

Comment thread generator/chu/UgcGenerator.cs
@Starrah
Starrah force-pushed the fix/c2s-zero-meter-timing branch from f7f8fc3 to 457d827 Compare October 8, 2026 09:54
@sourcery-ai
sourcery-ai Bot dismissed their stale review October 8, 2026 09:55

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@Starrah
Starrah merged commit 520798c into MuNET-OSS:master Oct 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants