A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Editor: collection CRC checks are read from the bundle cache, so player builds work again (refs #680) (#722)
Eyal Golan900f844d6712
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 505d397e4..0d5bcf96c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB## [Unreleased]+### Fixed+- Player builds work again (refs #680). Since #680 every `Build.*` failed with "no CRC for the bundle", because Unity+ reads a bundle's CRC from its `.manifest` and the collection's bundles were copied into StreamingAssets without them.+ The checks file is now written in the bundle cache and copied beside the shipped bundles.+### Changed- Sourcing audit of the MVP-window office rows (#457): the First Government row no longer cites Wikipedia (theKnesset's position records, the 14 May 1948 minutes, Ben-Gurion's diary page, the plenum records and thediff --git a/unity/Assets/Editor/CollectionImport.cs b/unity/Assets/Editor/CollectionImport.csindex ffd06cfdc..84ebfe30e 100644--- a/unity/Assets/Editor/CollectionImport.cs+++ b/unity/Assets/Editor/CollectionImport.cs@@ -193,7 +193,11 @@ namespace Statecraft.Game.EditorToolsbytes += size;Debug.Log($"BUNDLE {b} {size} bytes");}- WriteChecks(dest, manifest.GetAllAssetBundles());+ // Unity reads a bundle's CRC from its .manifest, which stays in the cache (the player ships the bundles only), so+ // the checks are written there, over the same bytes, and copied beside the shipped bundles (found by #668: from+ // #680 every player build failed with "no CRC for the bundle").+ WriteChecks(cache, manifest.GetAllAssetBundles());+ File.Copy(Path.Combine(cache, CollectionCatalog.ChecksFile), Path.Combine(dest, CollectionCatalog.ChecksFile));Debug.Log($"BUNDLES {target}: {manifest.GetAllAssetBundles().Length} bundles, {bytes} bytes -> {dest}");return Path.Combine(cache, Path.GetFileName(cache) + ".manifest");}diff --git a/unity/Assets/Tests/EditMode/CollectionImportTests.cs b/unity/Assets/Tests/EditMode/CollectionImportTests.csindex 62100e4a6..18f69ad18 100644--- a/unity/Assets/Tests/EditMode/CollectionImportTests.cs+++ b/unity/Assets/Tests/EditMode/CollectionImportTests.cs@@ -29,6 +29,33 @@ public class CollectionImportTestsstatic bool UnderResources(string path) => path.Split('/').Any(s => s.Equals("Resources", StringComparison.OrdinalIgnoreCase));+ /// <summary>Found by #668's WebGL build: every Build.* ran BuildBundles, which copied the bundles into+ /// StreamingAssets/collection without their .manifest files and then asked Unity for each one's CRC there, which Unity+ /// reads from the .manifest: "no CRC for the bundle", and no player build since #680. The real path, for the editor's+ /// build target: the shipped folder holds the bundles and a checks file whose every line matches its bundle.</summary>+ [Test]+ public void BuildBundlesWritesTheChecksBesideTheShippedBundles()+ {+ var t = Type.GetType("Statecraft.Game.EditorTools.CollectionImport, Assembly-CSharp-Editor");+ Assert.IsNotNull(t, "CollectionImport");+ try { t!.GetMethod("BuildBundles")!.Invoke(null, new object[] { EditorUserBuildSettings.activeBuildTarget }); }+ catch (System.Reflection.TargetInvocationException e) when (e.InnerException != null) { throw e.InnerException; }+ var dest = System.IO.Path.Combine(Application.streamingAssetsPath, CollectionCatalog.StreamingFolder);+ var checks = CollectionCatalog.ParseChecks(System.IO.File.ReadAllText(System.IO.Path.Combine(dest, CollectionCatalog.ChecksFile)));+ Assert.IsNotNull(checks, "a well-formed checks file");+ CollectionAssert.AreEquivalent(CollectionCatalog.Bundles.Select(b => b.Bundle), checks!.Keys);+ var cache = (string)t.GetMethod("BundleCache")!.Invoke(null, new object[] { EditorUserBuildSettings.activeBuildTarget })!;+ foreach (var (bundle, check) in checks)+ {+ var file = System.IO.Path.Combine(dest, bundle);+ Assert.IsTrue(BuildPipeline.GetCRCForAssetBundle(System.IO.Path.Combine(cache, bundle), out var crc), bundle);+ Assert.AreEqual(crc, check.Crc, $"{bundle}: Unity's CRC, from the bundle build's own manifest");+ Assert.AreEqual(new System.IO.FileInfo(file).Length, check.Bytes, bundle);+ Assert.AreEqual(CollectionCatalog.Sha256(file), check.Sha256, bundle);+ Assert.IsFalse(System.IO.File.Exists(file + ".manifest"), "the build ships no .manifest files");+ }+ }+[Test]public void TheCatalogHasThe31ModelsOfIssue664InThreeBundles(){