Snapshot unreviewed LocalMP battle work as rework baseline
Records the uncommitted battle-session work exactly as it was left (local service matchmaking, settlement, chat, native LocalMP hooks, battle gui/exe patches) so the following review and rework commits show every correction as a diff against this state. This commit is not reviewed and is known to be incomplete: in-game testing reported wrong settlement rewards, single-country teams, missing random/fixed supplement slots, misattributed hit messages and other regressions. Do not merge this branch before the rework lands.
This commit is contained in:
1 parent
aa272fc82b
commit
6a189513b0
97 files changed
+7676
-396
No files matched your search
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* Dataset: Ground RB special spawn aircraft (`missionSupportPlane` nuclear bombers and
|
||||
* `ucav_*_killstreak` strike UCAVs) and `RandomSpawnUnits` auto-supplemented vehicle pools.
|
||||
*
|
||||
* aces.vromfs.bin config/gameplay.blk
|
||||
* missionSupportPlane{ tank_event_in_random_battles_historical{ UnitPreset{ ... } } }
|
||||
* RandomSpawnUnits{ <eventName>{ <country>{ <group>{ minPlayerMRank:i ... <unit>{ ... } } } } }
|
||||
* char.vromfs.bin config/wpcost.blk
|
||||
* <unit>_killstreak{ country:t economicRankHistorical:i economicRankTankHistorical:i weapons{ ... } }
|
||||
*/
|
||||
import { findBlock, findParam, type BlkBlock } from '@wto/blk';
|
||||
import { numberField, stringField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
export interface NuclearAircraftEntry {
|
||||
readonly country: string;
|
||||
readonly unitName: string;
|
||||
readonly weapon: string;
|
||||
readonly tankRealisticMrank: number;
|
||||
}
|
||||
|
||||
export interface NuclearPresetBracket {
|
||||
readonly minMrank: number;
|
||||
readonly maxMrank: number;
|
||||
readonly spawnScore: number;
|
||||
readonly entries: readonly NuclearAircraftEntry[];
|
||||
}
|
||||
|
||||
export interface StrikeUcavEntry {
|
||||
readonly country: string;
|
||||
readonly unitName: string;
|
||||
readonly weapon: string;
|
||||
readonly historicalMrank: number;
|
||||
}
|
||||
|
||||
export interface RandomSpawnCandidate {
|
||||
readonly unitName: string;
|
||||
readonly forceWeapon?: string;
|
||||
}
|
||||
|
||||
export interface RandomSpawnGroupRule {
|
||||
readonly groupName: string;
|
||||
readonly minPlayerMRank: number;
|
||||
readonly maxDiffBetweenTopUnitAndSessionRank: number;
|
||||
readonly mRanksCount: number;
|
||||
readonly units: readonly RandomSpawnCandidate[];
|
||||
}
|
||||
|
||||
export interface RandomSpawnEventRule {
|
||||
readonly eventName: string;
|
||||
readonly countries: Readonly<Record<string, readonly RandomSpawnGroupRule[]>>;
|
||||
}
|
||||
|
||||
export interface BattleSpawnRulesData {
|
||||
readonly nuclearBrackets: readonly NuclearPresetBracket[];
|
||||
readonly strikeUcavs: readonly StrikeUcavEntry[];
|
||||
readonly randomSpawnEvents: readonly RandomSpawnEventRule[];
|
||||
}
|
||||
|
||||
const STRIKE_UCAV_PATTERN = /^ucav_.*_killstreak$/;
|
||||
|
||||
export const battleSpawnRules: Dataset<BattleSpawnRulesData> = {
|
||||
id: 'battle-spawn-rules',
|
||||
version: 1,
|
||||
extract: (source) => {
|
||||
const gameplay = source.readBlk('aces.vromfs.bin', 'config/gameplay.blk');
|
||||
const wpcost = source.readBlk('char.vromfs.bin', 'config/wpcost.blk');
|
||||
const wpcostByUnit = new Map(wpcost.blocks.map((block) => [block.name, block]));
|
||||
return {
|
||||
nuclearBrackets: extractNuclearBrackets(gameplay, wpcostByUnit),
|
||||
strikeUcavs: extractStrikeUcavs(wpcost.blocks),
|
||||
randomSpawnEvents: extractRandomSpawnEvents(gameplay),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
function extractNuclearBrackets(
|
||||
gameplay: BlkBlock,
|
||||
wpcostByUnit: ReadonlyMap<string, BlkBlock>,
|
||||
): NuclearPresetBracket[] {
|
||||
const msp = findBlock(gameplay, 'missionSupportPlane');
|
||||
const tankRb = msp && findBlock(msp, 'tank_event_in_random_battles_historical');
|
||||
if (!tankRb) return [];
|
||||
|
||||
const brackets: NuclearPresetBracket[] = [];
|
||||
for (const preset of tankRb.blocks) {
|
||||
if (preset.name !== 'UnitPreset') continue;
|
||||
if (stringField(preset, 'killStreakTagName') !== 'bomber_nuclear') continue;
|
||||
const range = ipoint2Field(preset, 'rankRange');
|
||||
const spawnScore = numberField(preset, 'spawnScoreToUse');
|
||||
if (!range || spawnScore === undefined || spawnScore <= 0) continue;
|
||||
|
||||
const entries: NuclearAircraftEntry[] = [];
|
||||
for (const countryBlk of preset.blocks) {
|
||||
if (!countryBlk.name.startsWith('country_')) continue;
|
||||
const unitName = stringField(countryBlk, 'unitName') ?? '';
|
||||
const weapon = stringField(countryBlk, 'weapon') ?? '';
|
||||
if (!unitName || !weapon) continue;
|
||||
const costBlk = wpcostByUnit.get(unitName);
|
||||
const tankRealisticMrank = (costBlk && (
|
||||
numberField(costBlk, 'economicRankTankHistorical')
|
||||
?? numberField(costBlk, 'economicRankHistorical')
|
||||
?? numberField(costBlk, 'economicRank')
|
||||
)) ?? range[0];
|
||||
entries.push({ country: countryBlk.name, unitName, weapon, tankRealisticMrank });
|
||||
}
|
||||
if (entries.length > 0) {
|
||||
brackets.push({ minMrank: range[0], maxMrank: range[1], spawnScore, entries });
|
||||
}
|
||||
}
|
||||
return brackets.sort((a, b) => a.minMrank - b.minMrank);
|
||||
}
|
||||
|
||||
function extractStrikeUcavs(wpcostBlocks: readonly BlkBlock[]): StrikeUcavEntry[] {
|
||||
const entries: StrikeUcavEntry[] = [];
|
||||
for (const unitBlk of wpcostBlocks) {
|
||||
if (!STRIKE_UCAV_PATTERN.test(unitBlk.name)) continue;
|
||||
const country = stringField(unitBlk, 'country') ?? '';
|
||||
if (!country.startsWith('country_')) continue;
|
||||
const historicalMrank = numberField(unitBlk, 'economicRankTankHistorical')
|
||||
?? numberField(unitBlk, 'economicRankHistorical')
|
||||
?? numberField(unitBlk, 'economicRank')
|
||||
?? 0;
|
||||
const weapon = pickArmedUcavWeapon(unitBlk);
|
||||
entries.push({ country, unitName: unitBlk.name, weapon, historicalMrank });
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
function pickArmedUcavWeapon(unitBlk: BlkBlock): string {
|
||||
const weaponsBlk = findBlock(unitBlk, 'weapons');
|
||||
const presets = (weaponsBlk?.blocks ?? []).filter((b) =>
|
||||
b.name !== 'custom_presets'
|
||||
&& !b.name.startsWith('bombguns_')
|
||||
&& !b.name.startsWith('containers_')
|
||||
&& !b.name.startsWith('rocketguns_'));
|
||||
const armed = presets.find((preset) =>
|
||||
(numberField(preset, 'atgmMaxDistance') ?? 0) > 0
|
||||
|| (numberField(preset, 'totalBombRocketMass') ?? 0) > 0
|
||||
|| (numberField(preset, 'totalGuidedBombMass') ?? 0) > 0);
|
||||
return armed?.name ?? presets[0]?.name ?? '';
|
||||
}
|
||||
|
||||
function extractRandomSpawnEvents(gameplay: BlkBlock): RandomSpawnEventRule[] {
|
||||
const root = findBlock(gameplay, 'RandomSpawnUnits');
|
||||
if (!root) return [];
|
||||
const events: RandomSpawnEventRule[] = [];
|
||||
for (const eventBlk of root.blocks) {
|
||||
const countries: Record<string, RandomSpawnGroupRule[]> = {};
|
||||
for (const countryBlk of eventBlk.blocks) {
|
||||
if (!countryBlk.name.startsWith('country_')) continue;
|
||||
const groups: RandomSpawnGroupRule[] = [];
|
||||
for (const groupBlk of countryBlk.blocks) {
|
||||
const minPlayerMRank = numberField(groupBlk, 'minPlayerMRank') ?? 0;
|
||||
const maxDiff = numberField(groupBlk, 'maxDiffBetweenTopUnitAndSessionRank') ?? 0;
|
||||
const mRanksCount = numberField(groupBlk, 'mRanksCount') ?? 0;
|
||||
const units: RandomSpawnCandidate[] = groupBlk.blocks
|
||||
.filter((u) => u.name.length > 0)
|
||||
.map((u) => {
|
||||
const forceWeapon = stringField(u, 'forceWeapon');
|
||||
return forceWeapon ? { unitName: u.name, forceWeapon } : { unitName: u.name };
|
||||
});
|
||||
if (units.length > 0) {
|
||||
groups.push({
|
||||
groupName: groupBlk.name,
|
||||
minPlayerMRank,
|
||||
maxDiffBetweenTopUnitAndSessionRank: maxDiff,
|
||||
mRanksCount,
|
||||
units,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (groups.length > 0) countries[countryBlk.name] = groups;
|
||||
}
|
||||
events.push({ eventName: eventBlk.name, countries });
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
function ipoint2Field(block: BlkBlock, name: string): readonly [number, number] | undefined {
|
||||
const value = findParam(block, name)?.value;
|
||||
if (value?.type === 'ipoint2') return value.value;
|
||||
return undefined;
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
/**
|
||||
* Dataset: crew skills, skill point packs and per-vehicle crew training prices
|
||||
*.
|
||||
* Dataset: crew skills, skill point packs, per-vehicle crew training prices, and
|
||||
* Expert-to-Ace Golden Eagles discount stages.
|
||||
*
|
||||
* char.vromfs.bin config/crew_skills.blk
|
||||
* crew_skills{ <page>{ type:t <skill>{ skill_level_exp{ level1:i ... levelN:i } } } }
|
||||
* levelN is the skill point cost of level N (the scripts add them up into costTbl).
|
||||
* char.vromfs.bin config/warpoints.blk
|
||||
* crewSkillPointsCost{ <pack>{ costGold:i crewExp:i } }
|
||||
* expert_to_ace_cost_reduce{ stage{ percent:i discount:i } }
|
||||
* char.vromfs.bin config/wpcost.blk, per vehicle
|
||||
* trainCost:i (training a crew, silver lions), train2Cost:i (expert, silver lions),
|
||||
* train3Cost_gold:i (ace, golden eagles)
|
||||
* train3Cost_gold:i (ace, golden eagles), train3Cost_exp:i (free ace RP threshold)
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import { findBlock } from '@wto/blk';
|
||||
@@ -34,33 +35,48 @@ export interface SkillPointPack {
|
||||
readonly points: number;
|
||||
}
|
||||
|
||||
export interface AceDiscountStage {
|
||||
readonly percent: number;
|
||||
readonly discount: number;
|
||||
}
|
||||
|
||||
export interface CrewTrainingPrices {
|
||||
readonly vehicle: string;
|
||||
readonly training: number;
|
||||
readonly expert: number;
|
||||
readonly aceGoldenEagles: number;
|
||||
readonly aceResearchPoints: number;
|
||||
}
|
||||
|
||||
export interface CrewSkillData {
|
||||
readonly pages: readonly SkillPage[];
|
||||
readonly packs: readonly SkillPointPack[];
|
||||
readonly aceDiscountStages: readonly AceDiscountStage[];
|
||||
readonly training: readonly CrewTrainingPrices[];
|
||||
}
|
||||
|
||||
export const crewSkillData: Dataset<CrewSkillData> = {
|
||||
id: 'crew-skills',
|
||||
version: 1,
|
||||
version: 2,
|
||||
extract: (source) => {
|
||||
const skills = findBlock(source.readBlk('char.vromfs.bin', 'config/crew_skills.blk'), 'crew_skills');
|
||||
const packs = findBlock(source.readBlk('char.vromfs.bin', 'config/warpoints.blk'), 'crewSkillPointsCost');
|
||||
const warpoints = source.readBlk('char.vromfs.bin', 'config/warpoints.blk');
|
||||
const packs = findBlock(warpoints, 'crewSkillPointsCost');
|
||||
const aceReduce = findBlock(warpoints, 'expert_to_ace_cost_reduce');
|
||||
return {
|
||||
pages: (skills?.blocks ?? []).map(pageOf),
|
||||
packs: (packs?.blocks ?? []).map((pack) => ({ name: pack.name, goldenEagles: numberField(pack, 'costGold') ?? 0, points: numberField(pack, 'crewExp') ?? 0 })),
|
||||
aceDiscountStages: (aceReduce?.blocks ?? [])
|
||||
.filter((stage) => stage.name === 'stage')
|
||||
.map((stage) => ({ percent: numberField(stage, 'percent') ?? 0, discount: numberField(stage, 'discount') ?? 0 }))
|
||||
.filter((stage) => stage.percent > 0 && stage.discount > 0)
|
||||
.sort((a, b) => a.percent - b.percent),
|
||||
training: source.readBlk('char.vromfs.bin', 'config/wpcost.blk').blocks.map((vehicle) => ({
|
||||
vehicle: vehicle.name,
|
||||
training: numberField(vehicle, 'trainCost') ?? 0,
|
||||
expert: numberField(vehicle, 'train2Cost') ?? 0,
|
||||
aceGoldenEagles: numberField(vehicle, 'train3Cost_gold') ?? 0,
|
||||
aceResearchPoints: numberField(vehicle, 'train3Cost_exp') ?? 0,
|
||||
})),
|
||||
};
|
||||
},
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* Dataset and local DXP2 scanner for Hangar and Marketplace decals.
|
||||
*
|
||||
* Why this exists:
|
||||
* - char.vromfs.bin config/decals.blk lists all stock and marketplace decals (1,598 blocks)
|
||||
* with category, group, costGold, unlock, marketplaceItemdefId, and aspect_ratio, but omits
|
||||
* lod0 / lod1 texture fields because the online client merges downloadable_decals.<hash>.blk
|
||||
* into sharedDecalsBlk first (aces.exe 2.61.0.37 0xd41050 -> 0xd47e20 -> 0xd48380).
|
||||
* - In webdlcontent::getDecalsBlk (0xd415d6..0xd4183d), any decal block without a lod0 string
|
||||
* and without a local managed texture "<name>*" (get_managed_texture_id, 0x31aec00) is
|
||||
* deleted from sharedDecalsBlk ("failed to find texture for decal '%s', skipping it").
|
||||
* - Stock client installations only ship built-in decal textures in content/base/res/decals.dxp.bin
|
||||
* (DxP2 v2 pack: lang, panther, star). Extracting the decal list via DatasetCache and scanning
|
||||
* any local *decal*.dxp.bin headers lets DownloadableContentService populate every decal block
|
||||
* with valid lod0/lod1 and 32-byte DDSx headers without outbound CDN requests.
|
||||
*/
|
||||
import { closeSync, existsSync, openSync, readdirSync, readSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { numberField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
const DECALS_CONFIG_PATH = 'config/decals.blk';
|
||||
|
||||
/** DxP2 v2 pack header constants (verified on content/base/res/decals.dxp.bin). */
|
||||
const DXP2_MAGIC = 0x32507844; // "DxP2"
|
||||
const DXP2_VERSION = 2;
|
||||
const DXP2_PREAMBLE_BYTES = 0x10;
|
||||
const DXP2_MAX_HEADER_BYTES = 4 * 1024 * 1024;
|
||||
|
||||
/** Dagor ddsx::Header binary layout constants (32 bytes, verified at aces.exe 0xd49e00). */
|
||||
const DDSX_HEADER_BYTES = 32;
|
||||
const DDSX_MAGIC = 0x78534444; // "DDSx"
|
||||
const DDSX_DXT5_FOURCC = 0x35545844; // "DXT5"
|
||||
const DDSX_COMPRESSION_MASK = 0x0fffffff;
|
||||
const DDSX_UNPACKED_DECAL_FLAGS = 0x00000044;
|
||||
const DDSX_DECAL_QUALITY_WORD = 0x7401;
|
||||
const DXT5_BLOCK_BYTES = 16;
|
||||
|
||||
export interface DecalConfigEntry {
|
||||
readonly name: string;
|
||||
readonly aspectRatio: number;
|
||||
}
|
||||
|
||||
export interface DxpDecalTexture {
|
||||
readonly name: string;
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly aspectRatio: number;
|
||||
/** Base64-encoded 32-byte unpacked ddsx::Header expected in hdr0 / hdr1 (0xd49e00). */
|
||||
readonly ddsxHeaderBase64: string;
|
||||
}
|
||||
|
||||
export const decalTextures: Dataset<readonly DecalConfigEntry[]> = {
|
||||
id: 'decal-textures',
|
||||
version: 1,
|
||||
extract: (source) =>
|
||||
source.readBlk('char.vromfs.bin', DECALS_CONFIG_PATH).blocks.map((entry) => {
|
||||
const ratio = numberField(entry, 'aspect_ratio');
|
||||
return {
|
||||
name: entry.name,
|
||||
aspectRatio: ratio !== undefined && Number.isFinite(ratio) && ratio > 0 ? ratio : 1,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
/** Scan local *decal*.dxp.bin headers inside the game folder, keyed by lowercase texture name. */
|
||||
export function scanLocalDecalDxp(gameFolder?: string): ReadonlyMap<string, DxpDecalTexture> {
|
||||
const found = new Map<string, DxpDecalTexture>();
|
||||
if (!gameFolder || !existsSync(gameFolder)) return found;
|
||||
for (const dxpPath of candidateDecalDxpPaths(gameFolder)) {
|
||||
for (const entry of readDxp2DecalHeaders(dxpPath)) {
|
||||
const key = entry.name.toLowerCase();
|
||||
if (!found.has(key)) found.set(key, entry);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Synthesize a 32-byte Dagor DXT5 ddsx::Header (base64) matching downloadable_decals.blk. */
|
||||
export function makeDdsxDxt5HeaderBase64(width: number, height: number): string {
|
||||
const header = Buffer.alloc(DDSX_HEADER_BYTES);
|
||||
header.writeUInt32LE(DDSX_MAGIC, 0);
|
||||
header.writeUInt32LE(DDSX_DXT5_FOURCC, 4);
|
||||
header.writeUInt32LE(DDSX_UNPACKED_DECAL_FLAGS, 8);
|
||||
header.writeUInt16LE(width, 12);
|
||||
header.writeUInt16LE(height, 14);
|
||||
const { levels, memSize } = dxt5MipChainSize(width, height);
|
||||
header[16] = levels;
|
||||
header.writeUInt16LE(DDSX_DECAL_QUALITY_WORD, 22);
|
||||
header.writeUInt32LE(memSize, 24);
|
||||
return header.toString('base64');
|
||||
}
|
||||
|
||||
function dxt5MipChainSize(width: number, height: number): { readonly levels: number; readonly memSize: number } {
|
||||
let w = Math.max(1, Math.trunc(width));
|
||||
let h = Math.max(1, Math.trunc(height));
|
||||
let levels = 0;
|
||||
let memSize = 0;
|
||||
for (;;) {
|
||||
levels += 1;
|
||||
memSize += Math.max(1, Math.ceil(w / 4)) * Math.max(1, Math.ceil(h / 4)) * DXT5_BLOCK_BYTES;
|
||||
if (w === 1 && h === 1) break;
|
||||
w = Math.max(1, w >> 1);
|
||||
h = Math.max(1, h >> 1);
|
||||
}
|
||||
return { levels, memSize };
|
||||
}
|
||||
|
||||
function candidateDecalDxpPaths(gameFolder: string): string[] {
|
||||
const paths = new Set<string>();
|
||||
const addResFolder = (resFolder: string): void => {
|
||||
if (!existsSync(resFolder)) return;
|
||||
try {
|
||||
for (const item of readdirSync(resFolder, { withFileTypes: true })) {
|
||||
if (item.isFile() && /decal.*\.dxp\.bin$/i.test(item.name)) paths.add(join(resFolder, item.name));
|
||||
}
|
||||
} catch { /* unreadable optional pack folder */ }
|
||||
};
|
||||
addResFolder(join(gameFolder, 'res'));
|
||||
addResFolder(join(gameFolder, 'content', 'base', 'res'));
|
||||
const contentRoot = join(gameFolder, 'content');
|
||||
if (existsSync(contentRoot)) {
|
||||
try {
|
||||
for (const pkg of readdirSync(contentRoot, { withFileTypes: true })) {
|
||||
if (pkg.isDirectory() && pkg.name !== 'base') addResFolder(join(contentRoot, pkg.name, 'res'));
|
||||
}
|
||||
} catch { /* unreadable optional content root */ }
|
||||
}
|
||||
return [...paths];
|
||||
}
|
||||
|
||||
function readDxp2DecalHeaders(dxpPath: string): DxpDecalTexture[] {
|
||||
const headerBuf = readDxp2HeaderSlice(dxpPath);
|
||||
if (!headerBuf) return [];
|
||||
const count = headerBuf.readUInt32LE(0x08);
|
||||
const namesTable = DXP2_PREAMBLE_BYTES + headerBuf.readUInt32LE(0x10);
|
||||
const ddsxTable = DXP2_PREAMBLE_BYTES + headerBuf.readUInt32LE(0x20);
|
||||
if (namesTable + count * 8 > headerBuf.length || ddsxTable + count * DDSX_HEADER_BYTES > headerBuf.length) {
|
||||
return [];
|
||||
}
|
||||
const textures: DxpDecalTexture[] = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const nameOffset = DXP2_PREAMBLE_BYTES + Number(headerBuf.readBigUInt64LE(namesTable + i * 8));
|
||||
const rawName = readNullTerminatedAscii(headerBuf, nameOffset);
|
||||
const starIndex = rawName.indexOf('*');
|
||||
const cleanName = (starIndex >= 0 ? rawName.slice(0, starIndex) : rawName).trim();
|
||||
const ddsxSlice = headerBuf.subarray(ddsxTable + i * DDSX_HEADER_BYTES, ddsxTable + (i + 1) * DDSX_HEADER_BYTES);
|
||||
if (!cleanName || ddsxSlice.readUInt32LE(0) !== DDSX_MAGIC) continue;
|
||||
const width = ddsxSlice.readUInt16LE(12);
|
||||
const height = ddsxSlice.readUInt16LE(14);
|
||||
if (width === 0 || height === 0) continue;
|
||||
textures.push({
|
||||
name: cleanName,
|
||||
width,
|
||||
height,
|
||||
aspectRatio: width / height,
|
||||
ddsxHeaderBase64: normalizeDdsxHeader(ddsxSlice),
|
||||
});
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
|
||||
function readDxp2HeaderSlice(dxpPath: string): Buffer | undefined {
|
||||
let fd: number | undefined;
|
||||
try {
|
||||
fd = openSync(dxpPath, 'r');
|
||||
const preamble = Buffer.alloc(DXP2_PREAMBLE_BYTES);
|
||||
if (readSync(fd, preamble, 0, DXP2_PREAMBLE_BYTES, 0) < DXP2_PREAMBLE_BYTES) return undefined;
|
||||
if (preamble.readUInt32LE(0) !== DXP2_MAGIC || preamble.readUInt32LE(4) !== DXP2_VERSION) return undefined;
|
||||
const hdrSize = preamble.readUInt32LE(0x0c);
|
||||
if (hdrSize === 0 || hdrSize > DXP2_MAX_HEADER_BYTES) return undefined;
|
||||
const total = DXP2_PREAMBLE_BYTES + hdrSize;
|
||||
const full = Buffer.alloc(total);
|
||||
preamble.copy(full, 0);
|
||||
if (readSync(fd, full, DXP2_PREAMBLE_BYTES, hdrSize, DXP2_PREAMBLE_BYTES) < hdrSize) return undefined;
|
||||
return full;
|
||||
} catch {
|
||||
return undefined;
|
||||
} finally {
|
||||
if (fd !== undefined) {
|
||||
try { closeSync(fd); } catch { /* ignore close failure */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeDdsxHeader(rawHeader: Uint8Array): string {
|
||||
const unpacked = Buffer.from(rawHeader);
|
||||
unpacked.writeUInt32LE(unpacked.readUInt32LE(8) & DDSX_COMPRESSION_MASK, 8);
|
||||
unpacked.writeUInt32LE(0, 28);
|
||||
return unpacked.toString('base64');
|
||||
}
|
||||
|
||||
function readNullTerminatedAscii(buffer: Buffer, offset: number): string {
|
||||
if (offset < 0 || offset >= buffer.length) return '';
|
||||
let end = offset;
|
||||
while (end < buffer.length && buffer[end] !== 0) end += 1;
|
||||
return buffer.subarray(offset, end).toString('ascii');
|
||||
}
|
||||
@@ -32,6 +32,8 @@ export interface MissionHeader {
|
||||
readonly type?: string;
|
||||
readonly environment?: string;
|
||||
readonly weather?: string;
|
||||
readonly locName?: string;
|
||||
readonly postfix?: string;
|
||||
readonly countryAxis?: string;
|
||||
readonly countryAllies?: string;
|
||||
readonly timeLimit?: number;
|
||||
@@ -50,7 +52,7 @@ export interface MultiplayerMissions {
|
||||
|
||||
export const multiplayerMissions: Dataset<MultiplayerMissions> = {
|
||||
id: 'multiplayer-missions',
|
||||
version: 1,
|
||||
version: 2,
|
||||
extract(source: DatasetSource): MultiplayerMissions {
|
||||
const section = blockAt(source.readBlk('char.vromfs.bin', MISSION_LIST), MULTIPLAYER_SECTION);
|
||||
if (!section) throw new Error(`${MISSION_LIST} has no "${MULTIPLAYER_SECTION}" block`);
|
||||
@@ -93,6 +95,8 @@ function readHeader(name: string, path: string, document: BlkBlock): MissionHead
|
||||
type: stringField(mission, 'type'),
|
||||
environment: stringField(mission, 'environment'),
|
||||
weather: stringField(mission, 'weather'),
|
||||
locName: stringField(mission, 'locName'),
|
||||
postfix: stringField(mission, 'postfix'),
|
||||
countryAxis: stringField(mission, 'country_axis'),
|
||||
countryAllies: stringField(mission, 'country_allies'),
|
||||
timeLimit: numberField(mission, 'timeLimit'),
|
||||
|
||||
@@ -60,11 +60,18 @@ export interface CatalogueVehicle {
|
||||
readonly openCostGold: number;
|
||||
/** wpcost.blk minOpenCostGold (minimum GE buyout floor for squadron vehicles, implementation notes). */
|
||||
readonly minOpenCostGold: number;
|
||||
/** wpcost.blk economicRank and per-difficulty matchmaking ranks. */
|
||||
readonly economicRank: number;
|
||||
readonly economicRankArcade: number;
|
||||
readonly economicRankHistorical: number;
|
||||
readonly economicRankSimulation: number;
|
||||
readonly economicRankTankHistorical?: number;
|
||||
readonly economicRankTankSimulation?: number;
|
||||
}
|
||||
|
||||
export const vehicleCatalogue: Dataset<readonly CatalogueVehicle[]> = {
|
||||
id: 'vehicle-catalogue',
|
||||
version: 5,
|
||||
version: 6,
|
||||
extract: (source) => {
|
||||
const shopEntries = shopEntriesByName(source);
|
||||
const treeOrder = new Map([...shopEntries.keys()].map((name, index) => [name, index]));
|
||||
@@ -77,6 +84,9 @@ function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined, tr
|
||||
const researchType = stringField(vehicle, 'researchType');
|
||||
const requiredUnlock = stringField(shopEntry, 'reqUnlock');
|
||||
const marketplaceItemdefId = numberField(shopEntry, 'marketplaceItemdefId') ?? numberField(vehicle, 'marketplaceItemdefId');
|
||||
const economicRank = numberField(vehicle, 'economicRank') ?? 0;
|
||||
const economicRankTankHistorical = numberField(vehicle, 'economicRankTankHistorical');
|
||||
const economicRankTankSimulation = numberField(vehicle, 'economicRankTankSimulation');
|
||||
return {
|
||||
name: vehicle.name,
|
||||
country: stringField(vehicle, 'country') ?? '',
|
||||
@@ -98,5 +108,11 @@ function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined, tr
|
||||
...(marketplaceItemdefId !== undefined ? { marketplaceItemdefId } : {}),
|
||||
openCostGold: numberField(vehicle, 'openCostGold') ?? 0,
|
||||
minOpenCostGold: numberField(vehicle, 'minOpenCostGold') ?? 0,
|
||||
economicRank,
|
||||
economicRankArcade: numberField(vehicle, 'economicRankArcade') ?? economicRank,
|
||||
economicRankHistorical: numberField(vehicle, 'economicRankHistorical') ?? economicRank,
|
||||
economicRankSimulation: numberField(vehicle, 'economicRankSimulation') ?? economicRank,
|
||||
...(economicRankTankHistorical !== undefined ? { economicRankTankHistorical } : {}),
|
||||
...(economicRankTankSimulation !== undefined ? { economicRankTankSimulation } : {}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user