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": "操作会影响登记的客户端或数据目录之外的文件。",
+4
View File
@@ -21,6 +21,7 @@ import { localEndpoint, type LocalEndpoint } from './network/local-endpoint.ts';
import { NETWORK_HOOK_LIBRARY, networkHookSettings } from './network/network-hook.ts';
import { loadNativeModules } from './native/native-definition.ts';
import { resolveNativeModules } from './native/native-resolve.ts';
import type { AddedFile } from './pack-edit.ts';
import { patchSetFolders } from './patch-set.ts';
import { offlinePackBundleGuids } from './store/offline-bundles.ts';
@@ -44,6 +45,8 @@ export interface GameCopyInputs {
readonly multiVehiclePackIds: readonly string[];
/** Store the placeholder decal index; false when the player's own web cache is copied. */
readonly placeholderDecals: boolean;
/** Real dldata/downloadable_decals.blk and downloadable_skins.blk extracted from the player's cache. */
readonly decalIndexFiles?: readonly AddedFile[];
/** Whether wto_ws.dll writes win64/wto_ws.log; defaults to true. */
readonly hookLogging?: boolean;
}
@@ -92,6 +95,7 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
appliedGuiPatches.includes('registration/keep-local-page-embedded');
const { pack: charPack, ...charReport } = rebuildCharPack(inputs.stock.charPack, endpoint, {
placeholderDecals: inputs.placeholderDecals,
...(inputs.decalIndexFiles ? { decalIndexFiles: inputs.decalIndexFiles } : {}),
localRegistration,
});
const bundles = offlinePackBundleGuids(inputs.stock.charPack, inputs.multiVehiclePackIds);
+10 -4
View File
@@ -8,7 +8,7 @@ import { DECALS_CONFIG_PATH, offlineDecalIndex } from './decals/offline-decal-in
import { enableFeaturesForEveryone, GAME_SETTINGS_PATH, OFFLINE_FEATURES } from './features/offline-features.ts';
import type { LocalEndpoint } from './network/local-endpoint.ts';
import { redirectNetworkConfig, type NetworkRedirectReport } from './network/redirect-network-config.ts';
import { editPackBlks, readPackBlk } from './pack-edit.ts';
import { editPackBlks, readPackBlk, type AddedFile } from './pack-edit.ts';
import { revealHiddenVehicles, SHOP_PATH } from './tech-tree/reveal-hidden-vehicles.ts';
export const NETWORK_CONFIG_PATH = 'config/network.blk';
@@ -20,13 +20,15 @@ export interface CharPackResult {
readonly features: readonly string[];
/** Vehicles that were hidden from players who had not researched or bought them. */
readonly revealedVehicles: number;
/** Decals in the placeholder index; undefined when the index was left out. */
/** Decals in the placeholder index; undefined when the player's own decal cache is used. */
readonly placeholderDecals: number | undefined;
}
export interface CharPackOptions {
/** Store the placeholder decal index (false when the player's own web cache is copied). */
readonly placeholderDecals: boolean;
/** Real dldata/downloadable_decals.blk and downloadable_skins.blk extracted from the player's cache. */
readonly decalIndexFiles?: readonly AddedFile[];
readonly localRegistration: boolean;
}
@@ -34,11 +36,15 @@ export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint,
let network: NetworkRedirectReport | undefined;
let features: string[] = [];
let revealedVehicles = 0;
const decals = options.placeholderDecals ? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH)) : undefined;
const usePlayerIndex = (options.decalIndexFiles?.length ?? 0) > 0;
const decals = !usePlayerIndex && options.placeholderDecals
? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH))
: undefined;
const addedFiles = usePlayerIndex ? options.decalIndexFiles! : (decals?.files ?? []);
const pack = editPackBlks(stockPack, [
{ path: NETWORK_CONFIG_PATH, edit: (root) => { network = redirectNetworkConfig(root, endpoint, options.localRegistration); } },
{ path: GAME_SETTINGS_PATH, edit: (root) => { features = enableFeaturesForEveryone(root, OFFLINE_FEATURES); } },
{ path: SHOP_PATH, edit: (root) => { revealedVehicles = revealHiddenVehicles(root); } },
], decals?.files ?? []);
], addedFiles);
return { pack, network: network!, features, revealedVehicles, placeholderDecals: decals?.decals };
}
+166 -26
View File
@@ -1,47 +1,98 @@
/**
* Decals from the player's own online client: the player names the web cache folder of an
* installation they have played online with (<game>/cache/content), and the build copies it
* into the game copy's cache/content. The offline version never looks for that folder itself.
* Decals and downloadable skins from the player's own online client: the player names the web
* cache folder of an installation they have played online with (<game>/cache/content, or its
* parent <game>/cache), and the build copies the cached textures into the game copy's
* cache/content. The offline version never looks for that folder itself.
*
* What the copy gives the client (aces.exe 2.61.0.37):
* - cache/content/ is the web cache root ("ContentProvider::init mount=<game>/cache/content/").
* - dldata_s.info names the current indexes; when the request for it fails, the client reads
* the cached copy ("failed to get dlContent index hashes from %s, will fallback local copy",
* 0xd3eb40), and the local server answers that request with 404.
* - downloadable_decals.<hash>.blk is the decal index as the CDN served it, with its signature
* (0xd383e0 checks it and deletes a file that fails). If the file named by dldata_s.info is
* missing, the newest valid downloadable_decals.*.blk in the folder is used (0xd3f610).
* - Each decal's texture is fetched through the web cache by its lod0 name (0xd44fc0); the
* textures the player's client has cached are in the copied folder (assumed, not verified
* against an online cache: the folder layout below httpCache/ was not examined). Textures it
* never cached cannot be fetched offline and stay blank.
*
* With a player source the build leaves the vromfs index (offline-decal-index.ts) out of
* char.vromfs.bin, because the client takes the vromfs index first and then skips the web cache.
* Two layouts exist across War Thunder builds (verified on 2.61.0.37 and 2.61.0.58):
* 1. Modern vromfs-indexed cache (2.61+): cache/content/ holds dldata_s.info and the downloaded
* <first2>/<hash>.ddsx textures, while the decal and skin indexes (dldata/downloadable_decals.blk
* and dldata/downloadable_skins.blk) ship inside sibling cache/binary.<ver>/regional.vromfs.bin
* (mounted by webdlcontent::on_regional_vrom_remounted, 0xd3cf95 -> 0xd3d066). Because the client
* reads the vromfs index first, it never writes downloadable_decals.<hash>.blk into cache/content/.
* We extract both index BLKs into a self-contained snapshot (.wto-index/) on import and embed
* them into char.vromfs.bin during build so webdlcontent::init mounts cache/content/ (0xd3ca11)
* and loads the real hashes from vromfs without signature checks (0xd3cb6b).
* 2. Legacy webcache-indexed cache: cache/content/ holds dldata_s.info and signed
* downloadable_decals.<hash>.blk directly; char.vromfs.bin omits dldata/ so the client reads
* the cached index from cache/content/.
*/
import { cpSync, existsSync, lstatSync, readdirSync, realpathSync, statSync } from 'node:fs';
import { dirname, isAbsolute, join, relative, sep } from 'node:path';
import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path';
import { decodeBlk, emptyBlock, encodeBlk, parseSharedNameMap } from '@wto/blk';
import { getFile, NAME_MAP_PATH, readArchive } from '@wto/vromfs';
import type { AddedFile } from '../pack-edit.ts';
import { compareVersions } from '../version-record.ts';
import { DECALS_INDEX_PATH, SKINS_INDEX_PATH } from './offline-decal-index.ts';
export const WEB_CACHE_FOLDER = join('cache', 'content');
const INDEX_LIST_FILE = 'dldata_s.info';
const DECALS_INDEX_FILE = /^downloadable_decals\.[a-z2-7]{32}-[a-z2-7]{1,8}\.blk$/;
const BINARY_CACHE_DIR = /^binary\.(.+)$/;
const REGIONAL_PACK_NAME = 'regional.vromfs.bin';
const SNAPSHOT_INDEX_DIR = '.wto-index';
const SNAPSHOT_DECALS_FILE = 'downloadable_decals.blk';
const SNAPSHOT_SKINS_FILE = 'downloadable_skins.blk';
export interface PlayerDecalCache {
readonly copiedTo: string;
readonly decalIndexes: readonly string[];
}
/**
* Resolve the actual cache/content folder when the player selects either <game>/cache/content
* or its parent <game>/cache folder.
*/
export function resolvePlayerDecalCacheFolder(source: string): string {
if (!existsSync(source) || !statSync(source).isDirectory()) return source;
if (directDecalCacheProblem(source) === undefined) return source;
const nested = join(source, 'content');
if (existsSync(nested) && statSync(nested).isDirectory() && directDecalCacheProblem(nested) === undefined) {
return nested;
}
return source;
}
/** Check that the folder looks like an online client's web cache; returns the problem or undefined. */
export function playerDecalCacheProblem(source: string): string | undefined {
if (!existsSync(source) || !statSync(source).isDirectory()) return `${source} is not a folder`;
if (!statSync(join(source, INDEX_LIST_FILE), { throwIfNoEntry: false })?.isFile()) return `${source} has no ${INDEX_LIST_FILE} (expected the cache/content folder of an online installation)`;
if (decalIndexes(source).length === 0) return `${source} has no downloadable_decals.<hash>.blk`;
return undefined;
const resolved = resolvePlayerDecalCacheFolder(source);
return directDecalCacheProblem(resolved);
}
/**
* Read real dldata/downloadable_decals.blk and dldata/downloadable_skins.blk for embedding into
* char.vromfs.bin when the cache uses either an imported snapshot index or a sibling
* binary.<ver>/regional.vromfs.bin. Returns undefined for legacy downloadable_decals.<hash>.blk
* caches, which supply their index directly inside cache/content/.
*/
export function readPlayerDecalIndexFiles(source: string): readonly AddedFile[] | undefined {
const folder = resolvePlayerDecalCacheFolder(source);
const snapshot = readSnapshotIndexFiles(folder);
if (snapshot) return snapshot;
if (decalIndexes(folder).length > 0) return undefined;
const regional = findRegionalPack(folder);
if (!regional) return undefined;
return extractRegionalIndexFiles(regional);
}
/**
* Persist extracted vromfs decal/skin indexes into an imported cache snapshot so subsequent
* launches are completely self-contained and never touch the online client directory.
*/
export function writeDecalCacheIndexSnapshot(source: string, target: string): void {
const files = readPlayerDecalIndexFiles(source);
if (!files) return;
const indexDir = join(target, SNAPSHOT_INDEX_DIR);
mkdirSync(indexDir, { recursive: true });
for (const file of files) {
const fileName = file.path === DECALS_INDEX_PATH ? SNAPSHOT_DECALS_FILE : SNAPSHOT_SKINS_FILE;
writeFileSync(join(indexDir, fileName), file.content);
}
}
/** Copy the player's web cache folder into <copy>/cache/content; the source is only read. */
export function copyPlayerDecalCache(source: string, copyFolder: string): PlayerDecalCache {
const from = realpathSync(source);
const from = realpathSync(resolvePlayerDecalCacheFolder(source));
const target = join(realpathSync(copyFolder), WEB_CACHE_FOLDER);
if (contains(from, target) || contains(target, from)) {
throw new Error('The decal source and game copy cache overlap.');
@@ -49,10 +100,12 @@ export function copyPlayerDecalCache(source: string, copyFolder: string): Player
if (lstatSync(dirname(target), { throwIfNoEntry: false })?.isSymbolicLink()) {
throw new Error('The game cache folder is redirected.');
}
const snapshotDir = join(from, SNAPSHOT_INDEX_DIR);
cpSync(from, target, {
recursive: true,
force: true,
filter: (input, output) => {
if (input === snapshotDir || input.startsWith(snapshotDir + sep)) return false;
const entry = lstatSync(input);
const existing = lstatSync(output, { throwIfNoEntry: false });
if ((!entry.isFile() && !entry.isDirectory()) || existing?.isSymbolicLink() ||
@@ -62,7 +115,94 @@ export function copyPlayerDecalCache(source: string, copyFolder: string): Player
return true;
},
});
return { copiedTo: target, decalIndexes: decalIndexes(from) };
const legacy = decalIndexes(from);
const indexLabels = legacy.length > 0
? legacy
: (readSnapshotIndexFiles(from) || findRegionalPack(from) ? [DECALS_INDEX_PATH, SKINS_INDEX_PATH] : []);
return { copiedTo: target, decalIndexes: indexLabels };
}
function directDecalCacheProblem(folder: string): string | undefined {
if (!existsSync(folder) || !statSync(folder).isDirectory()) return `${folder} is not a folder`;
if (readSnapshotIndexFiles(folder)) return undefined;
if (statSync(join(folder, INDEX_LIST_FILE), { throwIfNoEntry: false })?.isFile() && decalIndexes(folder).length > 0) {
return undefined;
}
const hasTextures = hasCachedDdsxTextures(folder);
const regional = findRegionalPack(folder);
if (hasTextures && regional) return undefined;
if (!hasTextures && !regional) {
return `${folder} has neither cached .ddsx textures nor downloadable_decals.<hash>.blk (log into the online hangar once to populate cache/content)`;
}
if (!hasTextures) {
return `${folder} has no cached .ddsx textures yet (log into the online hangar once to cache decals or skins)`;
}
return `${folder} has no downloadable_decals.<hash>.blk and no sibling binary.*/${REGIONAL_PACK_NAME}`;
}
function readSnapshotIndexFiles(folder: string): readonly AddedFile[] | undefined {
const decalsPath = join(folder, SNAPSHOT_INDEX_DIR, SNAPSHOT_DECALS_FILE);
if (!statSync(decalsPath, { throwIfNoEntry: false })?.isFile()) return undefined;
const skinsPath = join(folder, SNAPSHOT_INDEX_DIR, SNAPSHOT_SKINS_FILE);
const skinsContent = statSync(skinsPath, { throwIfNoEntry: false })?.isFile()
? readFileSync(skinsPath)
: encodeBlk(emptyBlock());
return [
{ path: SKINS_INDEX_PATH, content: skinsContent },
{ path: DECALS_INDEX_PATH, content: readFileSync(decalsPath) },
];
}
function hasCachedDdsxTextures(folder: string): boolean {
for (const entry of readdirSync(folder, { withFileTypes: true })) {
if (!entry.isDirectory() || entry.name === SNAPSHOT_INDEX_DIR) continue;
const sub = join(folder, entry.name);
for (const child of readdirSync(sub, { withFileTypes: true })) {
if (child.isFile() && child.name.endsWith('.ddsx')) return true;
}
}
return false;
}
function findRegionalPack(contentFolder: string): string | undefined {
const parent = dirname(contentFolder);
if (parent === contentFolder || !existsSync(parent)) return undefined;
const candidates: Array<{ readonly path: string; readonly version: string; readonly mtimeMs: number }> = [];
for (const entry of readdirSync(parent, { withFileTypes: true })) {
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
const match = BINARY_CACHE_DIR.exec(entry.name);
if (!match) continue;
const packPath = join(parent, entry.name, REGIONAL_PACK_NAME);
const stat = lstatSync(packPath, { throwIfNoEntry: false });
if (!stat || !stat.isFile() || stat.isSymbolicLink()) continue;
candidates.push({ path: packPath, version: match[1]!, mtimeMs: stat.mtimeMs });
}
candidates.sort((a, b) => compareVersions(b.version, a.version) || b.mtimeMs - a.mtimeMs || basename(b.path).localeCompare(basename(a.path)));
for (const candidate of candidates) {
try {
const archive = readArchive(readFileSync(candidate.path));
if (archive.files.has(DECALS_INDEX_PATH)) return candidate.path;
} catch {
// Skip unreadable or partially written regional packs and try older ones.
}
}
return undefined;
}
function extractRegionalIndexFiles(regionalPackPath: string): readonly AddedFile[] {
const archive = readArchive(readFileSync(regionalPackPath));
const dictionaries = [...archive.files.keys()].filter((path) => path.endsWith('.dict'));
const dictionary = dictionaries.length === 1 ? archive.files.get(dictionaries[0]!) : undefined;
const names = archive.files.has(NAME_MAP_PATH) ? parseSharedNameMap(getFile(archive, NAME_MAP_PATH), dictionary).names : [];
const shared = { names, dictionary };
const decalsBlk = decodeBlk(getFile(archive, DECALS_INDEX_PATH), shared);
const skinsBlk = archive.files.has(SKINS_INDEX_PATH)
? decodeBlk(getFile(archive, SKINS_INDEX_PATH), shared)
: emptyBlock();
return [
{ path: SKINS_INDEX_PATH, content: encodeBlk(skinsBlk) },
{ path: DECALS_INDEX_PATH, content: encodeBlk(decalsBlk) },
];
}
function contains(parent: string, child: string): boolean {
+7 -1
View File
@@ -13,7 +13,13 @@ export {
type StockGameFiles,
} from './build-game-copy.ts';
export { NETWORK_CONFIG_PATH, rebuildCharPack, type CharPackResult } from './char-pack.ts';
export { copyPlayerDecalCache, playerDecalCacheProblem } from './decals/player-decal-cache.ts';
export {
copyPlayerDecalCache,
playerDecalCacheProblem,
readPlayerDecalIndexFiles,
resolvePlayerDecalCacheFolder,
writeDecalCacheIndexSnapshot,
} from './decals/player-decal-cache.ts';
export { blockingFailures, ESSENTIAL_FEATURES } from './essential-features.ts';
export { patchExecutable, type ExecutableResult } from './executable.ts';
export { assertWritableCopy, GAME_FILES, isInSteamLibrary, type WritableCopyOptions } from './game-copy.ts';
+3
View File
@@ -30,6 +30,7 @@ import {
copyPlayerDecalCache,
NETWORK_HOOK_LIBRARY,
playerDecalCacheProblem,
readPlayerDecalIndexFiles,
readStockGameFiles,
writeGameCopy,
type GameCopyBuild,
@@ -72,6 +73,7 @@ function main(): number {
return 1;
}
const decalIndexFiles = decalCache === undefined ? undefined : readPlayerDecalIndexFiles(decalCache);
const build = buildGameCopy({
stock: readStockGameFiles(values.game),
port: Number(values.port),
@@ -79,6 +81,7 @@ function main(): number {
networkHookLibrary: readFileSync(hookLibraryPath),
multiVehiclePackIds: multiVehiclePackIds(values.data, (line) => console.log(line)),
placeholderDecals: decalCache === undefined,
...(decalIndexFiles ? { decalIndexFiles } : {}),
});
report(build, values.verbose);