A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Unity: smoke flag ignores the URL fragment (Fixes #2264) (#2280)
Berif923366785b6
diff --git a/changelog.d/2264-smoke-fragment.md b/changelog.d/2264-smoke-fragment.mdnew file mode 100644index 000000000..46b585e76--- /dev/null+++ b/changelog.d/2264-smoke-fragment.md@@ -0,0 +1,3 @@+### Fixed++- A smoke flag in the part of the page URL after the `#` no longer starts a smoke run; only the query counts (Fixes #2264).diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex ff303d013..0f71e30f8 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -202,7 +202,10 @@ namespace Statecraft.Game.UI{if (webgl){- var m = SmokeQuery.Match(url ?? "");+ // Only the query counts: a flag after the '#' is the fragment (#2264; UrlFlags does the same since #2215).+ var query = url ?? "";+ var hash = query.IndexOf('#');+ var m = SmokeQuery.Match(hash < 0 ? query : query.Substring(0, hash));if (!m.Success) return 0;var digits = m.Groups[1].Value;return digits.Length == 0 ? DefaultSmokeTurns : int.TryParse(digits, NumberStyles.None, CultureInfo.InvariantCulture, out var n) ? n : 0;diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex b864db84c..0f86f92db 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -943,6 +943,9 @@ public class GameSceneTestsAssert.AreEqual(3, Web("http://localhost:8000/?smoke=3"));Assert.AreEqual(3, Web("http://localhost:8000/?smoke=3&golden"));Assert.AreEqual(3, Web("http://localhost:8000/?smoke=3#top"));+ Assert.AreEqual(0, Web("http://localhost:8000/index.html#&smoke=5"), "#2264: a flag after the '#' is not the query");+ Assert.AreEqual(0, Web("http://localhost:8000/index.html?a=1#&smoke"), "bare, after the '#'");+ Assert.AreEqual(3, Web("http://localhost:8000/?smoke=3#&smoke=9"), "the query wins over the fragment");Assert.AreEqual(GameRoot.DefaultSmokeTurns, Web("http://localhost:8000/?smoke"));Assert.AreEqual(GameRoot.DefaultSmokeTurns, Web("http://localhost:8000/?smoke&golden"));Assert.AreEqual(GameRoot.DefaultSmokeTurns, Web("http://localhost:8000/?golden&smoke="));