Cut 8b. AetherDb.Open composes GameData/Aetheria.cc through AetheriaStores.Open, read-only unless clear-boss-hulls runs with apply; save attaches GameData/run.cc when present and reads the SavedGame global. - census, factions, station-fit, hardpoint-fit, loadout, settings, settings-dump and clear-boss-hulls read references through the null-safe Get(ref) and compare identity by record key (RefOf, from TryGetHandle). Their output formats are unchanged so Cut 9 can compare them with the Cut 0 captures. - clear-boss-hulls lands every cleared faction in one Commit. - The help line lists every command. - Deleted: doctor, migrate-products, AetherDb.Save(), and OpenWithNameFiles. The last was Cut 9's delete, but it needs the removed multi-file store, and NameFile now routes to the catalog. - FindRoot looks for Aetheria.Shared.csproj; AetherDB.msgpack leaves in Cut 9. It compiles. It cannot run until Cut 9 writes Aetheria.cc, so the pre-cut captures do not apply to this cut. Builds: Aetheria.Shared, AetherDb. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using GameCult.Caching;
|
|
|
|
// Opens GameData/Aetheria.cc through AetheriaStores, the game's own store composition. The catalog attaches read-only
|
|
// unless a command writes it, so a command that only reads cannot write.
|
|
public sealed class AetherDb
|
|
{
|
|
public string Root { get; }
|
|
public CultCache Cache { get; }
|
|
|
|
private AetherDb(string root, bool catalogWritable, bool withRun)
|
|
{
|
|
Root = root;
|
|
var gameData = Path.Combine(root, "GameData");
|
|
Cache = AetheriaStores.Open(
|
|
Path.Combine(gameData, "Aetheria.cc"),
|
|
runPath: withRun ? Path.Combine(gameData, "run.cc") : null,
|
|
catalogWritable: catalogWritable);
|
|
}
|
|
|
|
// With no root given, walks up from the working directory to the repository
|
|
public static AetherDb Open(bool catalogWritable = false, bool withRun = false, string root = null) =>
|
|
new AetherDb(root ?? FindRoot(), catalogWritable, withRun);
|
|
|
|
public static string FindRoot()
|
|
{
|
|
for (var dir = new DirectoryInfo(Environment.CurrentDirectory); dir != null; dir = dir.Parent)
|
|
if (File.Exists(Path.Combine(dir.FullName, "Aetheria.Shared", "Aetheria.Shared.csproj")))
|
|
return dir.FullName;
|
|
throw new DirectoryNotFoundException("Run from inside the Aetheria repository.");
|
|
}
|
|
}
|