Route login and character requests by their original host names on one loopback port. Add local accounts, saves, and credential redaction.
28 lines
727 B
TypeScript
28 lines
727 B
TypeScript
/**
|
|
* The game files the local service reads, opened lazily from the player's game folder.
|
|
*/
|
|
import { join } from 'node:path';
|
|
import type { BlkBlock } from '@wto/blk';
|
|
import { GamePack } from './game-pack.ts';
|
|
|
|
/** Gaijin's template for a new account's profile. */
|
|
const NEW_ACCOUNT_TEMPLATE = 'config/default_user.blk';
|
|
|
|
export class GameFiles {
|
|
readonly #gameFolder: string;
|
|
#charPack: GamePack | undefined;
|
|
|
|
constructor(gameFolder: string) {
|
|
this.#gameFolder = gameFolder;
|
|
}
|
|
|
|
newAccountTemplate(): BlkBlock {
|
|
return this.#char().readBlk(NEW_ACCOUNT_TEMPLATE);
|
|
}
|
|
|
|
#char(): GamePack {
|
|
this.#charPack ??= GamePack.open(join(this.#gameFolder, 'char.vromfs.bin'));
|
|
return this.#charPack;
|
|
}
|
|
}
|