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:
N0VAN0M4LY committed 2026-12-01 12:13:53 +08:00
1 parent 7ba66340b6
commit d165a80a4a
12 files changed
+175 -25

No files matched your search

@@ -0,0 +1,51 @@
/** Build the offline Air Realistic rotation from the stock mission variants and ranked airfield imports. */
import { AIR_HISTORICAL_MISSION_FOLDER, type MissionHeader } from '../game-data/datasets/multiplayer-missions.ts';
interface MissionRankRange {
readonly minMRank: number;
readonly maxMRank: number;
}
export interface MissionRotationRanks {
readonly byMission: ReadonlyMap<string, readonly MissionRankRange[]>;
readonly maxMrank: number;
}
export function airRealisticMissionRanks(selected: readonly MissionHeader[], fixedLayoutMaxMrank: number): MissionRotationRanks {
const historical = selected.filter((mission) => mission.path.startsWith(AIR_HISTORICAL_MISSION_FOLDER)
&& !mission.airfieldLayoutProblem && !mission.locName?.split(';').includes('missions/air_newbie'));
const byMission = new Map<string, readonly MissionRankRange[]>();
const topRankStarts = historical.flatMap((mission) => mission.airfieldLayouts.flatMap((layout) =>
layout.tier === 'top' ? [layout.minMRank] : []));
if (topRankStarts.length === 0) return { byMission, maxMrank: 0 };
const belowTopMax = Math.min(...topRankStarts) - 1;
let maxMrank = 0;
for (const mission of historical) {
const ranges = mission.airfieldLayouts.length === 0
? [{ minMRank: 0, maxMRank: Math.min(fixedLayoutMaxMrank, belowTopMax) }]
: mission.airfieldLayouts.map(({ tier, minMRank, maxMRank }) => ({
minMRank,
maxMRank: tier === 'top' ? maxMRank : Math.min(maxMRank, belowTopMax),
}));
const supported = mergeRankRanges(ranges);
if (supported.length === 0) continue;
byMission.set(mission.name, supported);
maxMrank = Math.max(maxMrank, supported.at(-1)!.maxMRank);
}
return { byMission, maxMrank };
}
function mergeRankRanges(ranges: readonly MissionRankRange[]): MissionRankRange[] {
const sorted = ranges.filter(({ minMRank, maxMRank }) => minMRank <= maxMRank).sort((a, b) => a.minMRank - b.minMRank);
const merged: MissionRankRange[] = [];
for (const range of sorted) {
const previous = merged.at(-1);
if (previous && range.minMRank <= previous.maxMRank + 1) {
merged[merged.length - 1] = { minMRank: previous.minMRank, maxMRank: Math.max(previous.maxMRank, range.maxMRank) };
} else {
merged.push(range);
}
}
return merged;
}
@@ -23,6 +23,8 @@ export interface MissionSelection {
readonly include?: RegExp;
/** Drop missions whose name matches. */
readonly exclude?: RegExp;
/** Use the stock historical mission and airfield layout data to limit the rotation by BR. */
readonly rankByAirfieldLayout?: boolean;
}
export interface GameModeDeclaration {
@@ -16,6 +16,13 @@ export const AIR_BATTLE_MISSIONS: MissionSelection = {
exclude: NEWBIE_MISSIONS,
};
export const AIR_REALISTIC_MISSIONS: MissionSelection = {
categories: ['base_dom'],
requireAllowed: ['aircraft'],
exclude: NEWBIE_MISSIONS,
rankByAirfieldLayout: true,
};
export const GROUND_BATTLE_MISSIONS: MissionSelection = {
categories: ['air_ground_Dom', 'air_ground_Conq', 'air_ground_Bttl'],
requireAllowed: ['tank'],
@@ -13,7 +13,7 @@
* `scripts/unlocks/personalunlocks.nut:12`, and `config/unlocks.blk` (`title_prowler_in_the_night`).
*/
import type { GameModeDeclaration } from './game-mode-declaration.ts';
import { AIR_BATTLE_MISSIONS, GROUND_BATTLE_MISSIONS, NAVAL_BATTLE_MISSIONS } from './mission-pools.ts';
import { AIR_BATTLE_MISSIONS, AIR_REALISTIC_MISSIONS, GROUND_BATTLE_MISSIONS, NAVAL_BATTLE_MISSIONS } from './mission-pools.ts';
const AIR_REALISTIC_SMALL_TEAMS_MIN_MRANK = 27;
const GROUND_REALISTIC_NIGHT_MIN_MRANK = 27;
@@ -30,7 +30,7 @@ export const RANDOM_BATTLES: readonly GameModeDeclaration[] = [
{
gameModeId: 2, name: 'air_realistic', economicName: 'air_realistic', locName: 'missions/air_event_historical',
difficulty: 'realistic', displayType: 'random_battle', multiSlot: false,
minMRankForSmallTeamsBattles: AIR_REALISTIC_SMALL_TEAMS_MIN_MRANK, ...AIR,
...AIR, missions: AIR_REALISTIC_MISSIONS, minMRankForSmallTeamsBattles: AIR_REALISTIC_SMALL_TEAMS_MIN_MRANK,
},
{
gameModeId: 3, name: 'tank_event_in_random_battles_arcade', economicName: 'tank_event_in_random_battles_arcade',
@@ -13,7 +13,7 @@
*/
import type { GameModeDeclaration } from './game-mode-declaration.ts';
import {
AIR_BATTLE_MISSIONS,
AIR_REALISTIC_MISSIONS,
BULLET_HELL_MISSIONS,
GROUND_BATTLE_MISSIONS,
NAVAL_EC_MISSIONS,
@@ -57,7 +57,7 @@ export const SUB_GAME_MODES: readonly GameModeDeclaration[] = [
isSmallTeams: true,
requiredClass: 'aircraft',
allowedClasses: ['aircraft'],
missions: AIR_BATTLE_MISSIONS,
missions: AIR_REALISTIC_MISSIONS,
},
{
gameModeId: 103,
+18 -5
View File
@@ -7,6 +7,7 @@
* and team rules a chosen mode has.
*/
import type { MissionHeader, MultiplayerMissions } from '../game-data/datasets/multiplayer-missions.ts';
import { airRealisticMissionRanks, type MissionRotationRanks } from './air-realistic-missions.ts';
import { GAME_MODE_CATALOGUE } from './catalogue/catalogue.ts';
import type { GameModeDeclaration } from './catalogue/game-mode-declaration.ts';
import { selectMissions } from './mission-pool.ts';
@@ -15,6 +16,7 @@ import { buildModeDefinition, type ModeDefinition } from './mode-definition.ts';
export interface OfferedGameMode {
readonly declaration: GameModeDeclaration;
readonly missions: readonly MissionHeader[];
readonly missionRanks?: MissionRotationRanks;
readonly definition: ModeDefinition;
}
@@ -25,18 +27,29 @@ export class GameModes {
readonly #countries: readonly string[];
constructor(missions: MultiplayerMissions, countries: readonly string[], report: (line: string) => void,
catalogue: readonly GameModeDeclaration[] = GAME_MODE_CATALOGUE) {
fixedAirRealisticMaxMrank: number, catalogue: readonly GameModeDeclaration[] = GAME_MODE_CATALOGUE) {
this.#countries = [...countries];
for (const mode of catalogue) {
const selected = selectMissions(mode.missions, missions);
if (selected.length === 0) {
report(`game mode ${mode.name}${mode.tag ? `.${mode.tag}` : ''}: no missions in the game files, left out`);
const name = mode.tag ?? mode.name;
const missionRanks = mode.missions.rankByAirfieldLayout
? airRealisticMissionRanks(selected, fixedAirRealisticMaxMrank) : undefined;
if (missionRanks) {
for (const mission of selected) {
if (mission.airfieldLayoutProblem) report(`game mode ${name}: ${mission.name} omitted: ${mission.airfieldLayoutProblem}`);
}
}
const available = missionRanks ? selected.filter((mission) => missionRanks.byMission.has(mission.name)) : selected;
if (available.length === 0) {
const reason = missionRanks ? 'no usable top-rank airfield layouts' : 'no missions in the game files';
report(`game mode ${name}: ${reason}, left out`);
continue;
}
const offered: OfferedGameMode = {
declaration: mode,
missions: selected,
definition: buildModeDefinition(mode, selected, countries),
missions: available,
...(missionRanks ? { missionRanks } : {}),
definition: buildModeDefinition(mode, available, countries, missionRanks),
};
this.#byId.set(mode.gameModeId, offered);
if (!mode.tag) this.#byName.set(mode.name, offered);
@@ -10,8 +10,8 @@
* playable and mark the mode invalid. Craft rules name a vehicle class; requiredCrafts
* is what greys the mode out for a player without that class (gameModeManagerState.nut
* createEventGameMode).
* - mission_decl.missions_list: mission name -> {} (a value may carry "enableIf" rank
* limits, scripts/missions/mapPreferencesParams.nut; none are set).
* - mission_decl.missions_list: mission name -> settings; "enableIf" carries the rank
* limits of ranked missions (scripts/missions/mapPreferencesParams.nut).
* - tag: required, the script reads it unguarded (scripts/matching/matchingGameModes.nut,
* onGameModesUpdated). Tag prefixes mark sub-modes
* (night battles, small teams, bullet hell, nuclear escalation, naval EC;
@@ -26,6 +26,7 @@
* missionsBanMode (map preferences; absent means none, mapPreferencesParams.nut).
*/
import type { MissionHeader } from '../game-data/datasets/multiplayer-missions.ts';
import type { MissionRotationRanks } from './air-realistic-missions.ts';
import type { GameModeDeclaration, ModeDifficulty } from './catalogue/game-mode-declaration.ts';
const MATCHING_DIFFICULTY: Readonly<Record<ModeDifficulty, string>> = {
@@ -46,7 +47,7 @@ export const SINGLE_SPAWN = 1;
export type ModeDefinition = Readonly<Record<string, unknown>>;
export function buildModeDefinition(mode: GameModeDeclaration, missions: readonly MissionHeader[],
countries: readonly string[]): ModeDefinition {
countries: readonly string[], missionRanks?: MissionRotationRanks): ModeDefinition {
const minTeamSize = mode.teamSizeOverride?.min ?? 1;
const maxTeamSize = mode.teamSizeOverride?.max ?? teamSize(mode, missions);
const team = {
@@ -83,7 +84,10 @@ export function buildModeDefinition(mode: GameModeDeclaration, missions: readonl
mission_decl: {
difficulty: MISSION_DIFFICULTY[mode.difficulty],
...(mode.multiSlot === false ? { maxRespawns: SINGLE_SPAWN } : {}),
missions_list: Object.fromEntries(missions.map((mission) => [mission.name, {}])),
missions_list: Object.fromEntries(missions.map((mission) => {
const ranges = missionRanks?.byMission.get(mission.name);
return [mission.name, ranges?.length === 1 ? { enableIf: ranges[0] } : {}];
})),
},
};
}