refactor(patches)!: migrate definitions to JSONC and script fragments

Patch definitions under exe-patches/ and gui-patches/ move from
patch.json/locate.json to patch.jsonc/locate.jsonc. Each file now holds
only the data needed to apply the patch plus a short English comment
stating what it changes, why the local service cannot provide it, and
what happens without it. Every definition records the game versions it
was verified on (verified_on, required).

GUI patches keep their stock text and replacement in find.nut and
replace.nut next to patch.jsonc instead of escaped JSON strings, so the
script edits are readable, diffable and can carry Quirrel comments.
Matching treats CRLF and LF as the same line break because stock
scripts mix both; only the matched span is rewritten.

Loaders on both sides (packages/build, packages/exepatch, wtotools)
reject unknown keys so analysis text cannot creep back into the data.
JSONC parsing moves into a shared @wto/jsonc package; the build now
parses tuning/store.jsonc instead of scanning it with a regex.

Verified: npm run typecheck; check-patches (10/10 ready on 2.61.0.37);
check-gui (33 patches, 24 scripts compile); the TypeScript and Python
appliers produce identical scripts, byte-identical to the previous
definitions except one stock script with mixed line endings.

The 15 battle patches are migrated mechanically and still carry the
pending-review comment; they are rewritten by the LocalMP review.

BREAKING CHANGE: Patch loaders require JSONC definitions. Migrate patch.json and locate.json and move embedded GUI edits to separate Quirrel files.
This commit is contained in:
N0VAN0M4LY committed 2026-11-28 03:24:12 +08:00
1 parent b260d2899e
commit db981ab834
185 files changed
+2676 -1487

No files matched your search

@@ -0,0 +1,3 @@
skipTutorial = stdMath.change_bit(skipTutorial, this.checkIdx, obj.getValue())
saveLocalByAccount(skipTutorialBitmaskId, skipTutorial)
}
@@ -1,31 +0,0 @@
{
"id": "tutorials/immediate-save-skip-tutorial",
"title": "新手教程询问窗勾选「不再询问」后立即落盘保存",
"file": "scripts/tutorials/nexttutorialhandler.nut",
"program_behaviour": {
"stock": "scripts/tutorials/nexttutorialhandler.nut 的 onSkipTutorial 调用 saveLocalByAccount(skipTutorialBitmaskId, skipTutorial),默认走 saveProfile() 的 60 秒延迟定时器才调用 save_profile(false) 写盘与上行同步。",
"patched": "向 saveLocalByAccount 第三参数显式传入 @() save_profile(false)(与同文件第 52 行 prepareStartTutorial 一致),勾选或取消「不再询问」后立即触发本地 global.blk 写入与云端设置上行同步。"
},
"derivation": {
"requirement": "Persist the tutorial opt-out immediately so it remains set when the client restarts.",
"cause": "原版 saveLocalByAccount 默认回调 saveProfile()(scripts/clientState/saveProfile.nut SAVE_TIMEOUT = 60000)仅启动 60 秒延迟定时器,期间既不写本地磁盘也不向本地服务发送请求;若 60 秒内进程异常退出或被外部终止,跳过标记即丢失。",
"lighter_options_ruled_out": [
"仅靠本地服务:勾选后的 60 秒窗口内客户端不发出任何网络请求,本地服务无从获知勾选状态。"
],
"conclusion": "利用 saveLocalByAccount 原生支持的第三参数 saveFunc,传入本文件第 20 行已导入的 save_profile(false),使勾选变更即时落盘并触发 cln_bulk_set_gblk 同步。",
"if_not_applied": "勾选「不再询问」后 60 秒内若游戏崩溃或强退,下次启动仍会重复弹出新手教程询问窗。"
},
"features": ["A-新手流程"],
"evidence": [
"2.61.0.37 gui.vromfs.bin:scripts/tutorials/nexttutorialhandler.nut 第 20、52、121-128 行;scripts/clientstate/localprofiledeprecated.nut 第 40-53 行(saveLocalByAccount 第三参数 saveFunc);scripts/clientstate/saveprofile.nut 第 12、65 行(SAVE_TIMEOUT = 60000)。",
"2.61.0.37 aces.exe:0x1555600(chard.save_profile 绑定)-> 0x15ffb30 -> 0x4664880(online_storage::save_locally)与 0x4663080(online_storage::send_to_server)。"
],
"edit": {
"find": " skipTutorial = stdMath.change_bit(skipTutorial, this.checkIdx, obj.getValue())\r\n saveLocalByAccount(skipTutorialBitmaskId, skipTutorial)\r\n }",
"replace": " skipTutorial = stdMath.change_bit(skipTutorial, this.checkIdx, obj.getValue())\r\n saveLocalByAccount(skipTutorialBitmaskId, skipTutorial, @() save_profile(false))\r\n }"
}
}
@@ -0,0 +1,20 @@
// Save the tutorial opt-out immediately via save_profile(false).
// Why the client: the stock callback waits 60 s before writing or sending anything to the service.
// Without it: a crash within 60 s of ticking "do not ask again" brings the tutorial prompt back.
{
"id": "tutorials/immediate-save-skip-tutorial",
"title": "新手教程询问窗勾选「不再询问」后立即落盘保存",
"file": "scripts/tutorials/nexttutorialhandler.nut",
"features": [
"A-新手流程"
],
"verified_on": [
"2.61.0.37"
],
"edits": [
{
"find": "find.nut",
"replace": "replace.nut"
}
]
}
@@ -0,0 +1,3 @@
skipTutorial = stdMath.change_bit(skipTutorial, this.checkIdx, obj.getValue())
saveLocalByAccount(skipTutorialBitmaskId, skipTutorial, @() save_profile(false))
}