fix(patcher): support regional.vromfs.bin decal and skin indexes on cache import

Modern online War Thunder clients (verified on 2.61.0.58) ship their decal and
skin indexes (dldata/downloadable_decals.blk and dldata/downloadable_skins.blk)
inside cache/binary.<ver>/regional.vromfs.bin rather than downloading
downloadable_decals.<hash>.blk into cache/content/. Requiring
downloadable_decals.<hash>.blk rejected every live 2.61 cache/content folder.

- Accept modern online caches containing cached .ddsx textures alongside a
  sibling binary.<ver>/regional.vromfs.bin (as well as selecting the parent
  cache folder or legacy downloadable_decals.<hash>.blk caches).
- Extract both dldata/downloadable_decals.blk and dldata/downloadable_skins.blk
  into a self-contained .wto-index snapshot on launcher import (excluded from
  the copied game cache/content folder) and embed them into char.vromfs.bin
  during copy build so webdlcontent::init mounts cache/content and resolves
  cached real decals and downloadable skins natively without client patches.
- Log the specific rejection reason in launcher decal import and clarify the
  en/zh-CN prompts.

Verified with root and launcher npm run typecheck, launcher electron-vite
build, and an end-to-end temporary import + char.vromfs.bin build against a
read-only 2.61.0.58 online cache (4,080 decals / 1,930 skins embedded).
In-game acceptance pending on an isolated 2.61.0.58 client copy.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 01:58:28 +08:00
1 parent deffcd6dde
commit 662e837ab2
9 files changed
+218 -42

No files matched your search

