chore(battle): snapshot the LocalMP rework baseline
Records the uncommitted battle-session work exactly as it was left (local service matchmaking, settlement, chat, native LocalMP hooks, battle gui/exe patches) so the following review and rework commits show every correction as a diff against this state. This commit is not reviewed and is known to be incomplete: in-game testing reported wrong settlement rewards, single-country teams, missing random/fixed supplement slots, misattributed hit messages and other regressions. Do not merge this branch before the rework lands.
This commit is contained in:
1 parent
5c9204c031
commit
b260d2899e
97 files changed
+7676
-396
No files matched your search
@@ -1,9 +1,15 @@
|
||||
/**
|
||||
* Per-player cloud settings persistence inside `<data>/saves/<userId>/cloud-settings/`
|
||||
*. Keeping cloud settings inside each player's save directory means
|
||||
* copying `saves/<userId>/` to another machine or fresh client folder carries all game
|
||||
* options, keybinds, HUD settings, presets, and map preferences along automatically.
|
||||
* Per-player cloud settings persistence inside `<data>/saves/<userId>/cloud-settings/`.
|
||||
* Keeping cloud settings inside each player's save directory means copying `saves/<userId>/`
|
||||
* to another machine or fresh client folder carries all game options, keybinds, HUD settings,
|
||||
* presets, and map preferences along automatically.
|
||||
*
|
||||
* When an account has no saved `GBT_GENERAL_SETTINGS.blk` yet, version 1 is seeded once with
|
||||
* `hudShowFuel = 2` and `hudShowAmmo = 2` ("Always", `aces.exe` 0xf4cc1f..0xf4cc55) so the
|
||||
* top-left ground/air weapon and fuel HUD indicators are visible out of the box without
|
||||
* overriding any subsequent change the player makes in the in-game Options menu.
|
||||
*/
|
||||
import { createHash } from 'node:crypto';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { decodeBlk, emptyBlock, encodeBlk, ensureBlock, setParam, type BlkBlock } from '@wto/blk';
|
||||
@@ -27,6 +33,7 @@ export const GENERAL_BLK_TYPES = [
|
||||
export const SUPPORTED_CLOUD_COMPRESSIONS = 'zstd;zlib;gzip';
|
||||
|
||||
const SUPPORTED_BLK_TYPE_SET: ReadonlySet<string> = new Set(GENERAL_BLK_TYPES);
|
||||
const HUD_SHOW_ALWAYS = 2;
|
||||
|
||||
export interface ParsedGblkUpload {
|
||||
readonly blkType: string;
|
||||
@@ -54,6 +61,7 @@ export class CloudSettingsStore {
|
||||
}
|
||||
|
||||
buildMetaBlk(userId?: string, blockName?: string): BlkBlock {
|
||||
if (userId && isValidUserId(userId)) this.#ensureDefaultGeneralSettings(userId);
|
||||
const meta = blockName ? emptyBlock(blockName) : emptyBlock();
|
||||
setParam(meta, 'machineHash', { type: 'string', value: `hhh${userId ?? '0'}` });
|
||||
setParam(meta, 'compressionSupported', { type: 'string', value: SUPPORTED_CLOUD_COMPRESSIONS });
|
||||
@@ -78,6 +86,7 @@ export class CloudSettingsStore {
|
||||
|
||||
loadContainer(userId: string, blkType: string): BlkBlock | undefined {
|
||||
if (!isValidUserId(userId) || !isSupportedGeneralBlkType(blkType)) return undefined;
|
||||
if (blkType === 'GBT_GENERAL_SETTINGS') this.#ensureDefaultGeneralSettings(userId);
|
||||
const blkPath = this.#blkPath(userId, blkType);
|
||||
if (!existsSync(blkPath)) return undefined;
|
||||
try {
|
||||
@@ -111,6 +120,18 @@ export class CloudSettingsStore {
|
||||
return savedCount;
|
||||
}
|
||||
|
||||
#ensureDefaultGeneralSettings(userId: string): void {
|
||||
const blkPath = this.#blkPath(userId, 'GBT_GENERAL_SETTINGS');
|
||||
if (existsSync(blkPath)) return;
|
||||
const { container, contentHash } = buildDefaultGeneralSettings();
|
||||
this.saveUpload(userId, {
|
||||
blkType: 'GBT_GENERAL_SETTINGS',
|
||||
version: 1,
|
||||
contentHash,
|
||||
container,
|
||||
});
|
||||
}
|
||||
|
||||
#loadMeta(userId: string): CloudSettingsMetaFile {
|
||||
const metaPath = this.#metaPath(userId);
|
||||
if (!existsSync(metaPath)) return { formatVersion: 1, blocks: {} };
|
||||
@@ -138,6 +159,24 @@ export class CloudSettingsStore {
|
||||
}
|
||||
}
|
||||
|
||||
function buildDefaultGeneralSettings(): { readonly container: BlkBlock; readonly contentHash: string } {
|
||||
const content = emptyBlock('content');
|
||||
const profile = ensureBlock(content, 'profile');
|
||||
const settings = ensureBlock(profile, 'settings');
|
||||
setParam(settings, 'hudShowFuel', { type: 'int', value: HUD_SHOW_ALWAYS });
|
||||
setParam(settings, 'hudShowAmmo', { type: 'int', value: HUD_SHOW_ALWAYS });
|
||||
|
||||
const hashRoot = emptyBlock();
|
||||
hashRoot.params.push(...content.params);
|
||||
hashRoot.blocks.push(...content.blocks);
|
||||
const contentHash = createHash('md5').update(encodeBlk(hashRoot)).digest('hex');
|
||||
|
||||
const container = emptyBlock();
|
||||
setParam(container, 'version', { type: 'int', value: 1 });
|
||||
container.blocks.push(content);
|
||||
return { container, contentHash };
|
||||
}
|
||||
|
||||
function isValidUserId(userId: string): boolean {
|
||||
return /^\d+$/.test(userId);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user