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.
121 lines
6.1 KiB
TypeScript
121 lines
6.1 KiB
TypeScript
/**
|
|
* Dataset: what repairing each vehicle costs and how long a free repair takes.
|
|
*
|
|
* char.vromfs.bin config/wpcost.blk, per vehicle:
|
|
* repairCost<Mode>:i full repair cost (Mode = Arcade, Historical, Simulation)
|
|
* repairCostPerMin<Mode>:i repair cost per minute of the vehicle's lifetime in a battle
|
|
* repairTimeHrs<Mode>:r full repair time in hours with a crew
|
|
* repairTimeHrsNoCrew<Mode>:r full repair time in hours when no crew has the vehicle
|
|
* freeRepairs:i free repair allowance (falls back to warpoints.blk, then 0)
|
|
* modifications{ <mod>{ repairCostCoef:r repairCostCoef<Mode>:r } } added to the cost factor
|
|
* char.vromfs.bin config/warpoints.blk: rTimeNoCrewMul:r (no-crew time = repairTimeHrs x it when
|
|
* repairTimeHrsNoCrew<Mode> is missing).
|
|
* char.vromfs.bin config/crew_skills.blk: the crew's groundService skills that shorten the repair:
|
|
* crew_skills{ groundService{ repair{ use_specializations:b skill_level_exp{ level1..levelN } } } }
|
|
* specialization<k>_add:r (k = 1..4), repair_ranks{ rank<level>:i }.
|
|
*
|
|
* The client reads the same fields: the full cost from the price table (cln_get_price_ex,
|
|
* aircrafts/<vehicle>/repair/<mode>/cost, aces.exe 2.61.0.37 0x10517b0), times 1 + the
|
|
* repairCostCoef<Mode> (else repairCostCoef) of each modification the player has (0x964900); the
|
|
* repair time in 0x937330 (repair/repair-rules.ts fullRepairHours).
|
|
*/
|
|
import { findBlock, type BlkBlock } from '@wto/blk';
|
|
import { blockAt, numberField } from './blk-fields.ts';
|
|
import type { Dataset } from './dataset.ts';
|
|
|
|
export const REPAIR_MODES = ['Arcade', 'Historical', 'Simulation'] as const;
|
|
export type RepairMode = (typeof REPAIR_MODES)[number];
|
|
export type PerRepairMode = Readonly<Record<RepairMode, number>>;
|
|
|
|
export interface VehicleRepair {
|
|
readonly name: string;
|
|
readonly cost: PerRepairMode;
|
|
readonly costPerMin: PerRepairMode;
|
|
/** Allowance shown by scripts/unit/unit.nut and scripts/airinfo.nut. */
|
|
readonly freeRepairs: number;
|
|
/** Hours; 0 when the data has none. */
|
|
readonly timeHours: PerRepairMode;
|
|
/** Hours; -1 when the data has none (the client's default, 0x964e30). */
|
|
readonly noCrewTimeHours: PerRepairMode;
|
|
/** Modifications with a repair cost coefficient. */
|
|
readonly modCoefs: Readonly<Record<string, PerRepairMode>>;
|
|
}
|
|
|
|
/** The crew skills that shorten a repair (crew_skills.blk). */
|
|
export interface CrewRepairSkill {
|
|
/** Levels of groundService/repair (the length of its skill_level_exp). */
|
|
readonly maxLevel: number;
|
|
readonly usesSpecializations: boolean;
|
|
/** specialization1_add .. specialization4_add (0 when missing). */
|
|
readonly specializationAdds: readonly number[];
|
|
/** repair_ranks: the highest vehicle rank a groundService/repairRank level covers, index = level - 1. */
|
|
readonly ranksByQualification: readonly number[];
|
|
/** groundService/repairRank min_skill_level. */
|
|
readonly minQualification: number;
|
|
}
|
|
|
|
export interface VehicleRepairData {
|
|
readonly vehicles: readonly VehicleRepair[];
|
|
readonly noCrewTimeMul: number;
|
|
readonly crewSkill: CrewRepairSkill;
|
|
}
|
|
|
|
const SPECIALIZATION_ADDS = 4;
|
|
|
|
export const vehicleRepair: Dataset<VehicleRepairData> = {
|
|
id: 'vehicle-repair',
|
|
version: 3,
|
|
extract: (source) => {
|
|
const warpoints = source.readBlk('char.vromfs.bin', 'config/warpoints.blk');
|
|
const defaultFreeRepairs = numberField(warpoints, 'freeRepairs') ?? 0;
|
|
const vehicles = source.readBlk('char.vromfs.bin', 'config/wpcost.blk').blocks.flatMap((vehicle): VehicleRepair[] => {
|
|
const cost = perMode(vehicle, 'repairCost', 0);
|
|
if (REPAIR_MODES.every((mode) => cost[mode] <= 0)) return [];
|
|
const modCoefs: Record<string, PerRepairMode> = {};
|
|
for (const mod of blockAt(vehicle, 'modifications')?.blocks ?? []) {
|
|
const base = numberField(mod, 'repairCostCoef');
|
|
const coefs = Object.fromEntries(REPAIR_MODES.map((mode) => [mode, numberField(mod, `repairCostCoef${mode}`) ?? base ?? 0])) as Record<RepairMode, number>;
|
|
if (REPAIR_MODES.some((mode) => coefs[mode] !== 0)) modCoefs[mod.name] = coefs;
|
|
}
|
|
return [{
|
|
name: vehicle.name,
|
|
cost,
|
|
costPerMin: perMode(vehicle, 'repairCostPerMin', 0),
|
|
freeRepairs: Math.max(0, Math.trunc(numberField(vehicle, 'freeRepairs') ?? defaultFreeRepairs)),
|
|
timeHours: perMode(vehicle, 'repairTimeHrs', 0),
|
|
noCrewTimeHours: perMode(vehicle, 'repairTimeHrsNoCrew', -1),
|
|
modCoefs,
|
|
}];
|
|
});
|
|
return {
|
|
vehicles,
|
|
noCrewTimeMul: numberField(warpoints, 'rTimeNoCrewMul') ?? 1,
|
|
crewSkill: crewRepairSkill(source.readBlk('char.vromfs.bin', 'config/crew_skills.blk')),
|
|
};
|
|
},
|
|
};
|
|
|
|
function crewRepairSkill(crewSkills: BlkBlock): CrewRepairSkill {
|
|
const groundService = findBlock(findBlock(crewSkills, 'crew_skills') ?? crewSkills, 'groundService');
|
|
const repair = groundService && findBlock(groundService, 'repair');
|
|
const qualification = groundService && findBlock(groundService, 'repairRank');
|
|
const levels = repair && findBlock(repair, 'skill_level_exp');
|
|
const ranks = findBlock(crewSkills, 'repair_ranks');
|
|
const ranksByQualification: number[] = [];
|
|
for (let level = 1; ranks && numberField(ranks, `rank${level}`) !== undefined; level++) ranksByQualification.push(numberField(ranks, `rank${level}`)!);
|
|
return {
|
|
maxLevel: levels?.params.length ?? numberField(crewSkills, 'max_skill_level') ?? 0,
|
|
usesSpecializations: repair?.params.some((param) => param.name === 'use_specializations' && param.value.type === 'bool' && param.value.value) ?? false,
|
|
specializationAdds: Array.from({ length: SPECIALIZATION_ADDS }, (_, index) => numberField(crewSkills, `specialization${index + 1}_add`) ?? 0),
|
|
ranksByQualification,
|
|
minQualification: (qualification && numberField(qualification, 'min_skill_level')) ?? 0,
|
|
};
|
|
}
|
|
|
|
function perMode(vehicle: BlkBlock, prefix: string, missing: number): PerRepairMode {
|
|
return Object.fromEntries(REPAIR_MODES.map((mode) => {
|
|
const value = numberField(vehicle, `${prefix}${mode}`);
|
|
return [mode, value === undefined ? missing : Math.max(0, value)];
|
|
})) as Record<RepairMode, number>;
|
|
}
|