refactor(repo)!: move apps, shared packages, and patch definitions
Everything sat in packages/: two programs next to the small libraries
they use, and the patch data loose at the root. The programs now live in
apps/ and the shared libraries in packages/:
apps/server the local server (was packages/local-service),
package @wto/server
packages/patcher builds the game copy (was packages/build),
package @wto/patcher
patches/exe exe patch definitions (was exe-patches)
patches/gui GUI script patches (was gui-patches)
Inside the server, the network layer folder becomes transport/ so it is
not server/server/, the entry module is server.ts, and startLocalService
and its types become startServer, ServerOptions and RunningServer. The
health answer names the app wto-server, and the TLS files in the data
folder are server.key and server.crt (made again on the next start).
Comments, logs and tool texts say "local server".
The patcher no longer reaches into the server's folder. It read the
default tuning/store.jsonc by a relative path to register bundle GUIDs
for the multi-vehicle packs, which also ignored the player's overrides
in <data>/tuning/. It now takes the pack ids from its caller; the
server exports multiVehiclePackIds(dataFolder), which reads them the way
the running server does. rebuildGuiPack takes the patch folder from its
caller as well.
The development build moves out of the patcher to
scripts/build-game-copy.ts, since it uses both the server and the
patcher. It needs --data (the folder the server will run with) and
defaults the patch folders and the hook library to this repository.
Checked with the root typecheck, check-patches, check-gui,
check-offsets, the native build, a run of build-game-copy.ts into a
scratch folder (12 exe patches, 35 GUI patches, 496 bundle GUIDs as
before) and a server start from apps/server answering wto-server.
BREAKING CHANGE: Use @wto/server and @wto/patcher from the new workspace paths. Run the development build with scripts/build-game-copy.ts and pass --data.
This commit is contained in:
1 parent
9c813ccf7d
commit
930ea07630
476 files changed
+275
-251
No files matched your search
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* The `mrpc.generic_notify` message that starts a local battle (`from: "wto_battle"`,
|
||||
* `func: "launch"`), received by the client's launch script patch
|
||||
* (patches/gui/battle/launch-local-battle-from-queue).
|
||||
*
|
||||
* - `mission`: the complete mission settings for `select_training_mission`, as a typed tree
|
||||
* `{ p: [[name, type, value], ...], b: [[name, node], ...] }` with type "t", "i", "r" or "b".
|
||||
* Matching notifications are JSON, which cannot tell 1 from 1.0; the engine reads ints and reals
|
||||
* with typed getters, so the type travels with every value. Repeated blocks stay separate.
|
||||
* - `lobby`: the session lobby settings the client's own room scripts read during the battle
|
||||
* (game mode and both sides' countries).
|
||||
* - `battle`: what the client keeps for this battle (session id for the settlement, extra slots,
|
||||
* `spawnScore` for Ground Realistic Battles, and `awards` for the in-battle reward banner).
|
||||
*/
|
||||
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';
|
||||
|
||||
type WireParam = readonly [name: string, type: 't' | 'i' | 'r' | 'b', value: string | number | boolean];
|
||||
|
||||
interface WireBlock {
|
||||
readonly p: readonly WireParam[];
|
||||
readonly b: ReadonlyArray<readonly [name: string, block: WireBlock]>;
|
||||
}
|
||||
|
||||
export interface BattleLaunchNotify extends Record<string, unknown> {
|
||||
readonly from: 'wto_battle';
|
||||
readonly func: 'launch';
|
||||
readonly mission: WireBlock;
|
||||
readonly lobby: Readonly<Record<string, unknown>>;
|
||||
readonly battle: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export function battleLaunchNotify(
|
||||
plan: BattleLaunchPlan,
|
||||
awards: BannerParams,
|
||||
scores: Readonly<Record<string, number>>,
|
||||
): BattleLaunchNotify {
|
||||
return {
|
||||
from: 'wto_battle',
|
||||
func: 'launch',
|
||||
mission: toWire(battleMissionSettings(plan, scores)),
|
||||
lobby: {
|
||||
game_mode_id: plan.modeId,
|
||||
game_mode_name: plan.modeName,
|
||||
economicName: plan.economicName,
|
||||
symmetricTeams: plan.symmetricTeams,
|
||||
country_allies: plan.countriesAllies.map(withCountryPrefix),
|
||||
country_axis: plan.countriesAxis.map(withCountryPrefix),
|
||||
mission: { name: plan.missionName, difficulty: plan.difficulty },
|
||||
},
|
||||
battle: {
|
||||
sessionId: plan.sessionId,
|
||||
modeName: plan.modeName,
|
||||
economicName: plan.economicName,
|
||||
country: plan.country,
|
||||
missionName: plan.missionName,
|
||||
extraBattleSlots: plan.extraBattleSlots,
|
||||
...(plan.spawnScore ? { spawnScore: plan.spawnScore } : {}),
|
||||
awards,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function toWire(block: BlkBlock): WireBlock {
|
||||
return {
|
||||
p: block.params.map((param) => [param.name, ...wireValue(param.name, param.value)] as const),
|
||||
b: block.blocks.map((child) => [child.name, toWire(child)] as const),
|
||||
};
|
||||
}
|
||||
|
||||
function wireValue(name: string, value: BlkValue): readonly ['t' | 'i' | 'r' | 'b', string | number | boolean] {
|
||||
switch (value.type) {
|
||||
case 'string': return ['t', value.value];
|
||||
case 'int': return ['i', value.value];
|
||||
case 'real': return ['r', value.value];
|
||||
case 'bool': return ['b', value.value];
|
||||
default: throw new Error(`mission settings parameter ${name} has type ${value.type}, which the launch message cannot carry`);
|
||||
}
|
||||
}
|
||||
|
||||
function withCountryPrefix(country: string): string {
|
||||
return country.startsWith('country_') ? country : `country_${country}`;
|
||||
}
|
||||
Reference in new issue
Block a user