Skip to content

fix:OneKeyEntryEnd的两个bug#127

Merged
clansty merged 1 commit intoMuNET-OSS:mainfrom
Starrah:fix-165-Guest-OneKeyEnd
Apr 28, 2026
Merged

fix:OneKeyEntryEnd的两个bug#127
clansty merged 1 commit intoMuNET-OSS:mainfrom
Starrah:fix-165-Guest-OneKeyEnd

Conversation

@Starrah
Copy link
Copy Markdown
Contributor

@Starrah Starrah commented Apr 27, 2026

  1. 在1.65以上,如果开游客模式、一首歌不打直接结束PC,游戏会直接崩溃。由1.65新增的NetDataManager.GetGuestLogId函数引起。
    • NetDataManager.GetGuestLogId(1.65新增的函数)中会调用Singleton<GamePlayManager>.Instance.GetGameScore,由于一首歌都没打,GetGameScore函数查不到对应的GameScoreList对象,就会返回null
    • 接下来GetGuestLogId会直接使用GetGameScore所返回的结果,于是就NPE了
    • 解决方法:通过HarmonyFinalizer捕获这里的异常,返回数字0(这正是1.60之前的行为)
  2. DoQuickSkip调用AddProcess、尝试结束PC后,没有立即跳出循环,造成迭代器继续遍历时抛异常。
    • 是一个轻微bug,不影响任何功能,只是会在控制台打印出一行Error不好看:System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

由 Sourcery 提供的总结

修复在特定条件下跳过或结束播放时发生的 OneKeyEntryEnd 崩溃和错误。

错误修复:

  • 通过在出错时将 guest 日志 ID 默认设为 0,防止在未播放任何歌曲就结束 guest 会话时,NetDataManager.GetGuestLogId 发生崩溃。
  • 在调度结束流程的转换后立刻退出流程迭代循环,防止 DoQuickSkip 抛出集合在枚举期间被修改的异常。
Original summary in English

Summary by Sourcery

Fix OneKeyEntryEnd crashes and errors when skipping or ending play under specific conditions.

Bug Fixes:

  • Prevent NetDataManager.GetGuestLogId from crashing when ending a guest session without having played any songs by defaulting the guest log ID to 0 on error.
  • Stop DoQuickSkip from throwing a collection-modified enumeration exception by exiting the process iteration loop immediately after scheduling the end-process transition.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 27, 2026

审阅者指南(在小型 PR 上默认折叠)

审阅者指南

此 PR 修复了 OneKeyEntryEnd UX 模组中的两个 Bug:
一个是在快速跳过时修改集合引发的异常,另一个是在游客模式中由于空引用导致的崩溃。
修复方式是为 NetDataManager.GetGuestLogId 增加循环跳出逻辑和 Harmony finalizer,以恢复 1.65 之前的行为。

游客模式下修补后的 NetDataManager.GetGuestLogId 序列图

sequenceDiagram
  actor Player
  participant GameClient
  participant NetDataManager
  participant GamePlayManager
  participant GameScoreList
  participant HarmonyFinalizer_GetGuestLogIdFix

  Player ->> GameClient: EndPlayCardInGuestMode
  GameClient ->> NetDataManager: GetGuestLogId()
  NetDataManager ->> GamePlayManager: GetGameScore(playId)
  GamePlayManager -->> NetDataManager: null
  NetDataManager ->> GameScoreList: AccessGameScoreList
  GameScoreList -->> NetDataManager: NullReferenceException
  NetDataManager -->> HarmonyFinalizer_GetGuestLogIdFix: __exception, __result
  HarmonyFinalizer_GetGuestLogIdFix ->> HarmonyFinalizer_GetGuestLogIdFix: Check __exception
  HarmonyFinalizer_GetGuestLogIdFix ->> HarmonyFinalizer_GetGuestLogIdFix: Set __result = 0
  HarmonyFinalizer_GetGuestLogIdFix -->> NetDataManager: return null (swallow exception)
  NetDataManager -->> GameClient: guestLogId = 0
  GameClient -->> Player: Guest session ends without crash
Loading

OneKeyEntryEnd 修复及相关游戏类的类图

