Files
WT-Offline/packages/patcher/src/char-pack.ts
T
N0VAN0M4LY d043a8f0f8 feat(accounts)!: require explicit local account registration
Open the local signup page in the game's embedded browser before sign-in. Return the existing login error for unknown accounts or invalid passwords.

BREAKING CHANGE: First-time players must register in the game's signup window or create a save in the launcher before signing in. Existing accounts can sign in with their saved credentials.
2026-11-29 18:00:21 +08:00

45 lines
2.4 KiB
TypeScript

/**
* Rebuild char.vromfs.bin: config/network.blk pointed at the local server, the offline
* version's features turned on in config/game_settings.blk, every vehicle shown in the
* tech tree (config/shop.blk), and, unless the player gave a decal source, placeholder decal
* and skin indexes (decals/offline-decal-index.ts).
*/
import { DECALS_CONFIG_PATH, offlineDecalIndex } from './decals/offline-decal-index.ts';
import { enableFeaturesForEveryone, GAME_SETTINGS_PATH, OFFLINE_FEATURES } from './features/offline-features.ts';
import type { LocalEndpoint } from './network/local-endpoint.ts';
import { redirectNetworkConfig, type NetworkRedirectReport } from './network/redirect-network-config.ts';
import { editPackBlks, readPackBlk } from './pack-edit.ts';
import { revealHiddenVehicles, SHOP_PATH } from './tech-tree/reveal-hidden-vehicles.ts';
export const NETWORK_CONFIG_PATH = 'config/network.blk';
export interface CharPackResult {
readonly pack: Uint8Array;
readonly network: NetworkRedirectReport;
/** Features that are now on for every player. */
readonly features: readonly string[];
/** Vehicles that were hidden from players who had not researched or bought them. */
readonly revealedVehicles: number;
/** Decals in the placeholder index; undefined when the index was left out. */
readonly placeholderDecals: number | undefined;
}
export interface CharPackOptions {
/** Store the placeholder decal index (false when the player's own web cache is copied). */
readonly placeholderDecals: boolean;
readonly localRegistration: boolean;
}
export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint, options: CharPackOptions): CharPackResult {
let network: NetworkRedirectReport | undefined;
let features: string[] = [];
let revealedVehicles = 0;
const decals = options.placeholderDecals ? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH)) : undefined;
const pack = editPackBlks(stockPack, [
{ path: NETWORK_CONFIG_PATH, edit: (root) => { network = redirectNetworkConfig(root, endpoint, options.localRegistration); } },
{ path: GAME_SETTINGS_PATH, edit: (root) => { features = enableFeaturesForEveryone(root, OFFLINE_FEATURES); } },
{ path: SHOP_PATH, edit: (root) => { revealedVehicles = revealHiddenVehicles(root); } },
], decals?.files ?? []);
return { pack, network: network!, features, revealedVehicles, placeholderDecals: decals?.decals };
}