Merge pull request #2467 from MartinFournier/fix/load-running-scripts

Check if running script is null before offlineProd
This commit is contained in:
hydroflame 2022-01-08 12:37:39 -05:00 committed by GitHub
commit 3c047d170f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -638,8 +638,15 @@ export function loadAllRunningScripts(player: IPlayer): void {
server.runningScripts.length = 0; server.runningScripts.length = 0;
} else { } else {
for (let j = 0; j < server.runningScripts.length; ++j) { for (let j = 0; j < server.runningScripts.length; ++j) {
const fileName = server.runningScripts[j].filename;
createAndAddWorkerScript(player, server.runningScripts[j], server); 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 // Offline production
scriptCalculateOfflineProduction(server.runningScripts[j]); scriptCalculateOfflineProduction(server.runningScripts[j]);
} }