Missing ship.cc fails the fixture, not the game's compose

The game treats a directory without ship.cc as not a package (TheBootCatalogIsTheShippedOneUntilAModIsInstalled), so da4d8c6c's
Compose exclusion broke that test. Reverts the Compose and ResolveCatalog change and moves the check to the one place that
holds the first-party tree to a stricter rule: TestCatalog.Resolve throws, naming each directory under GameData/Mods that
holds no ship.cc (missing-ship-cc-skipped). The GLB case change and the registry parameters stand.

Builds; not yet run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-10 07:35:08 +02:00
commit 1047698568
3 changed files with 11 additions and 24 deletions

View file

@ -67,9 +67,8 @@ public static class ShipModCatalog
foreach (var directory in Directory.GetDirectories(root).OrderBy(path => path, StringComparer.Ordinal))
{
var path = Path.Combine(directory, "ship.cc");
if (!File.Exists(path)) continue;
var name = Path.GetFileName(directory);
// A package directory without its ship.cc is a package that lost its records, named like any other failure.
if (!File.Exists(path)) { Exclude(name, "the package holds no ship.cc."); continue; }
// A package can fail in any way a hostile or broken file can, so its failure is quarantined whatever it is.
try { packages.Add((name, ReadPackage(path))); }
catch (Exception error) { Exclude(name, error.Message); }
@ -157,7 +156,8 @@ public static class ShipModCatalog
public static (string Catalog, Exclusion[] Excluded) ResolveCatalog(string shippedCatalog, string derivedCatalog, string modsRoot,
CultDocumentRegistry registry = null)
{
if (!Directory.Exists(modsRoot) || Directory.GetDirectories(modsRoot).Length == 0)
if (!Directory.Exists(modsRoot) ||
!Directory.GetDirectories(modsRoot).Any(directory => File.Exists(Path.Combine(directory, "ship.cc"))))
return (shippedCatalog, Array.Empty<Exclusion>());
Composition composition;
// A failure of the composition itself (an unwritable derived path, say) is still a mod problem, never a reason not to boot.

View file

@ -286,27 +286,6 @@ public sealed class ShipModCatalogTests : IDisposable
Assert.Equal("ship ID collides with an existing catalog ship authoring record.", Assert.Single(composition.Excluded).Reason);
}
// A package directory that lost its ship.cc is a package left out, named with the reason; it never vanishes silently.
[Fact]
public void APackageDirectoryWithoutAShipFileIsExcludedWithAReason()
{
WritePackage("mod.good", hullName: "Good");
WritePackage("mod.lost", hullName: "Lost");
File.Delete(Path.Combine(Mods, "mod.lost", "ship.cc"));
var composition = ShipModCatalog.Compose(Shipped, Derived, Mods);
Assert.Equal(new[] { "mod.good" }, composition.Included);
var lost = Assert.Single(composition.Excluded);
Assert.Equal("mod.lost", lost.Package);
Assert.Equal("the package holds no ship.cc.", lost.Reason);
Directory.Delete(Path.Combine(Mods, "mod.good"), true);
var (catalog, excluded) = ShipModCatalog.ResolveCatalog(Shipped, Derived, Mods);
Assert.Equal(Shipped, catalog);
Assert.Equal("mod.lost", Assert.Single(excluded).Package);
}
// The loader and the LFS rule (GameData/Mods/**/*.glb) agree: only a lowercase .glb is a model.
[Fact]
public void AModelWithAnUppercaseExtensionIsRefused()

View file

@ -36,6 +36,14 @@ internal static class TestCatalog
public static string Resolve(string shippedCatalog, string modsRoot, string workDir)
{
// Every directory under the first-party tree is a package. The game treats a directory without a ship.cc as not a
// package (a stray folder is not an error for a player), so the compose never names it; a first-party package whose
// ship.cc is gone must not vanish from the catalog the suite stages from.
var lost = Directory.Exists(modsRoot)
? Directory.GetDirectories(modsRoot).Where(directory => !File.Exists(Path.Combine(directory, "ship.cc"))).Select(Path.GetFileName).OrderBy(name => name, StringComparer.Ordinal).ToArray()
: Array.Empty<string>();
if (lost.Length > 0)
throw new InvalidOperationException("First-party packages hold no ship.cc: " + string.Join(", ", lost));
var (catalog, excluded) = ShipModCatalog.ResolveCatalog(shippedCatalog, Path.Combine(workDir, "derived.cc"), modsRoot, Registry());
if (excluded.Length > 0)
throw new InvalidOperationException("First-party packages were excluded from the catalog: " +