classDiagram
  class OneKeyEntryEnd {
    +static void DoQuickSkip()
    +static Exception GetGuestLogIdFix(Exception __exception, ulong __result)
  }

  class NetDataManager {
    +ulong GetGuestLogId()
  }

  class GamePlayManager {
    +static GamePlayManager Instance
    +object GetGameScore(int playId)
  }

  class ProcessManager {
    +void AddProcess(Process process)
  }

  class Process {
    +void Execute()
  }

  class FadeProcess {
    +FadeProcess(ProcessDataContainer container, Process nextProcess, Process afterFadeProcess)
  }

  class UnlockMusicProcess {
    +UnlockMusicProcess(ProcessDataContainer container)
  }

  class MusicSelectProcess {
    +MusicSelectProcess(ProcessDataContainer container)
  }

  class ProcessDataContainer {
  }

  class SharedInstances {
    +static ProcessDataContainer ProcessDataContainer
  }

  %% Relationships for DoQuickSkip behavior
  OneKeyEntryEnd --> ProcessManager : uses
  ProcessManager --> Process : manages
  FadeProcess ..|> Process
  UnlockMusicProcess ..|> Process
  MusicSelectProcess ..|> Process
  OneKeyEntryEnd --> FadeProcess : creates
  OneKeyEntryEnd --> UnlockMusicProcess : creates
  OneKeyEntryEnd --> MusicSelectProcess : creates
  OneKeyEntryEnd --> SharedInstances : uses
  SharedInstances --> ProcessDataContainer

  %% Relationships for GetGuestLogId fix
  OneKeyEntryEnd ..> NetDataManager : HarmonyPatch GetGuestLogId
  NetDataManager --> GamePlayManager : calls
  GamePlayManager --> Process : returns score-like object
Loading

更新后的 DoQuickSkip 循环与集合修改修复的流程图

flowchart TD
  A_Start[Start DoQuickSkip] --> B_Iterate[Foreach process in processList]
  B_Iterate --> C_CheckType{Is target process to end PC?}
  C_CheckType -->|No| D_Next[Move to next process]
  D_Next --> B_Iterate
  C_CheckType -->|Yes| E_AddFadeProcess[Add FadeProcess to processManager]
  E_AddFadeProcess --> F_AddUnlockMusicProcess[Add UnlockMusicProcess to processManager]
  F_AddUnlockMusicProcess --> G_GotoOutLoop[Goto outLoop to exit foreach]
  G_GotoOutLoop --> H_outLoop[outLoop label]
  H_outLoop --> I_HasProcessToRelease{processToRelease != null?}
  I_HasProcessToRelease -->|Yes| J_AddMusicSelectProcess[Add MusicSelectProcess to processManager]
  I_HasProcessToRelease -->|No| K_End[End DoQuickSkip]
  J_AddMusicSelectProcess --> K_End
Loading

文件级变更

变更 细节 文件
通过在添加淡出/解锁进程后立即退出循环,防止在快速跳过时出现“迭代期间集合被修改”的异常。
  • 将循环中的 break 替换为 goto,跳转到 foreach 之后带标签的部分,从而在 AddProcess 修改进程列表后避免继续迭代。
  • foreach 循环之后新增一个标签(outLoop:),作为提前退出循环时的跳转目标。
AquaMai.Mods/UX/OneKeyEntryEnd.cs
通过使用 Harmony finalizer 包装 NetDataManager.GetGuestLogId 并将错误规范化为安全的默认结果,避免在游客模式下未游玩任何歌曲就结束时发生崩溃。
  • NetDataManager.GetGuestLogId 上新增 Harmony finalizer 补丁,并通过 EnableGameVersionHarmonyPatch 特性限定为仅在游戏版本 26500+ 时启用。
  • 在 finalizer 中,如果发生异常,则将游客日志 ID 结果设为 0(与 1.60 之前行为一致),并通过返回 null 吞掉该异常。
AquaMai.Mods/UX/OneKeyEntryEnd.cs

技巧与命令

与 Sourcery 交互

  • 触发新的审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 在回复某条审查评论时让 Sourcery 创建 issue。你也可以直接回复该评论 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题任意位置写上 @sourcery-ai,即可在任意时间生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文任意位置写上 @sourcery-ai summary,即可在你期望的位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成审阅者指南: 在 Pull Request 中评论 @sourcery-ai guide,可在任意时间(重新)生成审阅者指南。
  • 一键解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 审查。若你想从一次全新的审查开始,这尤其有用——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

前往你的 控制面板 可以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 Pull Request 摘要、审阅者指南等。
  • 修改审查语言。
  • 添加、删除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes two bugs in the OneKeyEntryEnd UX mod: a collection-modification exception when quickly skipping, and a null-reference crash in guest mode by adding a loop-escape and a Harmony finalizer around NetDataManager.GetGuestLogId to restore pre‑1.65 behavior.

Sequence diagram for patched NetDataManager.GetGuestLogId in guest mode

