Check if running script is null before offlineProd

This commit is contained in:
Martin Fournier 2022-01-08 09:13:25 -05:00
parent d2193e017d
commit 71487337cb

@ -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]);
}