fix(launcher): skip and guard incomplete optional UHQ texture packs

Detect optional UHQ texture packs whose content/pkg_uhq_*.rq2 lacks a matching .ver file (PACKAGE_STATUS_REQUESTED) or whose grp_hdr.vromfs.bin has no .dxp.bin files.

planCopy now skips incomplete UHQ packs during copy installs and incremental updates (cleaning previously copied incomplete files on update), and planLaunch refuses to launch clients containing incomplete UHQ headers with a localized error instead of letting aces.exe crash with fatal error 81110007.

Verified with root and launcher typecheck, electron-vite build, en/zh-CN locale key parity (905/905), and a temp-folder runnable check.
This commit is contained in:
N0VAN0M4LY committed 2026-12-04 03:42:49 +08:00
1 parent 428b2d3601
commit 480496ca93
8 files changed
+134 -5

No files matched your search

@@ -5,6 +5,7 @@ import { pipeline } from 'node:stream/promises';
import { AppError } from '@shared/errors.ts';
import { rawFs } from '../../util/raw-fs.ts';
import { linkVerifiedResource, sameResource } from './hardlink-files.ts';
import { findIncompleteUhqPacks, isPathInUhqPacks } from './uhq-packages.ts';
/**
* Copy a War Thunder installation into a new or empty folder (install method "copy"). The stock
@@ -72,6 +73,11 @@ export interface CopyProgress {
/** Every file and folder to copy, relative to `source`. Links and junctions are not followed. */
export async function planCopy(source: string): Promise<CopyPlan> {
const fsPromises = rawFs().promises;
const incompleteUhq = await findIncompleteUhqPacks(source);
const skippedUhq = new Set(incompleteUhq);
if (incompleteUhq.length > 0) {
console.warn(`[install] skipping incomplete optional UHQ pack(s) in ${source}: ${incompleteUhq.join(', ')}`);
}
const files: CopyEntry[] = [];
const folders: string[] = [];
let totalBytes = 0;
@@ -87,11 +93,13 @@ export async function planCopy(source: string): Promise<CopyPlan> {
for (const entry of entries) {
const path = join(folder, entry.name);
if (folder === source && isInSkippedSourceFolder(entry.name)) continue;
const relPath = relative(source, path);
if (isPathInUhqPacks(relPath, skippedUhq)) continue;
if (entry.isDirectory()) {
pending.push(path);
} else if (entry.isFile()) {
const { size, mtimeMs } = await fsPromises.lstat(path);
files.push({ relativePath: relative(source, path), bytes: size, modifiedAt: mtimeMs });
files.push({ relativePath: relPath, bytes: size, modifiedAt: mtimeMs });
totalBytes += size;
}
}
@@ -0,0 +1,104 @@
import { join, normalize } from 'node:path';
import { rawFs } from '../../util/raw-fs.ts';
/**
* Detection of incomplete optional UHQ texture packs (`uhq_vehicles`, `uhq_aircraft`,
* `uhq_environment`, etc.) inside a War Thunder folder.
*
* War Thunder writes `content/pkg_<name>.rq2` when an optional pack is requested and only writes
* `content/pkg_<name>.ver` once its download finishes (`PACKAGE_STATUS_OK`). However, at startup
* `aces.exe` mounts `content.hq/<name>/res/grp_hdr.vromfs.bin` without requiring the `.ver` file,
* registering every `.dxp.bin` listed in the header and crashing later with fatal error 81110007
* (`Can't open TexPack`) if any texture pack is missing.
*/
const UHQ_PACK_PATTERN = /^uhq_[a-z0-9_]+$/i;
const UHQ_RQ2_PATTERN = /^pkg_(uhq_[a-z0-9_]+)\.rq2$/i;
const UHQ_VER_PATTERN = /^pkg_(uhq_[a-z0-9_]+)\.ver$/i;
export interface IncompleteUhqPack {
readonly name: string;
readonly hasHeader: boolean;
}
/**
* Inspects `root` for optional UHQ packs that are incomplete:
* - `content/pkg_<name>.rq2` exists without `content/pkg_<name>.ver` (`PACKAGE_STATUS_REQUESTED`), or
* - `content.hq/<name>/res/grp_hdr.vromfs.bin` exists with no `.dxp.bin` texture packs beside it.
*/
export async function inspectIncompleteUhqPacks(root: string): Promise<IncompleteUhqPack[]> {
const rq2Packs = new Set<string>();
const verPacks = new Set<string>();
const candidates = new Set<string>();
for (const name of await readDirNames(join(root, 'content'))) {
const rq2 = UHQ_RQ2_PATTERN.exec(name);
if (rq2) {
const pack = rq2[1]!.toLowerCase();
rq2Packs.add(pack);
candidates.add(pack);
continue;
}
const ver = UHQ_VER_PATTERN.exec(name);
if (ver) verPacks.add(ver[1]!.toLowerCase());
}
for (const name of await readDirNames(join(root, 'content.hq'))) {
if (UHQ_PACK_PATTERN.test(name)) candidates.add(name.toLowerCase());
}
const incomplete: IncompleteUhqPack[] = [];
for (const pack of [...candidates].sort()) {
const resDir = join(root, 'content.hq', pack, 'res');
const resFiles = await readDirNames(resDir);
const hasHeader = resFiles.some((file) => file.toLowerCase() === 'grp_hdr.vromfs.bin');
const hasDxp = resFiles.some((file) => file.toLowerCase().endsWith('.dxp.bin'));
const requestedWithoutVer = rq2Packs.has(pack) && !verPacks.has(pack);
const emptyHeaderOnly = hasHeader && !hasDxp;
if (requestedWithoutVer || emptyHeaderOnly) {
incomplete.push({ name: pack, hasHeader });
}
}
return incomplete;
}
/** Names of all incomplete optional UHQ packs in `root`. */
export async function findIncompleteUhqPacks(root: string): Promise<string[]> {
return (await inspectIncompleteUhqPacks(root)).map((pack) => pack.name);
}
/**
* Names of incomplete optional UHQ packs in `root` whose `grp_hdr.vromfs.bin` is present,
* which causes `aces.exe` to mount the pack and fail with 81110007 when streaming textures.
*/
export async function findBlockingIncompleteUhqPacks(root: string): Promise<string[]> {
return (await inspectIncompleteUhqPacks(root))
.filter((pack) => pack.hasHeader)
.map((pack) => pack.name);
}
/**
* Whether `relativePath` (relative to the War Thunder root) belongs to any UHQ pack in `packs`:
* `content.hq/<pack>/...`, `patch/content.hq/<pack>/...`, or `content/pkg_<pack>.rq2`.
*/
export function isPathInUhqPacks(relativePath: string, packs: ReadonlySet<string>): boolean {
if (packs.size === 0) return false;
const parts = normalize(relativePath).replace(/\\/g, '/').toLowerCase().split('/').filter(Boolean);
if (parts.length >= 2 && parts[0] === 'content.hq') return packs.has(parts[1]!);
if (parts.length >= 3 && parts[0] === 'patch' && parts[1] === 'content.hq') return packs.has(parts[2]!);
if (parts.length === 2 && parts[0] === 'content') {
const rq2 = UHQ_RQ2_PATTERN.exec(parts[1]!);
return rq2 !== null && packs.has(rq2[1]!);
}
return false;
}
async function readDirNames(folder: string): Promise<string[]> {
try {
const fsPromises = rawFs().promises;
await fsPromises.access(folder);
return await fsPromises.readdir(folder);
} catch {
return [];
}
}
@@ -11,6 +11,7 @@ import type { Settings } from '@shared/schemas/settings.ts';
import { getSettings } from '../config/settings-store.ts';
import { decalCachePath } from '../install/decals.ts';
import { canonicalCopyPath, copyPathContains, readInstallRecord } from '../install/install-record.ts';
import { findBlockingIncompleteUhqPacks } from '../install/uhq-packages.ts';
import { resolveEnabledModsForLaunch } from '../mods/mods-service.ts';
import { resourcePaths } from '../resources/resource-paths.ts';
import { saveBackup } from '../saves/save-archive.ts';
@@ -68,9 +69,13 @@ export function startLaunch(report: LaunchJob['report']): LaunchState {
case 'launch_server_exited':
update(job, { phase: 'server-exited', ...context });
break;
default:
update(job, { phase: 'failed', error: code, ...context });
default: {
const errorParams = error instanceof AppError && Object.keys(error.params).length > 0
? { errorParams: { ...error.params } }
: {};
update(job, { phase: 'failed', error: code, ...errorParams, ...context });
break;
}
}
}).finally(() => {
if (active === job) active = null;
@@ -194,6 +199,11 @@ async function planLaunch(job: LaunchJob, record: InstallRecord, settings: Setti
throw new AppError(lab ? 'launch_lab_version' : 'launch_stock_version');
}
if (games) throw new AppError('launch_game_running');
const incompleteUhq = await findBlockingIncompleteUhqPacks(copyPath);
if (incompleteUhq.length > 0) {
console.warn(`[launch] incomplete optional UHQ pack(s) detected in ${copyPath}: ${incompleteUhq.join(', ')}`);
throw new AppError('launch_incomplete_uhq_packs', { packs: incompleteUhq.join(', ') });
}
const { modsDir, enabledMods } = await resolveEnabledModsForLaunch(dataPath, copyVersion);
const enabledModIds = enabledMods.map((mod) => mod.manifest.id);
const port = await selectPort(requestedPort);
@@ -1067,6 +1067,7 @@
"launch_server_exited": "The local server is unavailable.",
"launch_game_failed": "The game process could not start. See the launcher log.",
"launch_game_files_missing": "Required game launch files are missing or unreadable (they may have been quarantined by antivirus software). Check your security software and the launcher log.",
"launch_incomplete_uhq_packs": "This client contains incomplete optional UHQ texture pack(s) ({{packs}}), which causes a texture read crash (81110007). Verify or finish downloading the DLC in Steam or the official launcher and update the offline client, or remove the incomplete content.hq/<pack> folder and content/pkg_<pack>.rq2 from the offline client.",
"settings_write_failed": "The settings could not be saved.",
"folder_unreadable": "The folder cannot be read: {{path}}",
"not_a_game_folder": "The selected folder is not a War Thunder installation: {{path}}",
@@ -1067,6 +1067,7 @@
"launch_server_exited": "本地服务器不可用。",
"launch_game_failed": "游戏进程无法启动。请查看启动器日志。",
"launch_game_files_missing": "启动所需的核心文件缺失或无法访问(可能已被安全软件隔离)。请检查安全软件拦截记录或查看启动器日志。",
"launch_incomplete_uhq_packs": "客户端包含未下载完整的高清材质包({{packs}}),直接启动会导致贴图读取报错(81110007)。请在 Steam 或官方启动器验证并补完文件后再更新离线客户端,或手动移除离线目录内对应的 content.hq/<包名> 与 content/pkg_<包名>.rq2。",
"settings_write_failed": "无法保存设置。",
"folder_unreadable": "无法读取文件夹:{{path}}",
"not_a_game_folder": "所选文件夹不是战争雷霆的安装文件夹:{{path}}",
@@ -80,8 +80,10 @@ export function homeBar(
detail: t('launch.versionDetail', { version: state.actualVersion ?? t('source.versionUnknown') }),
primary: { label: t('launch.check'), onClick: actions.checkVersion },
};
case 'failed':
return { tone: 'bad', title: t(`errors.${state.error ?? 'launch_failed'}`), primary: retry };
case 'failed': {
const key = `errors.${state.error ?? 'launch_failed'}` as const;
return { tone: 'bad', title: state.errorParams ? t(key, state.errorParams) : t(key), primary: retry };
}
case 'ready':
break;
}
+2
View File
@@ -76,6 +76,8 @@ export const APP_ERROR_CODES = [
'launch_game_failed',
/** Core files built for the launch (aces.exe, wto_ws.dll, wto_ws.cfg) are missing or unreadable. */
'launch_game_files_missing',
/** Optional UHQ texture packs have a mounted header without completed files (params: packs). */
'launch_incomplete_uhq_packs',
/** A folder the player chose does not exist or cannot be read (params: path). */
'folder_unreadable',
/** The chosen folder lacks the files of a War Thunder installation (params: path). */
@@ -28,6 +28,7 @@ export const LaunchStateSchema = z.object({
actualVersion: z.string().nullable().optional(),
gameExit: GameExitSchema.optional(),
error: z.enum(APP_ERROR_CODES).optional(),
errorParams: z.record(z.string(), z.union([z.string(), z.number()])).optional(),
});
export type LaunchState = z.output<typeof LaunchStateSchema>;