sequenceDiagram
  actor Player
  participant GameClient
  participant NetDataManager
  participant GamePlayManager
  participant GameScoreList
  participant HarmonyFinalizer_GetGuestLogIdFix

  Player ->> GameClient: EndPlayCardInGuestMode
  GameClient ->> NetDataManager: GetGuestLogId()
  NetDataManager ->> GamePlayManager: GetGameScore(playId)
  GamePlayManager -->> NetDataManager: null
  NetDataManager ->> GameScoreList: AccessGameScoreList
  GameScoreList -->> NetDataManager: NullReferenceException
  NetDataManager -->> HarmonyFinalizer_GetGuestLogIdFix: __exception, __result
  HarmonyFinalizer_GetGuestLogIdFix ->> HarmonyFinalizer_GetGuestLogIdFix: Check __exception
  HarmonyFinalizer_GetGuestLogIdFix ->> HarmonyFinalizer_GetGuestLogIdFix: Set __result = 0
  HarmonyFinalizer_GetGuestLogIdFix -->> NetDataManager: return null (swallow exception)
  NetDataManager -->> GameClient: guestLogId = 0
  GameClient -->> Player: Guest session ends without crash
Loading

Class diagram for OneKeyEntryEnd fixes and related game classes

classDiagram
  class OneKeyEntryEnd {
    +static void DoQuickSkip()
    +static Exception GetGuestLogIdFix(Exception __exception, ulong __result)
  }

  class NetDataManager {
    +ulong GetGuestLogId()
  }

  class GamePlayManager {
    +static GamePlayManager Instance
    +object GetGameScore(int playId)
  }

  class ProcessManager {
    +void AddProcess(Process process)
  }

  class Process {
    +void Execute()
  }

  class FadeProcess {
    +FadeProcess(ProcessDataContainer container, Process nextProcess, Process afterFadeProcess)
  }

  class UnlockMusicProcess {
    +UnlockMusicProcess(ProcessDataContainer container)
  }

  class MusicSelectProcess {
    +MusicSelectProcess(ProcessDataContainer container)
  }

  class ProcessDataContainer {
  }

  class SharedInstances {
    +static ProcessDataContainer ProcessDataContainer
  }

  %% Relationships for DoQuickSkip behavior
  OneKeyEntryEnd --> ProcessManager : uses
  ProcessManager --> Process : manages
  FadeProcess ..|> Process
  UnlockMusicProcess ..|> Process
  MusicSelectProcess ..|> Process
  OneKeyEntryEnd --> FadeProcess : creates
  OneKeyEntryEnd --> UnlockMusicProcess : creates
  OneKeyEntryEnd --> MusicSelectProcess : creates
  OneKeyEntryEnd --> SharedInstances : uses
  SharedInstances --> ProcessDataContainer

  %% Relationships for GetGuestLogId fix
  OneKeyEntryEnd ..> NetDataManager : HarmonyPatch GetGuestLogId
  NetDataManager --> GamePlayManager : calls
  GamePlayManager --> Process : returns score-like object
Loading

Flow diagram for updated DoQuickSkip loop and collection modification fix

flowchart TD
  A_Start[Start DoQuickSkip] --> B_Iterate[Foreach process in processList]
  B_Iterate --> C_CheckType{Is target process to end PC?}
  C_CheckType -->|No| D_Next[Move to next process]
  D_Next --> B_Iterate
  C_CheckType -->|Yes| E_AddFadeProcess[Add FadeProcess to processManager]
  E_AddFadeProcess --> F_AddUnlockMusicProcess[Add UnlockMusicProcess to processManager]
  F_AddUnlockMusicProcess --> G_GotoOutLoop[Goto outLoop to exit foreach]
  G_GotoOutLoop --> H_outLoop[outLoop label]
  H_outLoop --> I_HasProcessToRelease{processToRelease != null?}
  I_HasProcessToRelease -->|Yes| J_AddMusicSelectProcess[Add MusicSelectProcess to processManager]
  I_HasProcessToRelease -->|No| K_End[End DoQuickSkip]
  J_AddMusicSelectProcess --> K_End
Loading

File-Level Changes

Change Details Files
Prevent collection-modified-while-iterating exception during quick skip by exiting the loop immediately after adding the fade/unlock process.
  • Replace the loop break with a goto jumping to a labeled section after the foreach to avoid further iteration after AddProcess mutates the process list.
  • Add a label after the foreach loop (outLoop:) as the jump target for exiting the loop early.
AquaMai.Mods/UX/OneKeyEntryEnd.cs
Avoid crash in guest mode when ending without playing any songs by wrapping NetDataManager.GetGuestLogId with a Harmony finalizer that normalizes errors to a safe default result.
  • Introduce a Harmony finalizer patch on NetDataManager.GetGuestLogId scoped to game version 26500+ via EnableGameVersion and HarmonyPatch attributes.
  • In the finalizer, if an exception occurred, set the guest log id result to 0 (pre‑1.60 behavior) and swallow the exception by returning null.
