fix(session): launching the running game again resumes it instead of asking Steam twice (#2940)

* fix(session): launching the running game again resumes it instead of asking Steam twice

A front end that resumes a suspended player by launching the same game again
(Cocoon 3.07 does) made DroidDeck queue the game for Steam a second time,
and Steam answered with "An error occurred while launching this game: Game
already running" over the game.

queueSteamGame now resumes the session and returns when the requested game is
the current one and its process is running. A different game, or one that has
exited, still goes to Steam as before.

* fix(session): a relaunch during a pending freeze resumes too, and both game ID forms count as the same game
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-20 11:40:17 -05:00
1 parent d0022a35f9
commit 83dc5f37e9
3 files changed
+25

No files matched your search

@@ -88,4 +88,17 @@ class SteamGameProcessTest {
process("301", "reaper", "SteamLaunch", "AppId=351710", "--", "proton", "waitforexitandrun", "game.exe")
assertTrue(SteamGameProcess.running("351710", proc))
}
@Test fun onlyTheRunningCurrentGameCountsAsAlreadyRunning() {
val proc = tmp.newFolder("proc-relaunch")
File(proc, "200").apply { mkdirs() }.resolve("cmdline")
.writeBytes(cmdline("reaper", "SteamLaunch", "AppId=584400", "--", "proton", "waitforexitandrun", "SonicMania.exe"))
assertTrue(SteamGameProcess.alreadyRunning("584400", "584400", proc))
assertFalse(SteamGameProcess.alreadyRunning("584400", "311340", proc))
assertFalse(SteamGameProcess.alreadyRunning("311340", "311340", proc))
assertFalse(SteamGameProcess.alreadyRunning("584400", null, proc))
val shortcutId = ((584400uL shl 32) or 0x02000000uL).toString()
assertTrue(SteamGameProcess.alreadyRunning(shortcutId, "584400", proc))
assertTrue(SteamGameProcess.alreadyRunning("584400", shortcutId, proc))
}
}