Split the repository into apps, packages and patches

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.
This commit is contained in:
N0VAN0M4LY committed 2026-11-29 03:20:54 +08:00
1 parent f6cdab7ec7
commit 27fc535301
476 files changed
+275 -251

No files matched your search

@@ -0,0 +1,82 @@
/**
* Dataset: how a battle's Research Points reach the researched vehicle (implementation notes "3e").
*
* char.vromfs.bin config/rank.blk:
* expBonusPercentForChildForMode<N> bonus when the vehicle played precedes the researched one;
* the client reads N = the difficulty's diffCode
* (gui.vromfs.bin scripts/airinfo.nut)
* expPenaltyPercentForHigherRank<N> penalty when the researched vehicle is N ranks above the one played
* expPenaltyPercentForLowerRank<N> penalty when it is N ranks below
* ExpNewNationBonus{<type>{rank<N>}} "Vehicle Research Bonus" percent by the researched vehicle's rank
* expNewNationBonusDailyBattleCount battles per nation and branch per day that get it
* char.vromfs.bin config/shop.blk:
* country{ branch{ range{ vehicle | group{ vehicle... } } } }: the last entry of each range ends a
* research line; when it is a group, its first vehicle counts (official wiki "Research Points",
* "top" vehicle definition).
*/
import type { BlkBlock } from '@wto/blk';
import { numberField } from './blk-fields.ts';
import type { Dataset } from './dataset.ts';
import { SHOP } from './shop-tree.ts';
export interface ResearchEfficiencyData {
/** Indexed by mode number N of expBonusPercentForChildForMode<N>. */
readonly childBonusPercent: readonly number[];
/** Indexed by the rank difference. */
readonly higherRankPenaltyPercent: readonly number[];
readonly lowerRankPenaltyPercent: readonly number[];
/** Vehicle type (rank.blk spelling: Tank, Aircraft, Helicopter, Ship, Boat) -> rank -> percent. */
readonly nationBonusPercent: Readonly<Record<string, Readonly<Record<number, number>>>>;
readonly nationBonusDailyBattles: number;
/** The vehicle that ends each research line of shop.blk. */
readonly lineEnds: readonly string[];
}
const RANK = 'config/rank.blk';
export const researchEfficiency: Dataset<ResearchEfficiencyData> = {
id: 'research-efficiency',
version: 1,
extract: (source) => {
const rank = source.readBlk('char.vromfs.bin', RANK);
const nationBonus = rank.blocks.find((block) => block.name === 'ExpNewNationBonus');
const dailyBattles = numberField(rank, 'expNewNationBonusDailyBattleCount');
if (dailyBattles === undefined) throw new Error('rank.blk: expNewNationBonusDailyBattleCount is missing');
return {
childBonusPercent: indexedSeries(rank, 'expBonusPercentForChildForMode'),
higherRankPenaltyPercent: indexedSeries(rank, 'expPenaltyPercentForHigherRank'),
lowerRankPenaltyPercent: indexedSeries(rank, 'expPenaltyPercentForLowerRank'),
nationBonusPercent: Object.fromEntries((nationBonus?.blocks ?? []).map((type) => [
type.name,
Object.fromEntries(type.params.flatMap((param) => {
const rankNumber = /^rank(\d+)$/.exec(param.name)?.[1];
return rankNumber !== undefined && param.value.type === 'int' ? [[Number(rankNumber), param.value.value]] : [];
})),
])),
nationBonusDailyBattles: dailyBattles,
lineEnds: source.readBlk('char.vromfs.bin', SHOP).blocks.flatMap((country) =>
country.blocks.flatMap((branch) => branch.blocks.filter((range) => range.name === 'range').flatMap(lineEnd))),
};
},
};
/** <prefix>0, <prefix>1, ... up to the first missing index. */
function indexedSeries(block: BlkBlock, prefix: string): number[] {
const values: number[] = [];
for (let index = 0; ; index++) {
const value = numberField(block, `${prefix}${index}`);
if (value === undefined) break;
values.push(value);
}
if (values.length === 0) throw new Error(`rank.blk: ${prefix}0 is missing`);
return values;
}
/** A vehicle entry has no child blocks; a group holds its vehicles as child blocks. */
function lineEnd(range: BlkBlock): string[] {
const last = range.blocks.at(-1);
if (!last) return [];
if (last.blocks.length === 0) return [last.name];
const first = last.blocks[0];
return first ? [first.name] : [];
}