diff --git a/README.md b/README.md index 2c84a19..f41029c 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不 - **服务地址**:`config/network.blk`(`char.vromfs.bin`)和 `config/settings.blk`(`aces.vromfs.bin`)中所有 Gaijin 地址改写为 `127.0.0.1:<端口>`。端口在构建时写入,因此服务器必须使用相同的端口。 - **配置表**:开启离线需要的功能开关,放出隐藏载具,写入贴花索引,为本地商店的礼包登记 GUID。 - **exe 补丁**:`patches/exe/` 下共 12 项,见下表。 -- **界面脚本补丁**:`patches/gui/` 下共 37 项,用于本地账号注册、本地对局的开局与结算、本地商店的购买回执,以及库存签名公钥等。 +- **界面脚本补丁**:`patches/gui/` 下共 40 项,用于本地账号注册、本地对局的开局与结算、本地商店的购买回执,以及库存签名公钥等。 - **网络钩子库**:exe 的导入表把 `WS2_32.dll` 改为同长度的 `wto_ws.dll`。该库转发系统 `ws2_32.dll` 的全部导出,并用 MinHook 挂钩域名解析(`getaddrinfo` 等)、连接(`connect`、`ConnectEx` 等)和 UDP 发送,把所有外部连接重定向到本地服务器端口。端口从 exe 旁的 `wto_ws.cfg` 读取。 | exe 补丁 | 作用 | @@ -329,7 +329,7 @@ Static data such as vehicles, tech trees, prices, and reward factors is extracte - **Service addresses**: every Gaijin address in `config/network.blk` (`char.vromfs.bin`) and `config/settings.blk` (`aces.vromfs.bin`) is rewritten to `127.0.0.1:`. The port is written at build time, so the server must use the same port. - **Config tables**: enables feature flags the offline copy needs, reveals hidden vehicles, adds a decal index, and registers GUIDs for local store packs. - **exe patches**: 12 patches under `patches/exe/`, listed below. -- **UI script patches**: 37 patches under `patches/gui/`, covering local account registration, battle start and settlement, store purchase receipts, and the inventory signing key. +- **UI script patches**: 40 patches under `patches/gui/`, covering local account registration, battle start and settlement, store purchase receipts, and the inventory signing key. - **Network hook library**: the import table entry `WS2_32.dll` is renamed to `wto_ws.dll`, which has the same length. The library forwards every export of the system `ws2_32.dll` and uses MinHook to hook name resolution (`getaddrinfo` and others), connections (`connect`, `ConnectEx`, and others), and UDP sends, redirecting every external connection to the local server port. The port is read from `wto_ws.cfg` next to the exe. | exe patch | Purpose | diff --git a/patches/gui/tutorials/cancel-guide-without-target/find-missing-target.nut b/patches/gui/tutorials/cancel-guide-without-target/find-missing-target.nut new file mode 100644 index 0000000..d93e5d6 --- /dev/null +++ b/patches/gui/tutorials/cancel-guide-without-target/find-missing-target.nut @@ -0,0 +1 @@ + let needArrow = (stepData?.haveArrow ?? true) && blocksList.len() > 0 diff --git a/patches/gui/tutorials/cancel-guide-without-target/patch.jsonc b/patches/gui/tutorials/cancel-guide-without-target/patch.jsonc new file mode 100644 index 0000000..634ada9 --- /dev/null +++ b/patches/gui/tutorials/cancel-guide-without-target/patch.jsonc @@ -0,0 +1,20 @@ +// An opted-in object-click step can close safely when there is nothing to click. +{ + "id": "tutorials/cancel-guide-without-target", + "title": "Dismiss opted-in guide steps when their UI target disappears", + "features": [ + "A-Tutorials" + ], + "variants": [ + { + "written_for": "2.61.0.37", + "file": "scripts/guitutorial.nut", + "edits": [ + { + "find": "find-missing-target.nut", + "replace": "replace-missing-target.nut" + } + ] + } + ] +} diff --git a/patches/gui/tutorials/cancel-guide-without-target/replace-missing-target.nut b/patches/gui/tutorials/cancel-guide-without-target/replace-missing-target.nut new file mode 100644 index 0000000..7748475 --- /dev/null +++ b/patches/gui/tutorials/cancel-guide-without-target/replace-missing-target.nut @@ -0,0 +1,6 @@ + if ((stepData?.cancelOnMissingTarget ?? false) && blocksList.len() == 0) { + this.canceled = true + return this.goBack() + } + + let needArrow = (stepData?.haveArrow ?? true) && blocksList.len() > 0 diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-allow-close.nut b/patches/gui/tutorials/guard-crew-training-intro/find-allow-close.nut new file mode 100644 index 0000000..1766aaf --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-allow-close.nut @@ -0,0 +1,4 @@ + gui_modal_tutor(steps, this) + } + + function toBattleTutor() { diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-entry.nut b/patches/gui/tutorials/guard-crew-training-intro/find-entry.nut new file mode 100644 index 0000000..679a85d --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-entry.nut @@ -0,0 +1,5 @@ + function checkUpgradeCrewTutorial() { + if (!isLoggedIn.get()) + return + + if (!isAllCrewsMinLevel()) diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-imports.nut b/patches/gui/tutorials/guard-crew-training-intro/find-imports.nut new file mode 100644 index 0000000..50561a6 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-imports.nut @@ -0,0 +1 @@ +from "%scripts/user/newbieTutorialDisplay.nut" import needShowTutorial, reqFirstCountryChoice, saveShowedTutorial diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-menu-step.nut b/patches/gui/tutorials/guard-crew-training-intro/find-menu-step.nut new file mode 100644 index 0000000..3c84480 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-menu-step.nut @@ -0,0 +1,2 @@ + obj = [@() curSlotExtraInfoObj.findObject("openCrewWnd")] + text = loc("tutorials/upg_crew/select_crew") diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-slot-step.nut b/patches/gui/tutorials/guard-crew-training-intro/find-slot-step.nut new file mode 100644 index 0000000..621098b --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-slot-step.nut @@ -0,0 +1,2 @@ + obj = [curSlotExtraInfoObj] + text = " ".concat(loc("tutorials/upg_crew/skill_points_info"), loc("tutorials/upg_crew/press_to_crew")) diff --git a/patches/gui/tutorials/guard-crew-training-intro/find-slot.nut b/patches/gui/tutorials/guard-crew-training-intro/find-slot.nut new file mode 100644 index 0000000..a07392a --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/find-slot.nut @@ -0,0 +1,2 @@ + local curSlotExtraInfoObj = curSlotObj.findObject("extra_info_content") + if (!curSlotExtraInfoObj) diff --git a/patches/gui/tutorials/guard-crew-training-intro/patch.jsonc b/patches/gui/tutorials/guard-crew-training-intro/patch.jsonc new file mode 100644 index 0000000..4cc0db5 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/patch.jsonc @@ -0,0 +1,40 @@ +// The crew skill guide may be entered from the hangar while menus are reopening. +{ + "id": "tutorials/guard-crew-training-intro", + "title": "Keep the crew skill guide from reopening", + "features": [ + "A-Tutorials" + ], + "variants": [ + { + "written_for": "2.61.0.37", + "file": "scripts/mainmenu/instantactionhandler.nut", + "edits": [ + { + "find": "find-imports.nut", + "replace": "replace-imports.nut" + }, + { + "find": "find-entry.nut", + "replace": "replace-entry.nut" + }, + { + "find": "find-slot.nut", + "replace": "replace-slot.nut" + }, + { + "find": "find-slot-step.nut", + "replace": "replace-slot-step.nut" + }, + { + "find": "find-menu-step.nut", + "replace": "replace-menu-step.nut" + }, + { + "find": "find-allow-close.nut", + "replace": "replace-allow-close.nut" + } + ] + } + ] +} diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-allow-close.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-allow-close.nut new file mode 100644 index 0000000..5e1cba2 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-allow-close.nut @@ -0,0 +1,4 @@ + gui_modal_tutor(steps, this, true) + } + + function toBattleTutor() { diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-entry.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-entry.nut new file mode 100644 index 0000000..74a4ea9 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-entry.nut @@ -0,0 +1,5 @@ + function checkUpgradeCrewTutorial() { + if (!isLoggedIn.get() || this.guiScene.hasModalObject()) + return + + if (loadLocalByAccount("tutor/upgradeCrewSkills", false) || !isAllCrewsMinLevel()) diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-imports.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-imports.nut new file mode 100644 index 0000000..32ed3c0 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-imports.nut @@ -0,0 +1,2 @@ +from "%scripts/user/newbieTutorialDisplay.nut" import needShowTutorial, reqFirstCountryChoice, saveShowedTutorial +from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-menu-step.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-menu-step.nut new file mode 100644 index 0000000..c42fea6 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-menu-step.nut @@ -0,0 +1,3 @@ + obj = [@() checkObj(curSlotExtraInfoObj) ? curSlotExtraInfoObj.findObject("openCrewWnd") : null] + cancelOnMissingTarget = true + text = loc("tutorials/upg_crew/select_crew") diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-slot-step.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-slot-step.nut new file mode 100644 index 0000000..7e7ca7d --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-slot-step.nut @@ -0,0 +1,3 @@ + obj = [curSlotExtraInfoObj] + cancelOnMissingTarget = true + text = " ".concat(loc("tutorials/upg_crew/skill_points_info"), loc("tutorials/upg_crew/press_to_crew")) diff --git a/patches/gui/tutorials/guard-crew-training-intro/replace-slot.nut b/patches/gui/tutorials/guard-crew-training-intro/replace-slot.nut new file mode 100644 index 0000000..b5da1f6 --- /dev/null +++ b/patches/gui/tutorials/guard-crew-training-intro/replace-slot.nut @@ -0,0 +1,2 @@ + local curSlotExtraInfoObj = curSlotObj.findObject("extra_info_content") + if (!checkObj(curSlotExtraInfoObj)) diff --git a/patches/gui/tutorials/save-crew-training-completion/find-allow-close.nut b/patches/gui/tutorials/save-crew-training-completion/find-allow-close.nut new file mode 100644 index 0000000..6062c8e --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/find-allow-close.nut @@ -0,0 +1,4 @@ + gui_modal_tutor(steps, this) + } + + function canUpgradeCrewSpec(upgCrew) { diff --git a/patches/gui/tutorials/save-crew-training-completion/find-completion.nut b/patches/gui/tutorials/save-crew-training-completion/find-completion.nut new file mode 100644 index 0000000..00b18e4 --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/find-completion.nut @@ -0,0 +1,3 @@ + this.afterApplyAction = this.canUpgradeCrewSpec(this.crew) ? this.onUpgrCrewSpec1Tutorial + : this.onUpgrCrewTutorFinalStep + this.onApply() }, this) diff --git a/patches/gui/tutorials/save-crew-training-completion/find-imports.nut b/patches/gui/tutorials/save-crew-training-completion/find-imports.nut new file mode 100644 index 0000000..94ad98b --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/find-imports.nut @@ -0,0 +1 @@ +from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount, saveLocalByAccount diff --git a/patches/gui/tutorials/save-crew-training-completion/patch.jsonc b/patches/gui/tutorials/save-crew-training-completion/patch.jsonc new file mode 100644 index 0000000..517b3b6 --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/patch.jsonc @@ -0,0 +1,28 @@ +// Save the per-account completion flag from the existing successful upgrade callback. +{ + "id": "tutorials/save-crew-training-completion", + "title": "Save completion after the guided crew upgrade", + "features": [ + "A-Tutorials" + ], + "variants": [ + { + "written_for": "2.61.0.37", + "file": "scripts/crew/crewwndhandler.nut", + "edits": [ + { + "find": "find-imports.nut", + "replace": "replace-imports.nut" + }, + { + "find": "find-completion.nut", + "replace": "replace-completion.nut" + }, + { + "find": "find-allow-close.nut", + "replace": "replace-allow-close.nut" + } + ] + } + ] +} diff --git a/patches/gui/tutorials/save-crew-training-completion/replace-allow-close.nut b/patches/gui/tutorials/save-crew-training-completion/replace-allow-close.nut new file mode 100644 index 0000000..83484ea --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/replace-allow-close.nut @@ -0,0 +1,4 @@ + gui_modal_tutor(steps, this, true) + } + + function canUpgradeCrewSpec(upgCrew) { diff --git a/patches/gui/tutorials/save-crew-training-completion/replace-completion.nut b/patches/gui/tutorials/save-crew-training-completion/replace-completion.nut new file mode 100644 index 0000000..54ce5ea --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/replace-completion.nut @@ -0,0 +1,8 @@ + let nextStep = this.canUpgradeCrewSpec(this.crew) ? this.onUpgrCrewSpec1Tutorial + : this.onUpgrCrewTutorFinalStep + this.afterApplyAction = function() { + saveLocalByAccount("tutor/upgradeCrewSkills", true, @() save_profile(false)) + nextStep.call(this) + } + this.onApply() + }, this) diff --git a/patches/gui/tutorials/save-crew-training-completion/replace-imports.nut b/patches/gui/tutorials/save-crew-training-completion/replace-imports.nut new file mode 100644 index 0000000..b7bc4ba --- /dev/null +++ b/patches/gui/tutorials/save-crew-training-completion/replace-imports.nut @@ -0,0 +1,2 @@ +from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount, saveLocalByAccount +from "chard" import save_profile diff --git a/tools/src/wtotools/gui_check.py b/tools/src/wtotools/gui_check.py index 4a7710a..3af8114 100644 --- a/tools/src/wtotools/gui_check.py +++ b/tools/src/wtotools/gui_check.py @@ -64,6 +64,7 @@ let typeMap = { Float = types.Float Bool = types.Bool CtrlsInGui = __CONTROL_MASKS__ + QUEUE_TYPE_BIT = __QUEUE_MASKS__ } function readText(p) { let f = io.file(p, "rb") @@ -177,7 +178,14 @@ def verify_gui_patches( manifest_path = tmp_dir / "manifest.tsv" manifest_path.write_text("\n".join(manifest_lines), encoding="utf-8") # The standalone interpreter does not expose __argv as a script binding. - harness_source = HARNESS_SOURCE.replace("__CONTROL_MASKS__", _control_masks_literal(stock_archive)) + harness_source = HARNESS_SOURCE.replace( + "__CONTROL_MASKS__", + _integer_table_literal(stock_archive, "globalscripts/sharedenums.nut", r"\benum\s+CtrlsInGui"), + ) + harness_source = harness_source.replace( + "__QUEUE_MASKS__", + _integer_table_literal(stock_archive, "scripts/queue/queuetypebit.nut", r"\breturn\s+freeze\("), + ) harness_source = harness_source.replace("__MANIFEST_PATH__", json.dumps(manifest_path.as_posix(), ensure_ascii=False)) harness_path = tmp_dir / "harness.nut" harness_path.write_text(harness_source, encoding="utf-8") @@ -207,17 +215,17 @@ def verify_gui_patches( return GuiCheckReport(len(patches), len(touched_files), tuple(errors)) -def _control_masks_literal(archive: Archive) -> str: - """Use the stock integer masks for constant expressions involving CtrlsInGui.""" - source = archive.files.get("globalscripts/sharedenums.nut", b"").decode("utf-8") - enum = re.search(r"\benum\s+CtrlsInGui\s*\{([^{}]*)\}", source) - if enum is None: +def _integer_table_literal(archive: Archive, file: str, table_start: str) -> str: + """Read a stock table of integer flags for constant expressions in the compiler.""" + source = archive.files.get(file, b"").decode("utf-8") + table = re.search(table_start + r"\s*\{([^{}]*)\}", source) + if table is None: return "{}" fields = re.findall( r"^[ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]*=[ \t]*" r"(0x[0-9a-fA-F]+|[0-9]+)[ \t]*,?[ \t]*(?://[^\r\n]*)?\r?$", - enum[1], + table[1], re.MULTILINE, ) return "{ " + ", ".join(f"{name} = {value}" for name, value in fields) + " }"