Fix scripts dying of weird causes.

This commit is contained in:
Olivier Gagnon 2021-12-13 22:26:22 -05:00
parent c1e3a170ab
commit de9fb24156
7 changed files with 43 additions and 36 deletions

28
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -30,6 +30,19 @@ function createWindow() {
e.preventDefault();
shell.openExternal(url);
});
win.webContents.backgroundThrottling = false;
// This is backward but the game fills in an array called `document.achievements` and we retrieve it from
// here. Hey if it works it works.
const achievements = greenworks.getAchievementNames();
const intervalID = setInterval(async () => {
const achs = await win.webContents.executeJavaScript("document.achievements");
console.log(achs);
for (const ach of achs) {
if (!achievements.includes(ach)) continue;
greenworks.activateAchievement(ach, () => undefined);
}
}, 1000);
// Create the Application's main menu
Menu.setApplicationMenu(
@ -59,8 +72,10 @@ function createWindow() {
{
label: "reload & kill all scripts",
click: () => {
if (intervalID) clearInterval(intervalID);
win.webContents.forcefullyCrashRenderer();
setTimeout(() => win.loadFile("index.html", { query: { noScripts: "true" } }), 5000);
win.close();
createWindow();
},
},
],
@ -92,20 +107,6 @@ function createWindow() {
},
]),
);
// This is backward but the game fills in an array called `document.achievements` and we retrieve it from
// here. Hey if it works it works.
const achievements = greenworks.getAchievementNames();
// for (const ach of achievements) {
// greenworks.clearAchievement(ach, () => undefined);
// }
setInterval(async () => {
const achs = await win.webContents.executeJavaScript("document.achievements");
for (const ach of achs) {
if (!achievements.includes(ach)) continue;
greenworks.activateAchievement(ach, () => undefined);
}
}, 1000);
}
app.whenReady().then(() => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -14,6 +14,9 @@ export function netscriptDelay(time: number, workerScript: WorkerScript): Promis
}
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
if ((msg as any) instanceof WorkerScript) {
console.error("HERE");
}
const server = GetServer(workerScript.hostname);
if (server == null) {
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);

@ -139,7 +139,10 @@ function startNetscript2Script(workerScript: WorkerScript): Promise<WorkerScript
} else if (isScriptErrorMessage(e)) {
workerScript.errorMessage = e;
throw workerScript;
} else if (e instanceof WorkerScript) {
throw e;
}
workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, e);
throw workerScript; // Don't know what to do with it, let's rethrow.
});

@ -1853,7 +1853,7 @@ export function applyForEmployeeJob(this: IPlayer, sing = false): boolean {
this.companyName = company.name;
this.jobs[company.name] = posNames.MiscCompanyPositions[1];
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed at " + this.companyName);
dialogBoxCreate("Congratulations, you are now employed at " + this.location);
}
return true;
@ -1871,7 +1871,7 @@ export function applyForPartTimeEmployeeJob(this: IPlayer, sing = false): boolea
if (this.isQualified(company, CompanyPositions[posNames.PartTimeCompanyPositions[1]])) {
this.jobs[company.name] = posNames.PartTimeCompanyPositions[1];
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed part-time at " + this.companyName);
dialogBoxCreate("Congratulations, you are now employed part-time at " + this.location);
}
return true;
@ -1890,7 +1890,7 @@ export function applyForWaiterJob(this: IPlayer, sing = false): boolean {
this.companyName = company.name;
this.jobs[company.name] = posNames.MiscCompanyPositions[0];
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed as a waiter at " + this.companyName);
dialogBoxCreate("Congratulations, you are now employed as a waiter at " + this.location);
}
return true;
} else {
@ -1907,7 +1907,7 @@ export function applyForPartTimeWaiterJob(this: IPlayer, sing = false): boolean
this.companyName = company.name;
this.jobs[company.name] = posNames.PartTimeCompanyPositions[0];
if (!sing) {
dialogBoxCreate("Congratulations, you are now employed as a part-time waiter at " + this.companyName);
dialogBoxCreate("Congratulations, you are now employed as a part-time waiter at " + this.location);
}
return true;
} else {