Expand typed catalog migration surface

This commit is contained in:
Meta Vens 2026-06-13 08:09:41 +01:00
commit 7a2cc28c57
149 changed files with 461 additions and 277 deletions

Binary file not shown.

View file

@ -219,6 +219,7 @@ internal static class LegacyCatalogReader
var legacyId = GetGuid(payload, 0);
var name = GetString(payload, 1);
var description = GetString(payload, 2);
var shape = ReadShape(payload, 5);
var summary = new AetheriaLegacyCatalogEntrySummary
{
LegacyId = legacyId,
@ -238,7 +239,12 @@ internal static class LegacyCatalogReader
LegacyId = legacyId,
Description = description,
Mass = GetDouble(payload, 4),
Volume = GetArrayLength(payload, 5),
Volume = shape.OccupiedCells,
ManufacturerLegacyId = GetGuid(payload, 3),
Price = GetInt(payload, 8),
ShapeWidth = shape.Width,
ShapeHeight = shape.Height,
OccupiedCells = shape.OccupiedCells,
Tags = [unionName, "legacy-catalog"]
}
: null,
@ -247,7 +253,15 @@ internal static class LegacyCatalogReader
{
Name = name,
LegacyId = legacyId,
Description = description
ShortName = GetString(payload, 2),
Description = GetString(payload, 3),
GeonameFileLegacyId = GetGuid(payload, 9),
BossHullLegacyId = GetGuid(payload, 10),
InfluenceDistance = GetInt(payload, 11),
AllegianceCount = GetMapCount(payload, 12),
OverworldMusic = GetUInt(payload, 13),
CombatMusic = GetUInt(payload, 14),
BossMusic = GetUInt(payload, 15)
}
: null,
unionKey == 9
@ -382,6 +396,45 @@ internal static class LegacyCatalogReader
};
}
private static int GetInt(IReadOnlyDictionary<int, object?> payload, int key)
{
if (!payload.TryGetValue(key, out var value) || value == null)
{
return 0;
}
return value switch
{
long integerValue => checked((int) integerValue),
int integerValue => integerValue,
double doubleValue => checked((int) doubleValue),
float floatValue => checked((int) floatValue),
_ => 0
};
}
private static uint GetUInt(IReadOnlyDictionary<int, object?> payload, int key)
{
if (!payload.TryGetValue(key, out var value) || value == null)
{
return 0;
}
return value switch
{
long integerValue when integerValue >= 0 => checked((uint) integerValue),
int integerValue when integerValue >= 0 => checked((uint) integerValue),
double doubleValue when doubleValue >= 0 => checked((uint) doubleValue),
float floatValue when floatValue >= 0 => checked((uint) floatValue),
_ => 0
};
}
private static int GetMapCount(IReadOnlyDictionary<int, object?> payload, int key)
{
return payload.TryGetValue(key, out var value) && value is Dictionary<string, object?> map ? map.Count : 0;
}
private static int GetArrayLength(IReadOnlyDictionary<int, object?> payload, int key)
{
return payload.TryGetValue(key, out var value) && value is object?[] array ? array.Length : 0;
@ -393,6 +446,50 @@ internal static class LegacyCatalogReader
? array.OfType<string>().Take(max).ToArray()
: [];
}
private static ShapeFacts ReadShape(IReadOnlyDictionary<int, object?> payload, int key)
{
if (!payload.TryGetValue(key, out var value) || value == null)
{
return new ShapeFacts(0, 0, 0);
}
var matrix = UnwrapShapeMatrix(value);
if (matrix is not object?[] columns)
{
return new ShapeFacts(0, 0, 0);
}
var width = columns.Length;
var height = 0;
var occupied = 0;
foreach (var column in columns)
{
if (column is not object?[] cells)
{
if (column is bool occupiedCell)
{
height = Math.Max(height, 1);
if (occupiedCell)
{
occupied++;
}
}
continue;
}
height = Math.Max(height, cells.Length);
occupied += cells.Count(cell => cell is true);
}
return new ShapeFacts(width, height, occupied);
}
private static object? UnwrapShapeMatrix(object? value)
{
return value is object?[] shapeObject && shapeObject.Length == 1 ? shapeObject[0] : value;
}
}
internal sealed record LegacyCatalogEntry(
@ -400,3 +497,5 @@ internal sealed record LegacyCatalogEntry(
AetheriaItemDefinition? ItemDefinition,
AetheriaCorporation? Corporation,
AetheriaNameFile? NameFile);
internal readonly record struct ShapeFacts(int Width, int Height, int OccupiedCells);

View file

@ -36,6 +36,37 @@ if (nameFiles.Length == 0)
throw new InvalidOperationException("Typed state has no name files.");
}
var pricedItems = items.Count(item => item.Price > 0);
var manufacturedItems = items.Count(item => !string.IsNullOrWhiteSpace(item.ManufacturerLegacyId));
var shapedItems = items.Count(item => item.ShapeWidth > 0 && item.ShapeHeight > 0 && item.OccupiedCells > 0);
var describedCorporations = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.Description));
var corporationNameLinks = corporations.Count(corporation => !string.IsNullOrWhiteSpace(corporation.GeonameFileLegacyId));
if (pricedItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any prices.");
}
if (manufacturedItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any manufacturer legacy IDs.");
}
if (shapedItems == 0)
{
throw new InvalidOperationException("Typed item definitions did not import any shape dimensions.");
}
if (describedCorporations == 0)
{
throw new InvalidOperationException("Typed corporations did not import descriptions from legacy key 3.");
}
if (corporationNameLinks == 0)
{
throw new InvalidOperationException("Typed corporations did not import geoname file legacy IDs.");
}
await RequireLegacyLookupAsync(
items[0].LegacyId,
() => node.GetItemDefinitionByLegacyIdAsync(items[0].LegacyId),
@ -57,7 +88,9 @@ if (string.IsNullOrWhiteSpace(quarantine.CatalogFingerprint))
Console.WriteLine($"Aetheria typed state verify passed: {statePath}");
Console.WriteLine($"Catalog fingerprint: {quarantine.CatalogFingerprint}");
Console.WriteLine($"Item definitions: {items.Length}");
Console.WriteLine($"Priced/manufactured/shaped items: {pricedItems}/{manufacturedItems}/{shapedItems}");
Console.WriteLine($"Corporations: {corporations.Length}");
Console.WriteLine($"Described/geoname-linked corporations: {describedCorporations}/{corporationNameLinks}");
Console.WriteLine($"Name files: {nameFiles.Length}");
static void RequireCount(AetheriaMigrationLedger ledger, string documentType, int actual)

View file

@ -16,5 +16,31 @@ public sealed class AetheriaCorporation
public string LegacyId { get; set; } = "";
[Key(2)]
public string ShortName { get; set; } = "";
[Key(3)]
public string Description { get; set; } = "";
[Key(4)]
[CultIndex("geonameFileLegacyId")]
public string GeonameFileLegacyId { get; set; } = "";
[Key(5)]
[CultIndex("bossHullLegacyId")]
public string BossHullLegacyId { get; set; } = "";
[Key(6)]
public int InfluenceDistance { get; set; }
[Key(7)]
public int AllegianceCount { get; set; }
[Key(8)]
public uint OverworldMusic { get; set; }
[Key(9)]
public uint CombatMusic { get; set; }
[Key(10)]
public uint BossMusic { get; set; }
}

