fix(battle): enforce single-sortie Air Realistic rules

Carry the queued aircraft and crew index into LocalMP, apply the native single-spawn limits to players and aircraft bots, and disable spares for single-slot modes.

Verified with root and launcher type checks, check-patches and check-gui for 2.61.0.37 and 2.61.0.43, and an isolated launch-payload check.
This commit is contained in:
N0VAN0M4LY committed 2026-12-01 12:05:42 +08:00
1 parent 6c55c64222
commit 7ba66340b6
14 files changed
+122 -56

No files matched your search

@@ -16,6 +16,7 @@ import type { BlkBlock, BlkValue } from '@wto/blk';
import type { BannerParams } from '../battle/battle-economy.ts';
import type { BattleLaunchPlan } from '../battle/battle-matchmaker.ts';
import { battleMissionSettings } from '../battle/battle-mission-settings.ts';
import { SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
type WireParam = readonly [name: string, type: 't' | 'i' | 'r' | 'b', value: string | number | boolean];
@@ -48,7 +49,11 @@ export function battleLaunchNotify(
symmetricTeams: plan.symmetricTeams,
country_allies: plan.countriesAllies.map(withCountryPrefix),
country_axis: plan.countriesAxis.map(withCountryPrefix),
mission: { name: plan.missionName, difficulty: plan.difficulty },
mission: {
name: plan.missionName,
difficulty: plan.difficulty,
...(plan.selectedSlot ? { maxRespawns: SINGLE_SPAWN } : {}),
},
},
battle: {
sessionId: plan.sessionId,
@@ -56,6 +61,7 @@ export function battleLaunchNotify(
economicName: plan.economicName,
country: plan.country,
missionName: plan.missionName,
...(plan.selectedSlot ? { selectedSlot: plan.selectedSlot } : {}),
extraBattleSlots: plan.extraBattleSlots,
...(plan.spawnScore ? { spawnScore: plan.spawnScore } : {}),
awards,
@@ -5,6 +5,7 @@
* - `match.leave_queue` (scripts/queue/queuestate.nut:28)
* - `match.check_reconnect`
*/
import { MAX_BATTLE_CREW_SLOTS } from '../battle/battle-extra-slots.ts';
import { economyDifficulty, type BattleEconomy } from '../battle/battle-economy.ts';
import type { BattleMatchmaker } from '../battle/battle-matchmaker.ts';
import { maxModeMrank, unitClassOfExpClass, unitClassOfTypeCode, type CraftRankEntry } from '../battle/battle-ranks.ts';
@@ -81,16 +82,15 @@ function handleEnqueue(
}
const profile = deps.profiles.profileOf(userId);
const slotVehicles = crewVehiclesOfCountry(profile, playerEntry.country);
const selectedSlotVehicle = playerEntry.selectedSlot !== undefined
? crewSlotVehicleOfCountry(profile, playerEntry.country, playerEntry.selectedSlot)
: undefined;
const idInCountry = playerEntry.selectedSlot;
const selectedSlotVehicle = idInCountry === undefined ? undefined : crewSlotVehicleOfCountry(profile, playerEntry.country, idInCountry);
const outcome = deps.matchmaker.enqueue({
userId,
mode: modes[0]!,
modes,
country: playerEntry.country,
slotVehicles,
...(selectedSlotVehicle !== undefined ? { selectedSlotVehicle } : {}),
...(idInCountry !== undefined && selectedSlotVehicle ? { selectedSlot: { idInCountry, unitName: selectedSlotVehicle } } : {}),
bannedMissions: playerEntry.bannedMissions,
dislikedMissions: playerEntry.dislikedMissions,
});
@@ -101,7 +101,7 @@ function handleEnqueue(
const { launch } = outcome;
session.note(`mode=${launch.modeName}, mission=${launch.missionName}, mrank=${launch.minMrank}..${launch.maxMrank}`);
const playerVehicles = new Set([
...slotVehicles,
...(launch.selectedSlot ? [launch.selectedSlot.unitName] : slotVehicles),
...launch.extraBattleSlots.map((slot) => slot.unitName),
]);
const awards = deps.economy.bannerParams(playerVehicles, economyDifficulty(modes[0]!.declaration.difficulty));
@@ -163,7 +163,8 @@ function extractPlayerEntry(
const country = rawCountry.startsWith('country_') ? rawCountry : `country_${rawCountry}`;
const slots = isRecord(entry?.slots) ? entry.slots : undefined;
const rawSlot = slots?.[country] ?? slots?.[rawCountry];
const selectedSlot = typeof rawSlot === 'number' && Number.isInteger(rawSlot) && rawSlot >= 0 ? rawSlot : undefined;
const selectedSlot = typeof rawSlot === 'number' && Number.isInteger(rawSlot) && rawSlot >= 0 && rawSlot < MAX_BATTLE_CREW_SLOTS
? rawSlot : undefined;
return {
country,
...(selectedSlot !== undefined ? { selectedSlot } : {}),