diff --git a/gui-patches/tutorials/immediate-save-skip-tutorial/patch.json b/gui-patches/tutorials/immediate-save-skip-tutorial/patch.json new file mode 100644 index 0000000..440c9e8 --- /dev/null +++ b/gui-patches/tutorials/immediate-save-skip-tutorial/patch.json @@ -0,0 +1,31 @@ +{ + "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": "用户反馈(反馈20261125.md,原话 129 方案 A):新手教程询问窗设置「不再询问」后应稳定持久化,不应在重启游戏后反复重弹。", + "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 }" + } +} diff --git a/packages/build/src/features/offline-features.ts b/packages/build/src/features/offline-features.ts index 1343763..e2a6d6e 100644 --- a/packages/build/src/features/offline-features.ts +++ b/packages/build/src/features/offline-features.ts @@ -5,10 +5,12 @@ * condition:t="" means every player has it (the UI scripts ask with hasFeature, which falls * back to the native local_player_has_feature, scripts/user/features.nut). * - * AllowedToSkipBaseTutorials: lets the player skip the base tutorials. The stock tutorial - * offer (scripts/tutorials/nextTutorialHandler.nut) enables its skip and close buttons only - * with this feature (tutorialsData.nut canSkipByFeature). The offline version makes the - * tutorial optional (local verification). + * AllowedToSkipBaseTutorials / AllowedToSkipBaseTankTutorials: let the player skip or close + * every branch's base tutorial offer. `scripts/tutorials/tutorialsData.nut` gates air and naval + * base tutorials on `AllowedToSkipBaseTutorials` and ground base tutorials (`lightTank`, + * `lightTank_action`) on `AllowedToSkipBaseTankTutorials`; without both, `NextTutorialHandler` + * hides its "do not ask me again" checkbox and close button until the tutorial is started once + * (local verification). * * PaymentMethods: lets scripts/onlineShop/onlinePurchase.nut offer GJN payment directly * inside the Golden Eagles and Premium Account windows (stock game_settings.blk restricts it @@ -18,7 +20,11 @@ import { ensureBlock, setParam, type BlkBlock } from '@wto/blk'; export const GAME_SETTINGS_PATH = 'config/game_settings.blk'; -export const OFFLINE_FEATURES: readonly string[] = ['AllowedToSkipBaseTutorials', 'PaymentMethods']; +export const OFFLINE_FEATURES: readonly string[] = [ + 'AllowedToSkipBaseTutorials', + 'AllowedToSkipBaseTankTutorials', + 'PaymentMethods', +]; /** Give every player the features; returns the ones that were not on for everyone before. */ export function enableFeaturesForEveryone(gameSettings: BlkBlock, names: readonly string[]): string[] { diff --git a/packages/local-service/src/char/actions/cloud-settings-actions.ts b/packages/local-service/src/char/actions/cloud-settings-actions.ts index 9fe22a2..9f4dfeb 100644 --- a/packages/local-service/src/char/actions/cloud-settings-actions.ts +++ b/packages/local-service/src/char/actions/cloud-settings-actions.ts @@ -18,21 +18,29 @@ import { import { withAccount } from './account-context.ts'; import { headerOrPayloadInt, headerOrPayloadString } from './payload-params.ts'; -/** `cln_get_meta_blk`: returns schema, compression negotiation, and saved block versions/hashes. */ +/** + * `cln_get_meta_blk`: returns schema, compression negotiation, and saved block versions/hashes. + * `GetMetaHandler::handleResponse` (0x46659c0 -> 0x3280a50) parses the raw HTTP body directly + * with `DataBlock::loadFromStream` without stripping the `'i'` char compression marker. + */ export function getMetaBlkAction(accounts: AccountStore, cloudSettings: CloudSettingsStore): CharActionHandler { return (context) => withAccount(context, accounts, (account) => ({ - kind: 'data', + kind: 'raw-blk', blk: cloudSettings.buildMetaBlk(account.userId), })); } -/** `cln_get_general_blk`: returns `ContainerBlk` (`version:i`, `content { ... }`) for a valid `blkType`. */ +/** + * `cln_get_general_blk`: returns `ContainerBlk` (`version:i`, `content { ... }`) for a valid `blkType`. + * `LoadingHandler::handleResponse` (0x4667930 -> `ContainerBlk::load` 0x466a9e0 -> 0x3280a50) + * likewise reads bare binary BLK directly from the HTTP response buffer. + */ export function getGeneralBlkAction(accounts: AccountStore, cloudSettings: CloudSettingsStore): CharActionHandler { return (context) => withAccount(context, accounts, (account) => { const blkType = headerOrPayloadString(context, 'blkType'); if (!blkType || !isSupportedGeneralBlkType(blkType)) return { kind: 'error', code: 'BAD_PARAM' }; const stored = cloudSettings.loadContainer(account.userId, blkType) ?? buildContainerBlk(1, emptyBlock('content')); - return { kind: 'data', blk: stored }; + return { kind: 'raw-blk', blk: stored }; }); } diff --git a/packages/local-service/src/char/char-answers.ts b/packages/local-service/src/char/char-answers.ts index 8fd75d0..9447cc1 100644 --- a/packages/local-service/src/char/char-answers.ts +++ b/packages/local-service/src/char/char-answers.ts @@ -1,16 +1,20 @@ /** - * The char service's three kinds of answer (implementation notes; aces.exe 2.61.0.37, + * The char service's answer shapes (implementation notes; aces.exe 2.61.0.37, * CharServerClient::handleReqResult at 0x336d590): - * - data: HTTP 200, a compression marker and a BLK; + * - data: HTTP 200, a compression marker ('i') and a binary BLK (`loadBlkFromAnswer`, 0x336fd60); + * - raw-blk: HTTP 200, a bare binary BLK with no compression marker, for `online_storage` + * endpoints (`GetMetaHandler` 0x46659c0 and `LoadingHandler` 0x4667930 -> `0x3280a50`); + * - json: HTTP 200, UTF-8 JSON for custom JSON actions; * - done: HTTP 200 with a body starting "!OK", for requests that expect no data; * - error: a body starting "!ERROR:" followed by an error code. */ -import { formatBlkText, type BlkBlock } from '@wto/blk'; +import { encodeBlk, formatBlkText, type BlkBlock } from '@wto/blk'; import type { ServiceResponse } from '../server/exchange.ts'; import { encodeDataAnswer } from './char-payload.ts'; export type CharAnswer = | { readonly kind: 'data'; readonly blk: BlkBlock } + | { readonly kind: 'raw-blk'; readonly blk: BlkBlock } | { readonly kind: 'json'; readonly data: unknown } | { readonly kind: 'done' } | { readonly kind: 'error'; readonly code: string }; @@ -19,6 +23,8 @@ export function toResponse(answer: CharAnswer): ServiceResponse { switch (answer.kind) { case 'data': return { status: 200, headers: BINARY, body: encodeDataAnswer(answer.blk), logNotes: { responseText: formatBlkText(answer.blk) } }; + case 'raw-blk': + return { status: 200, headers: BINARY, body: encodeBlk(answer.blk), logNotes: { responseText: formatBlkText(answer.blk) } }; case 'json': { const body = JSON.stringify(answer.data); return { status: 200, headers: JSON_HEADERS, body, logNotes: { responseText: body } };