mirror of
https://github.com/burrow-dev/burrow-client.git
synced 2026-11-19 09:37:50 -05:00
fix: a game the graphics card keeps from drawing restarts the client without it
This commit is contained in:
1 parent
77be498599
commit
8a1b60ad42
3 files changed
+28
No files matched your search
@@ -529,6 +529,11 @@
|
|||||||
const METRICS_EVERY_MS = 2000;
|
const METRICS_EVERY_MS = 2000;
|
||||||
// the game says when it is drawn; if it never does, show it anyway.
|
// the game says when it is drawn; if it never does, show it anyway.
|
||||||
const LOADING_AT_MOST_MS = 25000;
|
const LOADING_AT_MOST_MS = 25000;
|
||||||
|
// a game not drawn this long after it started, with the graphics card
|
||||||
|
// in use, is taken for one the card keeps from drawing (main.js
|
||||||
|
// gpuFallback): the client starts again without it.
|
||||||
|
const GPU_WATCH_MS = 60000;
|
||||||
|
let gpuWatch = null;
|
||||||
|
|
||||||
let info = null;
|
let info = null;
|
||||||
let session = null; // {server, flashVars, since} while the game is open
|
let session = null; // {server, flashVars, since} while the game is open
|
||||||
@@ -1089,6 +1094,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const closeGame = message => {
|
const closeGame = message => {
|
||||||
|
clearTimeout(gpuWatch);
|
||||||
window.client.presence(null);
|
window.client.presence(null);
|
||||||
$("fps").textContent = "";
|
$("fps").textContent = "";
|
||||||
if (webview) {
|
if (webview) {
|
||||||
@@ -1272,6 +1278,7 @@
|
|||||||
$("fps").textContent = `· ${Number(event.args[0]) || 0} fps`;
|
$("fps").textContent = `· ${Number(event.args[0]) || 0} fps`;
|
||||||
}
|
}
|
||||||
if (event.channel === "initialized") {
|
if (event.channel === "initialized") {
|
||||||
|
clearTimeout(gpuWatch);
|
||||||
gameIsDrawn();
|
gameIsDrawn();
|
||||||
}
|
}
|
||||||
else if (event.channel === "reloadGame") {
|
else if (event.channel === "reloadGame") {
|
||||||
@@ -1316,6 +1323,13 @@
|
|||||||
$("loading").hidden = false;
|
$("loading").hidden = false;
|
||||||
clearTimeout(loadingTimer);
|
clearTimeout(loadingTimer);
|
||||||
loadingTimer = setTimeout(gameIsDrawn, LOADING_AT_MOST_MS);
|
loadingTimer = setTimeout(gameIsDrawn, LOADING_AT_MOST_MS);
|
||||||
|
clearTimeout(gpuWatch);
|
||||||
|
if (info && info.gpu) {
|
||||||
|
gpuWatch = setTimeout(() => {
|
||||||
|
closeGame("The game did not start with the graphics card. Burrow is restarting without it (Use GPU, under Advanced, turns it back on).");
|
||||||
|
setTimeout(() => window.client.gpuFallback(), 4000);
|
||||||
|
}, GPU_WATCH_MS);
|
||||||
|
}
|
||||||
$("stage").prepend(webview);
|
$("stage").prepend(webview);
|
||||||
$("who").textContent = `${session.flashVars.username} · ${new URL(session.server).host}`;
|
$("who").textContent = `${session.flashVars.username} · ${new URL(session.server).host}`;
|
||||||
$("stats-tip").textContent = fieldValue("account-type") === "4"
|
$("stats-tip").textContent = fieldValue("account-type") === "4"
|
||||||
|
|||||||
+11
@@ -211,6 +211,17 @@ let updateState = null; // the last thing the updater said, for a page loaded af
|
|||||||
ipcMain.handle("setGpu", (event, on) => {
|
ipcMain.handle("setGpu", (event, on) => {
|
||||||
fs.writeFileSync(SETTINGS_FILE, JSON.stringify({...readSettings(), gpu: on === true}));
|
fs.writeFileSync(SETTINGS_FILE, JSON.stringify({...readSettings(), gpu: on === true}));
|
||||||
});
|
});
|
||||||
|
// some graphics cards (or their drivers) leave the game on its loading
|
||||||
|
// screen for good; players got past it by turning "Use GPU" off. the page
|
||||||
|
// asks for that itself when the game has not drawn in time (index.html).
|
||||||
|
ipcMain.on("gpuFallback", () => {
|
||||||
|
if (!usesGpu || app.commandLine.hasSwitch("aj-gpu")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs.writeFileSync(SETTINGS_FILE, JSON.stringify({...readSettings(), gpu: false}));
|
||||||
|
app.relaunch();
|
||||||
|
app.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
// what the server is told about this computer at sign-in (device.js).
|
// what the server is told about this computer at sign-in (device.js).
|
||||||
ipcMain.handle("device", () => device.device());
|
ipcMain.handle("device", () => device.device());
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ contextBridge.exposeInMainWorld("client", {
|
|||||||
// the server's captcha ("login" or "signup") in a window of its own: its answer, or "" when there is none.
|
// the server's captcha ("login" or "signup") in a window of its own: its answer, or "" when there is none.
|
||||||
captcha: (serverUrl, action) => ipcRenderer.invoke("captcha", serverUrl, action),
|
captcha: (serverUrl, action) => ipcRenderer.invoke("captcha", serverUrl, action),
|
||||||
setGpu: on => ipcRenderer.invoke("setGpu", on),
|
setGpu: on => ipcRenderer.invoke("setGpu", on),
|
||||||
|
// the game did not start drawing with the graphics card: it is turned off
|
||||||
|
// (as "Use GPU" would) and the client starts again.
|
||||||
|
gpuFallback: () => ipcRenderer.send("gpuFallback"),
|
||||||
setAutoUpdate: on => ipcRenderer.invoke("setAutoUpdate", on),
|
setAutoUpdate: on => ipcRenderer.invoke("setAutoUpdate", on),
|
||||||
restartToUpdate: () => ipcRenderer.send("restartToUpdate"),
|
restartToUpdate: () => ipcRenderer.send("restartToUpdate"),
|
||||||
// {state: "ready" | "download", version} from updater.js
|
// {state: "ready" | "download", version} from updater.js
|
||||||
|
|||||||
Reference in new issue
Block a user