fix(tutorials): prevent crew training from reopening or trapping input
Record completion after the guided crew upgrade succeeds. Keep the guide dismissible and close it when its slot or menu target disappears. Compile the affected scripts with the stock queue flag bindings.
This commit is contained in:
1 parent
0c9340f883
commit
0881d62766
25 files changed
+169
-9
No files matched your search
@@ -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:<port>`. 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 |
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
let needArrow = (stepData?.haveArrow ?? true) && blocksList.len() > 0
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
gui_modal_tutor(steps, this)
|
||||
}
|
||||
|
||||
function toBattleTutor() {
|
||||
@@ -0,0 +1,5 @@
|
||||
function checkUpgradeCrewTutorial() {
|
||||
if (!isLoggedIn.get())
|
||||
return
|
||||
|
||||
if (!isAllCrewsMinLevel())
|
||||
@@ -0,0 +1 @@
|
||||
from "%scripts/user/newbieTutorialDisplay.nut" import needShowTutorial, reqFirstCountryChoice, saveShowedTutorial
|
||||
@@ -0,0 +1,2 @@
|
||||
obj = [@() curSlotExtraInfoObj.findObject("openCrewWnd")]
|
||||
text = loc("tutorials/upg_crew/select_crew")
|
||||
@@ -0,0 +1,2 @@
|
||||
obj = [curSlotExtraInfoObj]
|
||||
text = " ".concat(loc("tutorials/upg_crew/skill_points_info"), loc("tutorials/upg_crew/press_to_crew"))
|
||||
@@ -0,0 +1,2 @@
|
||||
local curSlotExtraInfoObj = curSlotObj.findObject("extra_info_content")
|
||||
if (!curSlotExtraInfoObj)
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
gui_modal_tutor(steps, this, true)
|
||||
}
|
||||
|
||||
function toBattleTutor() {
|
||||
@@ -0,0 +1,5 @@
|
||||
function checkUpgradeCrewTutorial() {
|
||||
if (!isLoggedIn.get() || this.guiScene.hasModalObject())
|
||||
return
|
||||
|
||||
if (loadLocalByAccount("tutor/upgradeCrewSkills", false) || !isAllCrewsMinLevel())
|
||||
@@ -0,0 +1,2 @@
|
||||
from "%scripts/user/newbieTutorialDisplay.nut" import needShowTutorial, reqFirstCountryChoice, saveShowedTutorial
|
||||
from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount
|
||||
@@ -0,0 +1,3 @@
|
||||
obj = [@() checkObj(curSlotExtraInfoObj) ? curSlotExtraInfoObj.findObject("openCrewWnd") : null]
|
||||
cancelOnMissingTarget = true
|
||||
text = loc("tutorials/upg_crew/select_crew")
|
||||
@@ -0,0 +1,3 @@
|
||||
obj = [curSlotExtraInfoObj]
|
||||
cancelOnMissingTarget = true
|
||||
text = " ".concat(loc("tutorials/upg_crew/skill_points_info"), loc("tutorials/upg_crew/press_to_crew"))
|
||||
@@ -0,0 +1,2 @@
|
||||
local curSlotExtraInfoObj = curSlotObj.findObject("extra_info_content")
|
||||
if (!checkObj(curSlotExtraInfoObj))
|
||||
@@ -0,0 +1,4 @@
|
||||
gui_modal_tutor(steps, this)
|
||||
}
|
||||
|
||||
function canUpgradeCrewSpec(upgCrew) {
|
||||
@@ -0,0 +1,3 @@
|
||||
this.afterApplyAction = this.canUpgradeCrewSpec(this.crew) ? this.onUpgrCrewSpec1Tutorial
|
||||
: this.onUpgrCrewTutorFinalStep
|
||||
this.onApply() }, this)
|
||||
@@ -0,0 +1 @@
|
||||
from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount, saveLocalByAccount
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
gui_modal_tutor(steps, this, true)
|
||||
}
|
||||
|
||||
function canUpgradeCrewSpec(upgCrew) {
|
||||
@@ -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)
|
||||
@@ -0,0 +1,2 @@
|
||||
from "%scripts/clientState/localProfileDeprecated.nut" import loadLocalByAccount, saveLocalByAccount
|
||||
from "chard" import save_profile
|
||||
@@ -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) + " }"
|
||||
|
||||
Reference in new issue
Block a user