ship-authoring product: a hull stored with no roles takes a product with none

Zenith decodes with a null Roles list, so a station made --like it failed product with a null source. The kind and product tests cover it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-28 00:19:49 +01:00
commit 4a2cc09786
2 changed files with 7 additions and 1 deletions

View file

@ -701,6 +701,11 @@ public sealed class ShipModCatalogTests : IDisposable
Assert.Equal(0, code);
Assert.Equal("", error);
Assert.Equal("station-kind:depot", ShipAuthoringStore.Load(target).Hull.Kind.Key.Value);
// A station made like Zenith carries no roles; its product still takes none.
(code, _, error) = Run("product", target, "Zhestokost", "--name", "Probe Depot");
Assert.Equal((0, ""), (code, error));
Assert.Empty(ShipAuthoringStore.Load(target).Products.Single().Roles);
}
// validate judges a finished station package's kind with the rule Compose applies, before compose does.

View file

@ -197,7 +197,8 @@ public static class ShipAuthoringCommands
Description = count == 7 ? args[6] : null,
Design = new CultRecordRef<CraftedItemData>(ShipModCatalog.HullKey(ship.Id)),
Manufacturer = new CultRecordRef<Faction>(makerKey),
Roles = hull.Roles.Select(role => new ProductRole { Role = role.Name }).ToList(),
// A hull stored with no roles (Zenith, so a station made --like it) decodes with a null list.
Roles = (hull.Roles ?? new List<ItemRole>()).Select(role => new ProductRole { Role = role.Name }).ToList(),
NotOffered = notOffered
});
cache.FlushAsync().Wait();