A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Sim: name the missing locality_hexes.yaml in the regions error (Fixes #2298) (#2316)
Beri2418469a9d36
diff --git a/changelog.d/2298-locality-hexes-required.md b/changelog.d/2298-locality-hexes-required.mdnew file mode 100644index 000000000..8451977fa--- /dev/null+++ b/changelog.d/2298-locality-hexes-required.md@@ -0,0 +1 @@+- GDD 0.3 content with `regions.yaml` but no `map/locality_hexes.yaml` is now refused with an error that names the missing file, instead of "unknown place id" on the region rows (#2298). The shipped game already has the file.diff --git a/sim/Statecraft.Sim.Tests/PlayerRegionsContentTests.cs b/sim/Statecraft.Sim.Tests/PlayerRegionsContentTests.csindex d2663b9fd..201700ce3 100644--- a/sim/Statecraft.Sim.Tests/PlayerRegionsContentTests.cs+++ b/sim/Statecraft.Sim.Tests/PlayerRegionsContentTests.cs@@ -249,14 +249,15 @@ public class PlayerRegionsContentTestsAssert.Equal("regions.yaml: player_regions[1].field_hexes[0]: must be one of the region's member_hexes", e.Message);}- // The site is listed first, so it must resolve (sites.yaml is always placed) before the locality is refused.+ // regions.yaml names localities, so map/locality_hexes.yaml is required with it: a missing file is refused by name+ // instead of every locality member failing as "unknown place id" (#2298).[Fact]- public void WithoutTheLocalityHexesALocalityIsUnknown()+ public void WithoutTheLocalityHexesTheRegionsAreRefusedNamingTheFile(){var e = Assert.Throws<ContentException>(() => Load("player_regions:\n"+ LocalityAndSite.Replace("[tarshiha, kiryat_shmona]", "[kiryat_shmona, tarshiha]"), localities: false));- Assert.Equal("regions.yaml", e.File); Assert.Equal("player_regions[0].member_locations[1]", e.Field);- Assert.Equal("regions.yaml: player_regions[0].member_locations[1]: unknown place id", e.Message);+ Assert.Equal(PlayerRegionCatalogue.LocalityHexesFileName, e.File); Assert.Equal("(file)", e.Field);+ Assert.Equal("map/locality_hexes.yaml: (file): missing file", e.Message);}// map/locality_hexes.yaml is generated, but the sim still refuses a malformed row instead of placing it: thediff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.csindex df9e66ef5..27690deb6 100644--- a/sim/Statecraft.Sim/ContentLoader.cs+++ b/sim/Statecraft.Sim/ContentLoader.cs@@ -195,9 +195,8 @@ namespace Statecraft.Sim/// <summary>R-CITY-006: the locality placements, with the settlement_hexes.yaml checks (unique ids, land hexes) and/// q and r required. Only the exact gdd-0.3 regions path calls this.</summary>- static List<SettlementHex>? LocalityHexes(Content c, LocalityHexesFile? file)+ static List<SettlementHex>? LocalityHexes(Content c, LocalityHexesFile file){- if (file == null) return null;const string f = PlayerRegionCatalogue.LocalityHexesFileName;Unique(f, "localities", file.Localities.Select(l => l.Id));var result = new List<SettlementHex>(file.Localities.Count);@@ -458,13 +457,13 @@ namespace Statecraft.Simc.StartingForces = StartingForces.Read(readFile, c);}// R-CITY-006: no read or hash input in either old identity. Absence leaves the capability inactive. After the- // sites (a site id may be a member) and the effective map overrides; the locality hexes are read only with regions.+ // sites (a site id may be a member) and the effective map overrides; the locality hexes are read only with regions, and are required then (#2298).if (c.Ruleset == SaveGame.Gdd03Ruleset){var regions = ReadOptional<PlayerRegionsFile>(readFile, PlayerRegionCatalogue.FileName);if (regions != null)c.PlayerRegions = PlayerRegionCatalogue.Validate(c, regions.PlayerRegions,- LocalityHexes(c, ReadOptional<LocalityHexesFile>(readFile, PlayerRegionCatalogue.LocalityHexesFileName)));+ LocalityHexes(c, Read<LocalityHexesFile>(readFile, PlayerRegionCatalogue.LocalityHexesFileName)));}EventRules.ValidateStructured(c); // R-EFX-006: after the GDD records it names are readc.BuildWindows();