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:
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);
|
||||
|
||||
Reference in new issue
Block a user