fix: 修正多作业 H 关 OCR 替换 / correct H-stage OCR replacement (#17326)

## 说明

多作业模式进入 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
This commit is contained in:
Zian Wen
2026-07-12 15:18:15 +08:00
committed by GitHub
parent 9de02b5988
commit 7746f07fc4

View File

@@ -271,8 +271,8 @@
["t", "T"],
[":", ""],
["'", ""],
["(H\\d+)O(?=-)", "$010"],
["(-\\d+)O", "$010"],
["(H\\d+)O(?=-)", "${1}0"],
["(-\\d+)O", "${1}0"],
[".*?([A-Z]{2}-EX-\\d+)", "$1"],
["-I$", "-1"]
],
@@ -307,8 +307,8 @@
["t", "T"],
[":", ""],
["'", ""],
["(H\\d+)O(?=-)", "$010"],
["(-\\d+)O", "$010"],
["(H\\d+)O(?=-)", "${1}0"],
["(-\\d+)O", "${1}0"],
[".*?([A-Z]{2}-EX-\\d+)", "$1"]
],
"roi": [845, 72, 220, 50]