A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: the service train stops at the Old City wall gap (Fixes #2021) (#2058)
Beri17f58d37be3d
diff --git a/changelog.d/2021.md b/changelog.d/2021.mdnew file mode 100644index 000000000..bc4fa1b73--- /dev/null+++ b/changelog.d/2021.md@@ -0,0 +1,4 @@+### Fixed+- The service train stops where the drawn railway ends, at the gap in Jerusalem's symbolic Old City wall (#2021):+ it rode the uncut trace and ran on about 1.3 km through the wall to the station inside the square. The Lod end+ is unchanged.diff --git a/unity/Assets/Scripts/Map/Routes/ServiceTrain.cs b/unity/Assets/Scripts/Map/Routes/ServiceTrain.csindex ba0294798..fd9e2dcb6 100644--- a/unity/Assets/Scripts/Map/Routes/ServiceTrain.cs+++ b/unity/Assets/Scripts/Map/Routes/ServiceTrain.cs@@ -70,7 +70,7 @@ namespace Statecraft.Game.Map.Routesvar go = new GameObject(Name);go.transform.SetParent(parent, false);var t = go.AddComponent<ServiceTrain>();- t.line = RouteLayer.World(frame, route);+ t.line = RouteLayer.Drawn(frame, route); // the line the rail ribbon draws, cut at the Old City walls (#2021)t.assets = assets;t.data = data; t.origin = origin;t.startAt = frame.ToWorld(s.StartLon, s.StartLat, 0);diff --git a/unity/Assets/Tests/EditMode/ServiceTrainTests.cs b/unity/Assets/Tests/EditMode/ServiceTrainTests.csindex 236ed8a67..9b0fe6fae 100644--- a/unity/Assets/Tests/EditMode/ServiceTrainTests.cs+++ b/unity/Assets/Tests/EditMode/ServiceTrainTests.cs@@ -281,7 +281,7 @@ public class ServiceTrainTests{var (start, end) = train.Stretch;Assert.Less((Flat(train.At(start)) - W(map, TelAvivSouth)).magnitude, 1000f, "from Tel Aviv South");- Assert.Less((Flat(train.At(end)) - W(map, Jerusalem)).magnitude, 1000f, "to Jerusalem");+ Assert.Less((Flat(train.At(end)) - W(map, Jerusalem)).magnitude, 1400f, "to Jerusalem (the wall gap, about 1.3 km short of the station: #2021)");}finally { Object.DestroyImmediate(map.gameObject); }}@@ -307,7 +307,7 @@ public class ServiceTrainTestsvar line = RouteLayer.World(map.Frame, BootRoutes().Single(r => r.Id == RouteLayer.TrainRoute));var (start, end) = train.Stretch;Assert.Less((Flat(train.At(start)) - W(map, Lod)).magnitude, 1000f, "it starts at Lod");- Assert.Less((Flat(train.At(end)) - W(map, Jerusalem)).magnitude, 1000f, "and ends at Jerusalem");+ Assert.Less((Flat(train.At(end)) - W(map, Jerusalem)).magnitude, 1400f, "and ends at Jerusalem (the wall gap, about 1.3 km short of the station: #2021)");Assert.That(end - start, Is.InRange(50000f, 80000f), "Lod to Jerusalem by the Sorek valley, about 65 km of the line");Assert.AreEqual(RouteTrain.ModelRealLengthM * RouteTrain.Scale * ServiceTrain.ModelSize, train.Length, 1f, "the showcase's locomotive and tender, at ModelSize");@@ -330,6 +330,33 @@ public class ServiceTrainTestsfinally { Object.DestroyImmediate(map.gameObject); }}+ /// <summary>Issue #2021: the train runs on the line the map draws (RouteLayer.Drawn, cut at the symbolic Old City's+ /// walls), not the uncut trace, so it stops at the wall gap and never runs on through the walls to the station inside+ /// the square; the Lod end, far outside the square, is where it was.</summary>+ [Test]+ public void TheTrainStopsAtTheWallGapAndItsLodEndIsUnchanged()+ {+ var (map, train) = RunningTrain();+ try+ {+ var route = BootRoutes().Single(r => r.Id == RouteLayer.TrainRoute);+ var world = RouteLayer.World(map.Frame, route);+ var drawn = RouteLayer.Drawn(map.Frame, route);+ var (centre, half) = Statecraft.Game.Map.Kits.SettlementKits.OldCityWalls(map.Frame);+ bool Inside(Vector2 p) => Mathf.Abs(p.x - centre.x) < half - 1f && Mathf.Abs(p.y - centre.y) < half - 1f;+ Assert.IsTrue(Inside(W(map, Jerusalem)), "non-vacuous: the station is inside the walled square");+ Assert.IsTrue(Inside(world[world.Count - 1]), "and the traced line runs on to it");+ var (start, end) = train.Stretch;+ var stop = Flat(train.At(end));+ TestContext.WriteLine($"the train stops {(stop - drawn[drawn.Count - 1]).magnitude:0} m from the drawn rail's end, {(stop - W(map, Jerusalem)).magnitude:0} m from the station");+ Assert.IsFalse(Inside(stop), "the train stops at the walls, not inside them");+ Assert.Less((stop - drawn[drawn.Count - 1]).magnitude, 60f, "at the drawn rail's end, the wall gap");+ float lodOff = DistanceToLine(W(map, Lod), world);+ Assert.AreEqual(lodOff, (Flat(train.At(start)) - W(map, Lod)).magnitude, 60f, "the Lod end is the traced line's point nearest Lod, as before");+ }+ finally { Object.DestroyImmediate(map.gameObject); }+ }+/// <summary>The owner's ruling for #668 (16 October 2026, "ride the track, cut walls"): every car rides the line. Each/// car's base stays within <see cref="LineBoundM"/> of the line's height (the rail ribbon plus RouteTrain.RideM) under/// the car's middle, at every 25 m of the train from Lod to Jerusalem, both ways; on the Sorek valley's tightest bends