AquaMai.Mods/UX/OneKeyEntryEnd.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并给出了一些整体反馈:

  • 建议避免使用 goto outLoop。可以考虑把这段逻辑提取到一个辅助方法中,或者使用标志位/break 之类的结构,使控制流更容易理解和维护。
  • 目前 Harmony 的 finalizer 会吞掉 GetGuestLogId 的所有异常;如果可行的话,建议将其收窄到你预期的特定异常类型(例如 NRE),以避免掩盖无关的问题。
  • GetGuestLogIdFix 中,你可能只想在 __exception 是预期类型时才显式设置 __result,在其他情况下保持不变,以便在意料之外的错误场景下更好地保留原有行为。
给 AI 代理的提示
请根据这次代码评审中的评论进行修改:

## 总体评论
- 建议避免使用 `goto outLoop`。可以考虑把这段逻辑提取到一个辅助方法中,或者使用标志位/`break` 之类的结构,使控制流更容易理解和维护。
- 目前 Harmony 的 finalizer 会吞掉 `GetGuestLogId` 的所有异常;如果可行的话,建议将其收窄到你预期的特定异常类型(例如 NRE),以避免掩盖无关的问题。
-`GetGuestLogIdFix` 中,你可能只想在 `__exception` 是预期类型时才显式设置 `__result`,在其他情况下保持不变,以便在意料之外的错误场景下更好地保留原有行为。

## 单独评论

### 评论 1
<location path="AquaMai.Mods/UX/OneKeyEntryEnd.cs" line_range="105-110" />
<code_context>
+    [EnableGameVersion(26500, noWarn: true)]
+    [HarmonyPatch(typeof(NetDataManager), "GetGuestLogId")]
+    [HarmonyFinalizer]
+    public static Exception GetGuestLogIdFix(Exception __exception, ref ulong __result)
+    {
+        // 如果在游客模式下,一首歌都没打就跳关了:
+        // NetDataManager.GetGuestLogId中会调用Singleton<GamePlayManager>.Instance.GetGameScore,这个函数查不到对应的GameScoreList对象,就会返回null;于是就NPE了
+        // 我们则捕获这里的异常,返回数字0(这正是1.60之前的行为)
+        if (__exception != null) __result = 0L;
+        return null; 
+    } 
</code_context>
<issue_to_address>
**issue (bug_risk):** 请收窄异常处理范围,以免无关的失败被静默吞掉。

注释表明,这个 finalizer 主要是为了处理 `GetGameScore` 返回 null 时导致的 `NullReferenceException`。但按当前实现,它会把任何异常(包括无关的网络或逻辑错误)都转换为结果 `0`,这样会掩盖真实问题。

请将特殊处理限制在预期场景,例如:

```csharp
if (__exception is NullReferenceException)
{
    __result = 0UL; // matches pre‑1.60 behavior
    return null;    // swallow only this known issue
}

return __exception; // let other exceptions propagate
```

这样既能保持兼容性行为,又能避免屏蔽无关的异常。
</issue_to_address>

Sourcery 对开源项目免费——如果你喜欢我们的评审,请考虑分享给更多人 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据反馈改进后续评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • Consider avoiding the goto outLoop by extracting the logic into a helper method or using a flag/break structure so the control flow is easier to follow and maintain.
  • The Harmony finalizer currently swallows all exceptions for GetGuestLogId; if feasible, narrow this to the specific exception type(s) you expect (e.g., NRE) to avoid hiding unrelated issues.
  • In GetGuestLogIdFix, you may want to explicitly set __result only when __exception is of the expected type and leave it untouched otherwise, to better preserve the original behavior in unexpected error cases.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider avoiding the `goto outLoop` by extracting the logic into a helper method or using a flag/`break` structure so the control flow is easier to follow and maintain.
- The Harmony finalizer currently swallows all exceptions for `GetGuestLogId`; if feasible, narrow this to the specific exception type(s) you expect (e.g., NRE) to avoid hiding unrelated issues.
- In `GetGuestLogIdFix`, you may want to explicitly set `__result` only when `__exception` is of the expected type and leave it untouched otherwise, to better preserve the original behavior in unexpected error cases.

## Individual Comments

