Skip to content

Commit 60479bb

Browse files
committed
change game checking interval to get around a performance issue some people have
1 parent 418129f commit 60479bb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wh3mm",
33
"productName": "wh3mm",
4-
"version": "2.12.0",
4+
"version": "2.12.1",
55
"description": "WH3 Mod Manager",
66
"main": ".webpack/main",
77
"scripts": {

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,25 @@ if (!gotTheLock) {
252252
} catch (e) {}
253253

254254
if (!checkWH3RunningInterval) {
255-
checkWH3RunningInterval = setInterval(async () => {
255+
const isGameRuningCheck = async () => {
256256
try {
257257
// if a game crashes you can end up with a tiny running process of the game, that's why we have a memory filter here
258258
exec(
259-
`tasklist /fi "MEMUSAGE gt 10000" | findstr ${gameToProcessName[appData.currentGame]}`,
260-
(error) => {
261-
const isWH3Running = !error;
259+
`tasklist /fi "IMAGENAME eq ${gameToProcessName[appData.currentGame]}" /fi "MEMUSAGE gt 10000"`,
260+
(_, stdout) => {
261+
const isWH3Running = !stdout.startsWith("INFO: ");
262262
if (appData.isWH3Running != isWH3Running) {
263263
appData.isWH3Running = isWH3Running;
264264
windows.mainWindow?.webContents.send("setIsWH3Running", appData.isWH3Running);
265265
}
266+
if (checkWH3RunningInterval) checkWH3RunningInterval.refresh();
266267
}
267268
);
268269
} catch (e) {
269270
console.log("psList coroutine error:", e);
270271
}
271-
}, 500);
272+
};
273+
checkWH3RunningInterval = setTimeout(isGameRuningCheck, 500);
272274
}
273275
});
274276
};

0 commit comments

Comments
 (0)