Files
WT-Offline/apps/server/src/saves/client-settings-cache.ts
T
N0VAN0M4LY d58ba9fb9b feat(saves)!: add offline crew editing
Add per-country crew slot controls and skill level previews to the launcher. Keep archived crews and their stable IDs in the save, update affected lineups, and back up the save before closing a slot.

Verified with both type checks, the launcher build, 2.61.0.64 patch checks, and temporary save read and write checks.

BREAKING CHANGE: The launcher automatically upgrades existing saves to format 4. Keep a pre-upgrade backup to use a save with an older launcher.
2026-12-06 15:34:24 +08:00

24 lines
902 B
TypeScript

import { lstatSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { intField } from '../profile/blk-fields.ts';
import { readBackupBlk } from './import/backup-blk.ts';
// The same local settings files accepted by the launcher's online backup import.
const SETTINGS_FILE_LIMIT = 32 * 1024 * 1024;
export function cachedSettingsVersion(folders: readonly string[], fileName: string): number {
let latest = 0;
for (const folder of folders) {
const path = join(folder, fileName);
try {
const stats = lstatSync(path);
if (!stats.isFile() || stats.size > SETTINGS_FILE_LIMIT) continue;
const version = intField(readBackupBlk(readFileSync(path)), 'version');
if (Number.isInteger(version)) latest = Math.max(latest, version);
} catch {
// A missing or unreadable cache does not have a version to supersede.
}
}
return latest;
}