### Comment 1
<location path="AquaMai.Mods/UX/OneKeyEntryEnd.cs" line_range="105-110" />
<code_context>
+    [EnableGameVersion(26500, noWarn: true)]
+    [HarmonyPatch(typeof(NetDataManager), "GetGuestLogId")]
+    [HarmonyFinalizer]
+    public static Exception GetGuestLogIdFix(Exception __exception, ref ulong __result)
+    {
+        // 如果在游客模式下,一首歌都没打就跳关了:
+        // NetDataManager.GetGuestLogId中会调用Singleton<GamePlayManager>.Instance.GetGameScore,这个函数查不到对应的GameScoreList对象,就会返回null;于是就NPE了
+        // 我们则捕获这里的异常,返回数字0(这正是1.60之前的行为)
+        if (__exception != null) __result = 0L;
+        return null; 
+    } 
</code_context>
<issue_to_address>
**issue (bug_risk):** Narrow the exception handling so unrelated failures are not silently swallowed.

The comment suggests this finalizer is meant to handle a `NullReferenceException` from `GetGameScore` returning null. As implemented, it converts any exception (including unrelated network or logic failures) into a result of `0`, which can hide real issues.

Limit the special handling to the expected case, for example:

```csharp
if (__exception is NullReferenceException)
{
    __result = 0UL; // matches pre‑1.60 behavior
    return null;    // swallow only this known issue
}

return __exception; // let other exceptions propagate
```

This keeps the compatibility behavior while avoiding masking unrelated exceptions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread AquaMai.Mods/UX/OneKeyEntryEnd.cs
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies OneKeyEntryEnd.cs to prevent a System.InvalidOperationException by exiting a loop early after modifying the process list, and introduces a Harmony finalizer to handle potential null pointer exceptions in NetDataManager.GetGuestLogId during guest mode. The review feedback suggests replacing the goto statement with a return to simplify the control flow and remove the unnecessary label.

Comment thread AquaMai.Mods/UX/OneKeyEntryEnd.cs Outdated
Comment thread AquaMai.Mods/UX/OneKeyEntryEnd.cs Outdated
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="AquaMai.Mods/UX/OneKeyEntryEnd.cs">

<violation number="1" location="AquaMai.Mods/UX/OneKeyEntryEnd.cs:110">
P2: The finalizer unconditionally suppresses all exceptions from `GetGuestLogId`; only the expected null-reference case should be swallowed.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread AquaMai.Mods/UX/OneKeyEntryEnd.cs
1. 在1.65以上,如果开游客模式、一首歌不打直接结束PC,游戏会直接崩溃。由1.65新增的NetDataManager.GetGuestLogId函数引起,具体原因详见代码中的注释。
2. (轻微bug,不影响任何功能,只是会在控制台打印出一行Error不好看) `DoQuickSkip`调用AddProcess、尝试结束PC后,没有立即跳出循环,造成迭代器继续遍历时抛异常。
@Starrah Starrah force-pushed the fix-165-Guest-OneKeyEnd branch from 7d406e2 to 214c13d Compare April 27, 2026 05:10
@Starrah
Copy link
Copy Markdown
Contributor Author

Starrah commented Apr 27, 2026

上面两个AI讲的问题都是一件事:觉得我Finalizer里屏蔽一切异常太过分,最好只抓NPE。但我是怎么想的呢:

  1. GetGuestLogId本质是非关键函数。我猜1.65引入它,可能是为了辅助服务端统计全国成绩百分比使用的。它对用户不会有任何影响,对服务器放在统计学意义下也没有什么影响,而且仅在游客模式下会被调用
  2. 更重要的是,作为一个getter性质的计算函数,不管GetGuestLogId因为何种原因抛异常、抛的是何种类型的异常,这个异常都一定会向上滚、都一定会产生“崩端”的严重后果;并不是抛的不是NPE就不崩端了。那么即使抛的是其他类型的非预期的异常,我们是希望游戏为这么一个非关键的函数而直接崩端呢?还是算了,不管什么异常都返回0,别管这些了?我个人倾向于后者。当然如果其他的reviewer有不同的观点的话,我也欢迎讨论&虚心听取意见。

综上,我认为就这样挺好的,无需改成只捕获NPE。

@clansty clansty merged commit c876b0e into MuNET-OSS:main Apr 28, 2026
2 checks passed
@clansty
Copy link
Copy Markdown
Member

clansty commented Apr 28, 2026

上面两个AI讲的问题都是一件事:觉得我Finalizer里屏蔽一切异常太过分,最好只抓NPE。

毕竟 AI 训练数据里面大多都是通用的应用程序,而对于像这样的 Mod 开发,本来就有很多操作是非寻常的,比如说需要使用歪门邪道的。这些 AI 对于这样的操作可能是很难很好的理解的

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