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.
24 lines
902 B
TypeScript
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;
|
|
}
|