/** * Dataset: the game's own SVG icons that the local web pages (store and marketplace, shown in * the in-game browser; implementation notes) display, taken from the player's * ui/atlases.vromfs.bin at runtime. The dataset uses these entries. * gameuiskin/_ico.svg the tech-tree silhouette of a vehicle * gameuiskin/.svg a country flag (country_usa, ...) * * All 3349 vehicle icons together are about 26 MB, so only premium and store/market vehicles * are kept: gift vehicles (wpcost.blk gift:t), Golden Eagle premium vehicles (wpcost.blk * costGold > 0, used by starter packs and custom multi-vehicle packs), and marketplace * vehicles (shop.blk marketplaceItemdefId). */ import { numberField, stringField } from './blk-fields.ts'; import type { Dataset } from './dataset.ts'; import { shopCountryNames, shopEntriesByName } from './shop-tree.ts'; const ATLASES = 'ui/atlases.vromfs.bin'; const VEHICLE_ECONOMY = 'config/wpcost.blk'; const ICON_FOLDER = 'gameuiskin/'; export interface WebIcons { /** Vehicle name -> SVG text. */ readonly vehicles: Readonly>; /** Country (country_usa, ...) -> SVG text. */ readonly flags: Readonly>; } export const webIcons: Dataset = { id: 'web-icons', version: 3, extract: (source) => { // Archive paths in ui/atlases.vromfs.bin are lowercase, whereas unit IDs in wpcost.blk // mix uppercase and lowercase (e.g. germ_pzkpfw_VI_ausf_h1_tiger_east, ussr_t_26E). const byLowerPath = new Map(source.listFiles(ATLASES).map((path) => [path.toLowerCase(), path])); const readIcon = (name: string): string | undefined => { const actualPath = byLowerPath.get(`${ICON_FOLDER}${name}.svg`.toLowerCase()); return actualPath ? source.readText(ATLASES, actualPath) : undefined; }; const shopEntries = shopEntriesByName(source); const vehicles: Record = {}; for (const vehicle of source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks) { const needIcon = stringField(vehicle, 'gift') !== undefined || (numberField(vehicle, 'costGold') ?? 0) > 0 || numberField(shopEntries.get(vehicle.name), 'marketplaceItemdefId') !== undefined; const icon = needIcon ? readIcon(`${vehicle.name}_ico`) : undefined; if (icon) vehicles[vehicle.name] = icon; } const flags: Record = {}; for (const country of shopCountryNames(source)) { const flag = readIcon(country); if (flag) flags[country] = flag; } return { vehicles, flags }; }, };