Fix vehicle icon lookup and default web account selection
Match archive paths without regard to case and include Golden Eagle vehicles in icon extraction. Default read-only page state to the current in-game account. Keep web mutations gated on an explicit account ID. Type checking and local icon and account selection checks passed. In-game acceptance is pending.
This commit is contained in:
1 parent
26fd6b51b7
commit
ec2d3ffbc4
6 files changed
+63
-24
No files matched your search
@@ -5,9 +5,10 @@
|
||||
* gameuiskin/<vehicle>_ico.svg the tech-tree silhouette of a vehicle
|
||||
* gameuiskin/<country>.svg a country flag (country_usa, ...)
|
||||
*
|
||||
* All 3349 vehicle icons together are about 26 MB, so only the vehicles the stock game sells
|
||||
* for real money are kept: gift vehicles (wpcost.blk gift:t, the store's packs) and
|
||||
* marketplace vehicles (shop.blk marketplaceItemdefId).
|
||||
* 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';
|
||||
@@ -26,20 +27,23 @@ export interface WebIcons {
|
||||
|
||||
export const webIcons: Dataset<WebIcons> = {
|
||||
id: 'web-icons',
|
||||
version: 1,
|
||||
version: 3,
|
||||
extract: (source) => {
|
||||
const available = new Set(source.listFiles(ATLASES));
|
||||
// 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 path = `${ICON_FOLDER}${name}.svg`;
|
||||
return available.has(path) ? source.readText(ATLASES, path) : undefined;
|
||||
const actualPath = byLowerPath.get(`${ICON_FOLDER}${name}.svg`.toLowerCase());
|
||||
return actualPath ? source.readText(ATLASES, actualPath) : undefined;
|
||||
};
|
||||
|
||||
const shopEntries = shopEntriesByName(source);
|
||||
const vehicles: Record<string, string> = {};
|
||||
for (const vehicle of source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks) {
|
||||
const soldForMoney = stringField(vehicle, 'gift') !== undefined
|
||||
const needIcon = stringField(vehicle, 'gift') !== undefined
|
||||
|| (numberField(vehicle, 'costGold') ?? 0) > 0
|
||||
|| numberField(shopEntries.get(vehicle.name), 'marketplaceItemdefId') !== undefined;
|
||||
const icon = soldForMoney ? readIcon(`${vehicle.name}_ico`) : undefined;
|
||||
const icon = needIcon ? readIcon(`${vehicle.name}_ico`) : undefined;
|
||||
if (icon) vehicles[vehicle.name] = icon;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user