From 87793044999446b618d7f35738171708e4aed221 Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:28:36 +0200
Subject: [PATCH] Galaxy generation refuses seed 0: delete the clock fallback
and the seed defaults
GalaxyStage.SeedFrom is the one minter of a run's seed; both generation
constructors now take progressCallback and seed without defaults and throw
ArgumentOutOfRangeException on zero instead of reading the clock.
Co-Authored-By: Claude Sonnet 5.5
---
Assets/Scripts/ServerShared/Galaxy.cs | 12 ++++++------
tests/Aetheria.Shared.Tests/RunStartTests.cs | 10 ++++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs
index 0b2f71387..b2d1e5dd0 100644
--- a/Assets/Scripts/ServerShared/Galaxy.cs
+++ b/Assets/Scripts/ServerShared/Galaxy.cs
@@ -96,15 +96,15 @@ public class Galaxy
SectorBackgroundSettings background,
CultCache cache,
Action log,
- Action progressCallback = null,
- uint seed = 0)
+ Action progressCallback,
+ uint seed)
{
_cache = cache;
IsPrelude = false;
Background = background;
Log = log;
var factions = cache.GetAll();
- Seed = seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed;
+ Seed = seed != 0 ? seed : throw new ArgumentOutOfRangeException(nameof(seed), "a generated galaxy takes its run's seed from GalaxyStage, never zero");
var random = new Random(Seed);
Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral;
@@ -163,15 +163,15 @@ public class Galaxy
PlayerSettings playerSettings,
DirectoryInfo narrativeDirectory,
Action log,
- Action progressCallback = null,
- uint seed = 0)
+ Action progressCallback,
+ uint seed)
{
_cache = cache;
IsPrelude = true;
Background = background;
Log = log;
- Seed = seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed;
+ Seed = seed != 0 ? seed : throw new ArgumentOutOfRangeException(nameof(seed), "a generated galaxy takes its run's seed from GalaxyStage, never zero");
var random = new Random(Seed);
var factions = new List();
diff --git a/tests/Aetheria.Shared.Tests/RunStartTests.cs b/tests/Aetheria.Shared.Tests/RunStartTests.cs
index efedc20dd..7c22bb911 100644
--- a/tests/Aetheria.Shared.Tests/RunStartTests.cs
+++ b/tests/Aetheria.Shared.Tests/RunStartTests.cs
@@ -115,6 +115,16 @@ public sealed partial class RunStartTests : IDisposable
private const float Freezing = 273.15f;
+ // One minter: a generated galaxy never reads the clock, so seed 0 is refused by both generation constructors.
+ [Fact]
+ public void AGeneratedGalaxyRefusesSeedZero()
+ {
+ Assert.Throws(() =>
+ new Galaxy(new SectorGenerationSettings(), new SectorBackgroundSettings(), _cache, _ => { }, null, 0));
+ Assert.Throws(() =>
+ new Galaxy(new TutorialGenerationSettings(), new SectorBackgroundSettings(), _cache, new PlayerSettings(), new DirectoryInfo(_root), _ => { }, null, 0));
+ }
+
// A main-sector galaxy: each station's gear must come from manufacturers its faction can reach, the makers its
// allegiance names, present in the galaxy or not.
private Galaxy MainSectorGalaxy()