@@ -1,7 +1,12 @@
import { randomUUID } from 'node:crypto';
import { cp, lstat, mkdir, realpath, rm } from 'node:fs/promises';
import { dirname, isAbsolute, join, relative } from 'node:path';
import { isInSteamLibrary, playerDecalCacheProblem } from '@wto/patcher';
import {
isInSteamLibrary,
playerDecalCacheProblem,
resolvePlayerDecalCacheFolder,
writeDecalCacheIndexSnapshot,
} from '@wto/patcher';
import { AppError } from '@shared/errors.ts';
import type { Copies } from '@shared/schemas/install.ts';
import { canonicalCopyPath, copyPathContains, listCopies, steamLibraryNeedsConfirmation, updateCopyRecord } from './install-record.ts';
@@ -33,8 +38,13 @@ export async function importDecalCache(
dataPath: string, sourcePath: string, signal?: AbortSignal, steamDataConfirmed = false,
): Promise<string> {
if (!isAbsolute(sourcePath)) throw new AppError('decal_source_invalid');
const source = await realpath(sourcePath).catch(() => null);
if (!source || playerDecalCacheProblem(source)) throw new AppError('decal_source_invalid');
const rawSource = await realpath(sourcePath).catch(() => null);
const source = rawSource ? await realpath(resolvePlayerDecalCacheFolder(rawSource)).catch(() => null) : null;
const problem = source ? playerDecalCacheProblem(source) : 'selected folder could not be resolved';
if (!source || problem) {
console.warn('[decals] invalid decal cache source:', sourcePath, '->', problem);
throw new AppError('decal_source_invalid');
}
const root = await cacheRoot(dataPath, steamDataConfirmed);
if (copyPathContains(source, root) || copyPathContains(root, source)) {
@@ -56,7 +66,12 @@ export async function importDecalCache(
},
});
signal?.throwIfAborted();
if (playerDecalCacheProblem(target)) throw new AppError('decal_source_invalid');
writeDecalCacheIndexSnapshot(source, target);
const copiedProblem = playerDecalCacheProblem(target);
if (copiedProblem) {
console.warn('[decals] copied decal cache failed validation:', copiedProblem);
throw new AppError('decal_source_invalid');
}
return id;
} catch (error) {
await discardDecalCache(dataPath, id, steamDataConfirmed);
@@ -1,7 +1,7 @@
import { readFileSync, realpathSync } from 'node:fs';
import { relative } from 'node:path';
import type { MessageEvent } from 'electron';
import { assertWritableCopy, buildGameCopy, copyPlayerDecalCache, playerDecalCacheProblem, readStockGameFiles, writeGameCopy, type GameCopyFile } from '@wto/patcher';
import { assertWritableCopy, buildGameCopy, copyPlayerDecalCache, playerDecalCacheProblem, readPlayerDecalIndexFiles, readStockGameFiles, writeGameCopy, type GameCopyFile } from '@wto/patcher';
import { multiVehiclePackIds } from '@wto/server';
import type { BuildCommand, BuildReply, BuildRequest } from './build-protocol.ts';
@@ -34,6 +34,7 @@ function importedDecals(path: string | undefined): string | undefined {
function build(request: BuildRequest): void {
checkBuildLocation(request);
const decalCache = importedDecals(request.decalCache);
const decalIndexFiles = decalCache ? readPlayerDecalIndexFiles(decalCache) : undefined;
const result = buildGameCopy({
stock: readStockGameFiles(request.stockPath),
patches: request.patches,
@@ -41,6 +42,7 @@ function build(request: BuildRequest): void {
port: request.port,
multiVehiclePackIds: multiVehiclePackIds(request.dataPath, console.info),
placeholderDecals: decalCache === undefined,
...(decalIndexFiles ? { decalIndexFiles } : {}),
hookLogging: request.hookLogging,
});
const unavailable = [...result.exePatches.failures, ...result.guiPatches.failures, ...result.nativeModules.failures];
@@ -96,7 +96,7 @@
},
"decals": {
"source": "Decal source",
"hint": "Import the online game's cache/content folder. The client uses placeholder decals when no cache is available.",
"hint": "Import the online game's cache/content (or cache) folder for cached decals and downloadable skins. Placeholder decals are used when no cache is available.",
"choose": "Choose decal cache…",
"useDefault": "Use placeholder decals",
"importing": "Importing decal cache",
@@ -494,7 +494,7 @@
"appUpdates": "Launcher updates",
"appUpdatesToggle": "Check for launcher updates at start",
"patchPacks": "Adaptation pack updates",
"patchPacksHint": "After a game update, the patches for the new version are released on GitHub as an adaptation pack.",
"patchPacksHint": "After a game update, patches for the new version are released as an adaptation pack.",
"updateMirror": "Update mirror repository",
"updateMirrorHint": "Enter an HTTPS mirror with a GitHub-compatible releases list. It is used if the primary source is unreachable. Leave blank to disable it.",
"updateMirrorInvalid": "Enter a valid HTTPS repository address or leave the field blank.",
@@ -706,7 +706,7 @@
"copy_not_found": "The selected client is no longer available.",
"copies_write_failed": "The client registry could not be saved.",
"copy_location_in_use": "The client or data location overlaps an existing client.",
"decal_source_invalid": "The selected folder does not contain a usable decal cache.",
"decal_source_invalid": "The selected folder does not contain a usable decal cache. Log into the online hangar once to populate it, then choose cache/content (or cache).",
"decal_import_failed": "The decal cache could not be imported into the client's data folder. See the launcher log.",
"maintenance_busy": "Maintenance requires the game, local server and other client operations to be stopped.",
"maintenance_location": "The operation would affect files outside the registered client or data folder.",
@@ -96,7 +96,7 @@
},
"decals": {
"source": "贴花来源",
"hint": "可导入在线版游戏的 cache/content。未导入时使用占位贴花。",
"hint": "可导入在线版游戏的 cache/content(或 cache),同时支持已缓存的真实贴花与可下载涂装。未导入时使用占位贴花。",
"choose": "选择贴花缓存…",
"useDefault": "使用占位贴花",
"importing": "正在导入贴花缓存",
@@ -494,7 +494,7 @@
"appUpdates": "启动器本体更新",
"appUpdatesToggle": "启动时检查本体更新",
"patchPacks": "适配包更新",
"patchPacksHint": "游戏更新后,新版本的补丁会以适配包的形式发布在 GitHub 上。",
"patchPacksHint": "游戏更新后,新版本的补丁会以适配包的形式发布。",
"updateMirror": "备用更新仓库",
"updateMirrorHint": "填写支持 GitHub Releases 格式的 HTTPS 镜像地址。主源连接失败时使用,留空关闭。",
"updateMirrorInvalid": "请输入有效的 HTTPS 仓库地址,或留空。",
@@ -706,7 +706,7 @@
"copy_not_found": "所选客户端已不可用。",
"copies_write_failed": "无法保存客户端记录。",
"copy_location_in_use": "客户端位置或数据目录与已有客户端重叠。",
"decal_source_invalid": "选定的目录缺少有效的贴花缓存。",
"decal_source_invalid": "选定的目录缺少有效的贴花缓存。请先登录过在线版机库生成缓存,再选择在线版目录中的 cache/content(或 cache)。",
"decal_import_failed": "无法把贴花缓存导入客户端数据目录。请查看启动器日志。",
"maintenance_busy": "维护前需结束游戏、本地服务器和其他客户端操作。",
"maintenance_location": "操作会影响登记的客户端或数据目录之外的文件。",