fix(launcher): report game exits separately
Keep successful process creation separate from exit status. Report the exit code and game log directory when the process exits abnormally. Verified by type checking and launcher build. The guarded game exit remains part of acceptance.
This commit is contained in:
1 parent
b3a30c0fd9
commit
84158f719d
9 files changed
+55
-26
No files matched your search
@@ -5,7 +5,7 @@ import { app, BrowserWindow, shell } from 'electron';
|
||||
import { AccountStore, LOOPBACK } from '@wto/server';
|
||||
import { executableVersion, GAME_FILES, isInSteamLibrary } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import type { LaunchState } from '@shared/schemas/launch.ts';
|
||||
import type { GameExit, LaunchState } from '@shared/schemas/launch.ts';
|
||||
import { getSettings } from '../config/settings-store.ts';
|
||||
import { decalCachePath } from '../install/decals.ts';
|
||||
import { copyPathContains, readInstallRecord } from '../install/install-record.ts';
|
||||
@@ -160,16 +160,20 @@ async function launch(job: LaunchJob): Promise<void> {
|
||||
});
|
||||
});
|
||||
|
||||
const publish = (phase: LaunchState['phase']): void => {
|
||||
const publish = (phase: LaunchState['phase'], gameExit?: GameExit): void => {
|
||||
if (signal.aborted) return;
|
||||
update(job, { phase, port });
|
||||
update(job, { phase, port, gameExit });
|
||||
if (phase === 'running' && settings.afterGameStarts === 'minimize') {
|
||||
for (const window of BrowserWindow.getAllWindows()) window.minimize();
|
||||
}
|
||||
};
|
||||
if (lab) await runLab(lab, stockPath, dataPath, signal, publish);
|
||||
else await runOrdinaryLaunch(copyPath, dataPath, port, settings, signal, publish);
|
||||
update(job, { phase: 'ready' });
|
||||
if (lab) {
|
||||
await runLab(lab, stockPath, dataPath, signal, publish);
|
||||
update(job, { phase: 'ready' });
|
||||
return;
|
||||
}
|
||||
const gameExit = await runOrdinaryLaunch(copyPath, dataPath, port, settings, signal, publish);
|
||||
update(job, { phase: 'game-exited', gameExit });
|
||||
}
|
||||
|
||||
async function readVersion(folder: string, signal: AbortSignal): Promise<string | null> {
|
||||
|
||||
Reference in new issue
Block a user