From 71487337cbfcae63ef45b94b727246f456d43a33 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Sat, 8 Jan 2022 09:13:25 -0500 Subject: [PATCH] Check if running script is null before offlineProd --- src/NetscriptWorker.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index dfcb1245a..9e3284d72 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -638,8 +638,15 @@ export function loadAllRunningScripts(player: IPlayer): void { server.runningScripts.length = 0; } else { for (let j = 0; j < server.runningScripts.length; ++j) { + const fileName = server.runningScripts[j].filename; createAndAddWorkerScript(player, server.runningScripts[j], server); + if (!server.runningScripts[j]) { + // createAndAddWorkerScript can modify the server.runningScripts array if a script is invalid + console.error(`createAndAddWorkerScript removed ${fileName} from ${server}`); + continue; + } + // Offline production scriptCalculateOfflineProduction(server.runningScripts[j]); }