From 7746f07fc4149a8a6000d0fcfebff04cda4b6d85 Mon Sep 17 00:00:00 2001 From: Zian Wen <53964029+wzacolemak@users.noreply.github.com> Date: Sun, 12 Jul 2026 15:18:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E5=A4=9A=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=20H=20=E5=85=B3=20OCR=20=E6=9B=BF=E6=8D=A2=20/=20corr?= =?UTF-8?q?ect=20H-stage=20OCR=20replacement=20(#17326)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 说明 多作业模式进入 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`。
English ## 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.
Refs #16888 --- resource/tasks/tasks.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resource/tasks/tasks.json b/resource/tasks/tasks.json index eb3f3e69f8..fc70f2391e 100644 --- a/resource/tasks/tasks.json +++ b/resource/tasks/tasks.json @@ -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]