From b0ec4c555847393b0fc3e25bf0503753dda2117b Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Sun, 24 Aug 2025 20:51:26 -0400 Subject: [PATCH] Fix trainwreck bug (#1925) Fixes #1922, the trainwreck bug. - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced --- src/core/execution/TrainStationExecution.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/execution/TrainStationExecution.ts b/src/core/execution/TrainStationExecution.ts index a257a909b..af8a5bd3f 100644 --- a/src/core/execution/TrainStationExecution.ts +++ b/src/core/execution/TrainStationExecution.ts @@ -61,12 +61,10 @@ export class TrainStationExecution implements Execution { } private spawnTrain(station: TrainStation, currentTick: number) { - if ( - !this.spawnTrains || - currentTick - this.lastSpawnTick < this.ticksCooldown - ) { - return; - } + if (this.mg === undefined) throw new Error("Not initialized"); + if (!this.spawnTrains) return; + if (this.random === undefined) throw new Error("Not initialized"); + if (currentTick < this.lastSpawnTick + this.ticksCooldown) return; const cluster = station.getCluster(); if (cluster === null) { return;