fix: RoguelikeRecruitSupportAnalyzer::analyze HH:MM:SS substr 偏移导致 hour 永为 0、sec 严重低估

```cpp
boost::regex_search(result.text, match_results, boost::regex("[0-9]{2}:[0-9]{2}:[0-9]{2}"))
const auto& match_str = match_results[0].str();              // 8 字节 "HH:MM:SS"
const auto& hour = std::atoi(match_str.substr(2).c_str());   // ":34:56" → 0
const auto& min  = std::atoi(match_str.substr(3, 2).c_str());// "34" ✓(碰巧)
const auto& sec  = std::atoi(match_str.substr(7, 2).c_str());// "6"   → 个位
```

`"12:34:56"` 字节索引 `0=1, 1=2, 2=:, 3=3, 4=4, 5=:, 6=5, 7=6`:
- `substr(2)` 从冒号开始,atoi 立即停 → `hour = 0`
- `substr(3, 2)` 偶然命中 `"34"` → `min = 34` ✓
- `substr(7, 2)` 只有最后 1 字节 `"6"` → `sec` 是个位数字而非两位

正确偏移应为 `(0,2)`、`(3,2)`、`(6,2)`。

不是游戏机制:regex 用的就是 `[0-9]{2}:[0-9]{2}:[0-9]{2}`(ASCII 半角冒号),
匹配成功时 `match_str` 必然是严格 8 字节 `HH:MM:SS` 格式;如果游戏改成
`12时34分56秒` 这种本地化格式,regex 根本不会匹配,函数会在 line 142 提前
`return false`,根本走不到这段 substr 代码。所以 substr 的偏移只看 8 字节
ASCII 格式本身。

实际场景:招募刷新 CD 比如 `01:23:45`,当前算 `0*3600 + 23*60 + 5 = 1385`
秒,正确应是 `5025` 秒——少算近 1 小时。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: fireflysentinel <phoenix1203@uchicago.edu>
This commit is contained in:
fireflysentinel
2026-05-03 12:44:56 +08:00
committed by status102
parent ef0e4958bf
commit c75eeb93bc

View File

@@ -131,9 +131,9 @@ bool asst::RoguelikeRecruitSupportAnalyzer::analyze()
boost::smatch match_results;
if (boost::regex_search(result.text, match_results, boost::regex("[0-9]{2}:[0-9]{2}:[0-9]{2}"))) {
const auto& match_str = match_results[0].str();
const auto& hour = std::atoi(match_str.substr(2).c_str());
const auto& hour = std::atoi(match_str.substr(0, 2).c_str());
const auto& min = std::atoi(match_str.substr(3, 2).c_str());
const auto& sec = std::atoi(match_str.substr(7, 2).c_str());
const auto& sec = std::atoi(match_str.substr(6, 2).c_str());
m_refresh_result = { result.rect, true, 3600 * hour + 60 * min + sec };
return true;
}