Build the local battle mission settings in the local service
The launch script patch used to assemble the whole MissionSettings block on the client: reading the mission file for localization keys and ticket rules, filling the AI vehicle pool, rank window and extra slot costs. All of that is pre-battle data the local service already owns. - multiplayer-missions dataset v3 keeps the scalar parameters of mission_settings.mission and of each per-difficulty sub-block, with their BLK types. - battle-mission-settings.ts builds the complete MissionSettings block from the launch plan (same parameters as before). - battle-launch-notify.ts sends it as a typed tree, so ints and reals keep the types the engine reads, plus the lobby settings and the per-battle record the in-battle patches read from nestdb. - The launch patch shrinks from 208 to about 70 lines: rebuild the DataBlock, set _gameMode from the client's own native constant, enter the session lobby and start the LocalMP battle. Behaviour is unchanged; coalitions, extra slots and economy are reworked in later commits. Verified: npm run typecheck, check-gui (33 patches).
This commit is contained in:
1 parent
16b5d3cab1
commit
b1392c0512
7 files changed
+276
-181
No files matched your search
@@ -7,11 +7,13 @@
|
||||
* - Each mission: mis.vromfs.bin gamedata/missions/…/<name lower-cased>.blk. Its
|
||||
* mission_settings block names the map, the kind of game, the two sides' countries, the
|
||||
* vehicle types allowed, per-difficulty overrides, and the players' spawn slots
|
||||
* ("wing" entries of player / player_teamB).
|
||||
* ("wing" entries of player / player_teamB). Its scalar parameters (and those of each
|
||||
* per-difficulty "mission" sub-block) are also kept as written, with their BLK types, for
|
||||
* the mission settings the local service sends when a battle starts.
|
||||
*
|
||||
* 2.61.0.37: 1315 missions, each name matching exactly one mission file (docs/implementation notes).
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import type { BlkBlock, BlkParam } from '@wto/blk';
|
||||
import type { Dataset, DatasetSource } from './dataset.ts';
|
||||
import { blockAt, boolFields, numberField, stringField, stringList } from './blk-fields.ts';
|
||||
|
||||
@@ -43,6 +45,10 @@ export interface MissionHeader {
|
||||
readonly difficultyOverrides: readonly string[];
|
||||
/** Spawn slots per side. */
|
||||
readonly playerSlots: { readonly teamA: number; readonly teamB: number };
|
||||
/** String, int, real and bool parameters of mission_settings.mission, in file order. */
|
||||
readonly missionParams: readonly BlkParam[];
|
||||
/** The same for each per-difficulty "mission" sub-block, keyed by its `difficulty`. */
|
||||
readonly difficultyParams: Readonly<Record<string, readonly BlkParam[]>>;
|
||||
}
|
||||
|
||||
export interface MultiplayerMissions {
|
||||
@@ -52,7 +58,7 @@ export interface MultiplayerMissions {
|
||||
|
||||
export const multiplayerMissions: Dataset<MultiplayerMissions> = {
|
||||
id: 'multiplayer-missions',
|
||||
version: 2,
|
||||
version: 3,
|
||||
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`);
|
||||
@@ -113,5 +119,19 @@ function readHeader(name: string, path: string, document: BlkBlock): MissionHead
|
||||
teamA: stringList(blockAt(settings, 'player'), 'wing').length,
|
||||
teamB: stringList(blockAt(settings, 'player_teamB'), 'wing').length,
|
||||
},
|
||||
missionParams: scalarParams(mission),
|
||||
difficultyParams: Object.fromEntries((mission?.blocks ?? [])
|
||||
.filter((block) => block.name === 'mission')
|
||||
.flatMap((block) => {
|
||||
const difficulty = stringField(block, 'difficulty');
|
||||
return difficulty ? [[difficulty, scalarParams(block)]] : [];
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
const SCALAR_TYPES = new Set(['string', 'int', 'real', 'bool']);
|
||||
|
||||
/** The parameters whose values survive the dataset cache's JSON unchanged. */
|
||||
function scalarParams(block: BlkBlock | undefined): BlkParam[] {
|
||||
return (block?.params ?? []).filter((param) => SCALAR_TYPES.has(param.value.type));
|
||||
}
|
||||
Reference in new issue
Block a user