From 0fe7156d8b63857f5ff571d77b419ee0f710a407 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 25 Sep 2026 20:15:00 +0200 Subject: [PATCH] Cut 1 fix batch 2 (F2): collapse the entrance station to one orbit selection Two writers decided the tutorial entrance's station orbit: the floor (stationCount < 1 -> 1) and a synthesized fallback orbit, each masking bugs in the other (removing either alone still passed the entrance test). Collapse to one rule: the floor still guarantees stationCount >= 1, but its orbit always comes from the same Lagrange selection. When that selection has no candidate (a zone that is entirely one rosette), widen it to every parented planet orbit ordinary placement draws from before the rosette filter, instead of inventing an unparented, zero-distance orbit -- which gave PlaceTurret's phase a division by zero and left an orphan orbit record. If even the widened set is empty, throw loudly instead of silently omitting the entrance's station. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/ZoneGenerator.cs | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index d09e52b6b..e3235b412 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -221,22 +221,25 @@ public static class ZoneGenerator .TrueForAll(c => !(c != p && abs(c.Distance - p.Distance) < .1f))) // Filter Rosettes .OrderBy(p => p.Distance) .ToArray(); + // The entrance's own station count is the floor above; its orbit always comes from this same selection. + // Ordinarily that selection is potentialLagrangePoints (non-rosette planet orbits). If the entrance zone + // has none of those (a boring single-body system, or a system that is entirely one rosette), widen to + // every planet orbit ordinary placement's own candidate pool is drawn from before the rosette filter -- + // still a real, parented planet orbit with a positive Distance -- rather than inventing an unparented, + // zero-distance orbit (that gave PlaceTurret's phase = 20*multiplier/orbit.Distance a division by zero, + // and left an orbit record with no planet behind it). + var lagrangeCandidates = potentialLagrangePoints; + if (isTutorialEntrance && lagrangeCandidates.Length == 0) + lagrangeCandidates = planets.Where(p => p.Parent != null).OrderBy(p => p.Distance).ToArray(); // Pick a selection from the middle of the distribution - var selectedStationOrbits = potentialLagrangePoints - .Skip(potentialLagrangePoints.Length / 2) + var selectedStationOrbits = lagrangeCandidates + .Skip(lagrangeCandidates.Length / 2) .Take(stationCount) .Select(p=>orbitMap[p]) .ToArray(); - // No planet has a sibling to share a Lagrange point with (a boring single-body system, or none at all), - // so there is nowhere the ordinary path would put a station. The entrance zone still needs one: give it - // a standalone orbit fixed at a safe distance from the zone centre rather than silently leaving it with - // no station. if (isTutorialEntrance && selectedStationOrbits.Length == 0) - { - var fallbackOrbit = new OrbitData { FixedPosition = random.NextFloat2Direction() * pack.Radius * .5f }; - cache.Upsert(fallbackOrbit); - selectedStationOrbits = new[] { fallbackOrbit }; - } + throw new InvalidOperationException( + "The tutorial entrance zone must always get a station, but it has no orbit at all -- every planet in the zone is a rootless rosette member with no parent."); var loadoutGenerators = new Dictionary();