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.
This commit is contained in:
1 parent
264c5c59b8
commit
d58ba9fb9b
31 files changed
+1021
-139
No files matched your search
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user