Keep a default vehicle research target for each branch

The accelerated research dialog reads currUnit when it first opens.
Assign a valid target whenever an eligible vehicle exists and replace
stale selections when refreshing a profile.

Prefer an available direct successor when configured. Otherwise use
the configured rank or tech tree order. Type checking and profile
initialization passed. In-game acceptance is pending.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 13:41:29 +08:00
1 parent d609188acc
commit a09ac41299
8 files changed
+115 -7

No files matched your search

@@ -46,6 +46,8 @@ export interface CatalogueVehicle {
readonly researchType?: string;
/** Listed in config/shop.blk. */
readonly inTechTree: boolean;
/** Position in config/shop.blk (countries, branches, columns top to bottom, in file order); -1 when not listed. */
readonly treeOrder: number;
/** shop.blk reqUnlock. */
readonly requiredUnlock?: string;
/** shop.blk slaveUnit, repeated. */
@@ -62,14 +64,15 @@ export interface CatalogueVehicle {
export const vehicleCatalogue: Dataset<readonly CatalogueVehicle[]> = {
id: 'vehicle-catalogue',
version: 4,
version: 5,
extract: (source) => {
const shopEntries = shopEntriesByName(source);
return source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map((vehicle) => catalogueVehicle(vehicle, shopEntries.get(vehicle.name)));
const treeOrder = new Map([...shopEntries.keys()].map((name, index) => [name, index]));
return source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map((vehicle) => catalogueVehicle(vehicle, shopEntries.get(vehicle.name), treeOrder.get(vehicle.name) ?? -1));
},
};
function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined): CatalogueVehicle {
function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined, treeOrder: number): CatalogueVehicle {
const requires = stringField(vehicle, 'reqAir');
const researchType = stringField(vehicle, 'researchType');
const requiredUnlock = stringField(shopEntry, 'reqUnlock');
@@ -88,6 +91,7 @@ function catalogueVehicle(vehicle: BlkBlock, shopEntry: BlkBlock | undefined): C
event: stringField(vehicle, 'event') !== undefined,
...(researchType ? { researchType } : {}),
inTechTree: shopEntry !== undefined,
treeOrder,
...(requiredUnlock ? { requiredUnlock } : {}),
parts: shopEntry ? shopEntry.params.flatMap((param) => (param.name === 'slaveUnit' && param.value.type === 'string' && param.value.value ? [param.value.value] : [])) : [],
onlyShownWhenOwned: boolField(shopEntry, 'showOnlyWhenBought') ?? false,