From 0eb85789965c1edc54d49fbf1c85d1b66b473404 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 18 May 2026 17:39:27 -0700 Subject: [PATCH] Fix nations not spawning in singleplayer when player picks fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NationExecution gated its first SpawnExecution by the same attackRate/attackTick throttle used for AI actions, so a nation could wait up to ~100 ticks before scheduling its spawn. In singleplayer the human's spawn ends the spawn phase immediately, stranding any nation that hadn't yet reached its attackTick — on the next tick its NationExecution sees inSpawnPhase()=false and isAlive()=false (no tiles), and deactivates itself. First spawn now fires on tick 1, gated by a one-shot flag to avoid queuing duplicates. The attackRate cadence is preserved for subsequent re-spawns so nations still hop locations during the spawn phase. --- src/core/execution/NationExecution.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/execution/NationExecution.ts b/src/core/execution/NationExecution.ts index 785aa41e9..6a2a53a7d 100644 --- a/src/core/execution/NationExecution.ts +++ b/src/core/execution/NationExecution.ts @@ -28,6 +28,7 @@ export class NationExecution implements Execution { private active = true; private random: PseudoRandom; private behaviorsInitialized = false; + private spawnExecAdded = false; private emojiBehavior!: NationEmojiBehavior; private mirvBehavior!: NationMIRVBehavior; private attackBehavior!: AiAttackBehavior; @@ -104,7 +105,14 @@ export class NationExecution implements Execution { } if (this.mg.inSpawnPhase()) { - if (ticks % this.attackRate !== this.attackTick) { + if (this.player.hasSpawned()) { + // Already on the map — periodically re-spawn so the nation + // visibly hops to different locations during the spawn phase. + if (ticks % this.attackRate !== this.attackTick) { + return; + } + } else if (this.spawnExecAdded) { + // First SpawnExecution already queued, wait for it to land. return; } // Place nations without a spawn cell (Dynamically created for HumansVsNations) randomly by SpawnExecution @@ -112,6 +120,7 @@ export class NationExecution implements Execution { this.mg.addExecution( new SpawnExecution(this.gameID, this.nation.playerInfo), ); + this.spawnExecAdded = true; return; } @@ -131,6 +140,7 @@ export class NationExecution implements Execution { this.mg.addExecution( new SpawnExecution(this.gameID, this.nation.playerInfo), ); + this.spawnExecAdded = true; return; } } @@ -147,6 +157,7 @@ export class NationExecution implements Execution { this.mg.addExecution( new SpawnExecution(this.gameID, this.nation.playerInfo, rl), ); + this.spawnExecAdded = true; return; }