fix(matchmaking): filter Air Realistic missions by layout and BR
Limit classic Air Realistic and Tactical Skies to historical mission variants. Read stock airfield ranges, select against the rank sent to the mission loader, and keep fixed-layout limits in battle tuning. Inspected mission data from 2.61.0.37 and 2.61.0.43. Root and launcher type checks pass. Gameplay awaits manual acceptance.
This commit is contained in:
1 parent
7ba66340b6
commit
d165a80a4a
12 files changed
+175
-25
No files matched your search
@@ -13,13 +13,15 @@
|
||||
*
|
||||
* 2.61.0.37: 1315 missions, each name matching exactly one mission file.
|
||||
*/
|
||||
import type { BlkBlock, BlkParam } from '@wto/blk';
|
||||
import { findParam, type BlkBlock, type BlkParam } from '@wto/blk';
|
||||
import type { Dataset, DatasetSource } from './dataset.ts';
|
||||
import { blockAt, boolFields, numberField, stringField, stringList } from './blk-fields.ts';
|
||||
|
||||
const MISSION_LIST = 'config/mislist.blk';
|
||||
const MULTIPLAYER_SECTION = 'skirmish';
|
||||
const MISSION_FOLDER = 'gamedata/missions/';
|
||||
export const AIR_HISTORICAL_MISSION_FOLDER = 'gamedata/missions/cta/planes/historical/';
|
||||
const AIRFIELD_LAYOUT = /\/template_airfields_(low|mid|high|top)_ranks\.blk$/;
|
||||
|
||||
export interface MissionCategory {
|
||||
readonly name: string;
|
||||
@@ -27,7 +29,19 @@ export interface MissionCategory {
|
||||
readonly missions: readonly string[];
|
||||
}
|
||||
|
||||
export interface MissionHeader {
|
||||
export interface AirfieldRankLayout {
|
||||
readonly tier: string;
|
||||
readonly minMRank: number;
|
||||
readonly maxMRank: number;
|
||||
}
|
||||
|
||||
interface AirfieldLayoutData {
|
||||
/** Ranked airfield imports within the mission's airfields_part.blk, as declared by the game. */
|
||||
readonly airfieldLayouts: readonly AirfieldRankLayout[];
|
||||
readonly airfieldLayoutProblem?: string;
|
||||
}
|
||||
|
||||
export interface MissionHeader extends AirfieldLayoutData {
|
||||
readonly name: string;
|
||||
readonly path: string;
|
||||
readonly level?: string;
|
||||
@@ -58,7 +72,7 @@ export interface MultiplayerMissions {
|
||||
|
||||
export const multiplayerMissions: Dataset<MultiplayerMissions> = {
|
||||
id: 'multiplayer-missions',
|
||||
version: 3,
|
||||
version: 4,
|
||||
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`);
|
||||
@@ -68,13 +82,19 @@ export const multiplayerMissions: Dataset<MultiplayerMissions> = {
|
||||
missions: stringList(block, 'm'),
|
||||
}));
|
||||
|
||||
const pathByName = missionPathsByLowerName(source.listFiles('mis.vromfs.bin'));
|
||||
const paths = source.listFiles('mis.vromfs.bin');
|
||||
const pathByName = missionPathsByLowerName(paths);
|
||||
const knownPaths = new Set(paths);
|
||||
const airfieldsByPath = new Map<string, AirfieldLayoutData>();
|
||||
const missions: Record<string, MissionHeader> = {};
|
||||
for (const name of categories.flatMap((category) => category.missions)) {
|
||||
if (name in missions) continue;
|
||||
const path = pathByName.get(name.toLowerCase());
|
||||
if (!path) throw new Error(`mission ${name} (${MISSION_LIST}) has no file in mis.vromfs.bin`);
|
||||
missions[name] = readHeader(name, path, source.readBlk('mis.vromfs.bin', path));
|
||||
const document = source.readBlk('mis.vromfs.bin', path);
|
||||
const airfields = path.startsWith(AIR_HISTORICAL_MISSION_FOLDER)
|
||||
? readAirfieldLayouts(source, document, knownPaths, airfieldsByPath) : { airfieldLayouts: [] };
|
||||
missions[name] = readHeader(name, path, document, airfields);
|
||||
}
|
||||
return { categories, missions };
|
||||
},
|
||||
@@ -93,7 +113,9 @@ function missionPathsByLowerName(paths: readonly string[]): Map<string, string>
|
||||
return byName;
|
||||
}
|
||||
|
||||
function readHeader(name: string, path: string, document: BlkBlock): MissionHeader {
|
||||
function readHeader(
|
||||
name: string, path: string, document: BlkBlock, airfields: AirfieldLayoutData,
|
||||
): MissionHeader {
|
||||
const settings = blockAt(document, 'mission_settings');
|
||||
const mission = blockAt(settings, 'mission');
|
||||
const optional = {
|
||||
@@ -110,6 +132,7 @@ function readHeader(name: string, path: string, document: BlkBlock): MissionHead
|
||||
return {
|
||||
name,
|
||||
path,
|
||||
...airfields,
|
||||
...Object.fromEntries(Object.entries(optional).filter(([, value]) => value !== undefined)),
|
||||
allowedUnitTypes: boolFields(blockAt(mission, 'allowedUnitTypes')),
|
||||
difficultyOverrides: (mission?.blocks ?? [])
|
||||
@@ -129,6 +152,40 @@ function readHeader(name: string, path: string, document: BlkBlock): MissionHead
|
||||
};
|
||||
}
|
||||
|
||||
function readAirfieldLayouts(
|
||||
source: DatasetSource, mission: BlkBlock, knownPaths: ReadonlySet<string>, cache: Map<string, AirfieldLayoutData>,
|
||||
): AirfieldLayoutData {
|
||||
const airfieldLayouts: AirfieldRankLayout[] = [];
|
||||
for (const entry of blockAt(mission, 'imports')?.blocks ?? []) {
|
||||
const path = stringField(entry, 'file')?.toLowerCase();
|
||||
if (!path?.endsWith('/airfields_part.blk')) continue;
|
||||
const part = cache.get(path) ?? readAirfieldPart(source, path, knownPaths);
|
||||
cache.set(path, part);
|
||||
if (part.airfieldLayoutProblem) return part;
|
||||
airfieldLayouts.push(...part.airfieldLayouts);
|
||||
}
|
||||
return { airfieldLayouts };
|
||||
}
|
||||
|
||||
function readAirfieldPart(source: DatasetSource, path: string, knownPaths: ReadonlySet<string>): AirfieldLayoutData {
|
||||
if (!knownPaths.has(path)) return { airfieldLayouts: [], airfieldLayoutProblem: `missing ${path}` };
|
||||
const part = source.readBlk('mis.vromfs.bin', path);
|
||||
const airfieldLayouts: AirfieldRankLayout[] = [];
|
||||
for (const layout of blockAt(part, 'imports')?.blocks ?? []) {
|
||||
const file = stringField(layout, 'file')?.toLowerCase();
|
||||
if (!file) continue;
|
||||
const tier = AIRFIELD_LAYOUT.exec(file)?.[1];
|
||||
if (!tier) continue;
|
||||
if (!knownPaths.has(file)) return { airfieldLayouts: [], airfieldLayoutProblem: `missing ${file}` };
|
||||
const range = findParam(layout, 'rankRange')?.value;
|
||||
if (range?.type !== 'ipoint2' || range.value[0] < 0 || range.value[1] < range.value[0]) {
|
||||
return { airfieldLayouts: [], airfieldLayoutProblem: `invalid rankRange for ${file} in ${path}` };
|
||||
}
|
||||
airfieldLayouts.push({ tier, minMRank: range.value[0], maxMRank: range.value[1] });
|
||||
}
|
||||
return { airfieldLayouts };
|
||||
}
|
||||
|
||||
const SCALAR_TYPES = new Set(['string', 'int', 'real', 'bool']);
|
||||
|
||||
/** The parameters whose values survive the dataset cache's JSON unchanged. */
|
||||
|
||||
Reference in new issue
Block a user