View file

@ -30,4 +30,20 @@ public sealed class AetheriaItemDefinition
[Key(6)]
public string[] Tags { get; set; } = [];
[Key(7)]
[CultIndex("manufacturerLegacyId")]
public string ManufacturerLegacyId { get; set; } = "";
[Key(8)]
public int Price { get; set; }
[Key(9)]
public int ShapeWidth { get; set; }
[Key(10)]
public int ShapeHeight { get; set; }
[Key(11)]
public int OccupiedCells { get; set; }
}

View file

@ -42,14 +42,19 @@ state: path, size, and SHA-256 fingerprint for `AetherDB.msgpack` plus
raw MessagePack union pass that maps stable catalog fields into typed
item/faction/name-file documents without compiling Unity's legacy domain model
into `Aetheria.State`. The current checked-in catalog maps to 115 item
definitions, 12 factions, and 12 name files. Runtime object graphs, behaviors,
Unity shapes, and simulation state remain legacy until dedicated typed
definitions, 12 factions, and 12 name files. Typed item definitions include
legacy manufacturer IDs, price, shape dimensions, and occupied cell counts.
Typed corporation documents include the legacy short name, the true description
field from key 3, name-file and boss-hull legacy IDs, influence distance,
allegiance count, and music bank IDs. Runtime object graphs, behaviors, full
Unity shape masks, and simulation state remain legacy until dedicated typed
documents exist.
`Aetheria.State.Verify` opens a materialized state file and checks that the
typed migration ledger matches the actual item, corporation, and name-file
records in the `.cc` store. It also verifies the canonical legacy-ID lookup API
for one migrated record of each catalog kind. Use it after import when
for one migrated record of each catalog kind and checks that expanded item and
corporation catalog facts survived materialization. Use it after import when
`GameData/aetheria-world.cc` changes.
Current rebuild notes:

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more