## 说明
多作业模式进入 H10-1 关卡详情页后,OCR 可能会把关卡名识别为 `H1O-1`。现有替换规则没有将它还原为 `H10-1`,而是处理成了
`-1`,导致关卡校验失败并重新开始导航。
本 PR 将 `ClickStageName` 和 `ClickedCorrectStage` 中的 `$010` 改为
`${1}0`,明确区分捕获组 1 和后面的字符 `0`。
## 原因
原规则的本意是保留捕获组 1,再补一个 `0`:
```json
["(H\\d+)O(?=-)", "$010"],
["(-\\d+)O", "$010"]
```
OCR 后处理使用 `boost::regex_replace`。这里的 `$010` 会被解析为捕获组 10,而不是捕获组 1 后接
`0`。这两个正则都没有第 10 个捕获组,因此 `H1O-1` 最终被处理成 `-1`。
修改后的规则使用无歧义写法:
```json
["(H\\d+)O(?=-)", "${1}0"],
["(-\\d+)O", "${1}0"]
```
## 验证
- `resource/tasks/tasks.json` 可以正常解析。
- 四处相关替换均已改为 `${1}0`,`git diff --check` 通过。
- 使用 MAA `v6.14.1`、明日方舟 PC 端、2560 × 1440 分辨率测试 H10-1 多作业导航。
修复前:
```text
CharOcr: H1O-1
Proceed: -1
confirm stage name failed after retrying 3 times, stage name: H10-1
```
修复后,同样的 OCR 输入可以正确进入编队流程:
```text
[2026-07-12 14:12:08.499][TRC] CharOcr: H1O-1
[2026-07-12 14:12:08.499][TRC] Proceed: H10-1
[2026-07-12 14:12:09.545][INF] task: BattleStartPre, text: 开始行动
[2026-07-12 14:12:11.670][INF] SubTaskStart: BattleFormationTask
```
本次测试中没有再出现 `confirm stage name failed`。
<details>
<summary>English</summary>
## Summary
In multi-copilot mode, the stage name on the H10-1 detail panel may be
recognized as `H1O-1`. The existing replacement rules turn it into `-1`
instead of restoring `H10-1`, so stage confirmation fails and navigation
starts over.
This PR changes `$010` to `${1}0` in both `ClickStageName` and
`ClickedCorrectStage`, making the boundary between capture group 1 and
the literal `0` explicit.
## Root cause
The original rules were intended to preserve capture group 1 and append
a literal `0`:
```json
["(H\\d+)O(?=-)", "$010"],
["(-\\d+)O", "$010"]
```
OCR post-processing uses `boost::regex_replace`, where `$010` is parsed
as capture group 10 rather than capture group 1 followed by `0`. Since
these expressions do not contain a tenth capture group, `H1O-1` is
reduced to `-1`.
The replacement now uses the unambiguous `${1}0` form.
## Verification
- Parsed `resource/tasks/tasks.json` successfully.
- Confirmed all four affected replacements use `${1}0`; `git diff
--check` passes.
- Tested H10-1 multi-copilot navigation with MAA `v6.14.1` on the
Arknights PC client at 2560 × 1440.
- The same `H1O-1` OCR result was corrected to `H10-1`, after which MAA
clicked `BattleStartPre` and entered `BattleFormationTask`.
- No `confirm stage name failed` entry was produced during the post-fix
attempt.
</details>
Refs #16888
## Summary by Sourcery
通过基于模板的关卡导航来处理活动关卡与支线关卡,当没有可用模板时回退到 OCR。
新功能:
- 添加一个辅助工具,用标准化关卡代码解析活动关卡模板路径,并在资源存在时使用模板匹配进行关卡导航。
- 为多协助作战关卡选择和支线复刻关卡选择启用基于模板的导航,以提升关卡识别的稳定性。
改进:
- 在资源加载阶段,按完整相对路径索引所有模板图片文件,以便在 C++ 代码中动态查找关卡导航模板。
<details>
<summary>Original summary in English</summary>
## Summary by Sourcery
Introduce template-based stage navigation for event and side-story
stages, falling back to OCR when no template is available.
New Features:
- Add a helper to resolve event stage template paths from standardized
stage codes and use template matching for stage navigation when
resources exist.
- Enable template-based navigation for multi-copilot stage selection and
side-story reopen stage selection to improve stage recognition
reliability.
Enhancements:
- Index all template image files by full relative path during resource
loading to allow dynamic lookup of stage navigation templates from C++
code.
</details>
新功能:
- 为事件关卡引入基于模板的导航机制,通过从标准化路径解析每个关卡的截图模板,并在可用时优先使用模板而不是 OCR。
- 将基于模板的导航应用于多协助器(multi-copilot)关卡选择以及支线故事重开关卡选择,以在这些流程中提供更稳健的关卡识别支持。
增强:
- 在加载模板资源时按相对路径索引所有模板图片文件,以便可以从 C++ 代码中动态查找关卡导航模板。
<details>
<summary>Original summary in English</summary>
## Summary by Sourcery
通过基于模板的关卡导航来处理活动关卡与支线关卡,当没有可用模板时回退到 OCR。
新功能:
- 添加一个辅助工具,用标准化关卡代码解析活动关卡模板路径,并在资源存在时使用模板匹配进行关卡导航。
- 为多协助作战关卡选择和支线复刻关卡选择启用基于模板的导航,以提升关卡识别的稳定性。
改进:
- 在资源加载阶段,按完整相对路径索引所有模板图片文件,以便在 C++ 代码中动态查找关卡导航模板。
<details>
<summary>Original summary in English</summary>
## Summary by Sourcery
Introduce template-based stage navigation for event and side-story
stages, falling back to OCR when no template is available.
New Features:
- Add a helper to resolve event stage template paths from standardized
stage codes and use template matching for stage navigation when
resources exist.
- Enable template-based navigation for multi-copilot stage selection and
side-story reopen stage selection to improve stage recognition
reliability.
Enhancements:
- Index all template image files by full relative path during resource
loading to allow dynamic lookup of stage navigation templates from C++
code.
</details>
</details>