Tell the end of a game started from the Steam shortcut as Play tells it, with a message box for a fatal one.

play_only, the --play path of the Steam shortcut, logged only "the game ended (code N)" in launcher.log: it read no FATAL line, added no note to the game's log and showed nothing, so a game that ended with 70, 71, 72 or a Windows status left the player with no word of why (as when Steam starts it while the window replaces a save, and it ends at once with "another copy of the game is running"). The 7b0dbeb1 change that logs every end touched the window's watch only. play_only now follows the run with GameRun, the Restart's copies too, and takes the same game_end as the window: the line in launcher.log, the note in the game's log, and a message box only for an end worth one (a FATAL line, 70, 71 or 72, a Windows status; not 0, nor 1 from Task Manager's End task). The logs are written before the box, which waits for OK while Steam still counts the game as running.

Not reproduced before the change in a game run: the audit's probe showed it with a stand-in process. Checks that passed: tests/launcher_test.py (214 tests, a new one for the Steam shortcut's ends with codes 70, 0xC0000005, 0 and 1, which fails before the change) and tools/check_content.py --staged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 17:12:51 -05:00
parent 8de99df6eb
commit 8f42883a74
3 changed files with 71 additions and 11 deletions

View File

@@ -241,13 +241,13 @@ def shown_fatal(fatal):
def game_end(game_dir, code, started=None, restarted=False):
"""What the launcher says about an end of the game (App.watch_game): a GameEnd of the line for launcher.log, the
sentence for the player ('' for none), the text note_exit_in_log adds to the game's log ('' for none), and alarm:
whether the end is worth a message box where no window shows the sentence (a FATAL line, a code of FATAL_CODES or
a Windows status; not 0, nor 1, which Task Manager's End task gives). code is the exit code of the run's last
process, or None when it is not known, which happens only for a copy the game's own Restart started that could not
be followed (GameRun). started is time.time() before the game was started, restarted whether it restarted itself
on the way."""
"""What the launcher says about an end of the game (App.watch_game, play_only): a GameEnd of the line for
launcher.log, the sentence for the player ('' for none), the text note_exit_in_log adds to the game's log ('' for
none), and alarm: whether the end is worth a message box where no window shows the sentence (a FATAL line, a code
of FATAL_CODES or a Windows status; not 0, nor 1, which Task Manager's End task gives). code is the exit code of
the run's last process, or None when it is not known, which happens only for a copy the game's own Restart started
that could not be followed (GameRun). started is time.time() before the game was started, restarted whether it
restarted itself on the way."""
how = ' after restarting itself' if restarted else ''
if code not in (0, None):
code &= 0xFFFFFFFF
@@ -2880,16 +2880,24 @@ def play_only(ctx):
if waiting: # the window builds the mods' code in, then starts the game (App.start with --play)
ctx.log(f'play from Steam: the game is built again first for the code of {", ".join(waiting)}')
return None
started = time.time()
try:
proc = winsys.start_game(exe)
run = GameRun(winsys.start_game(exe), gd, started)
except OSError as e:
ctx.log(f'play from Steam: {exe}: {e}')
return None
ctx.log(f'play from Steam: {exe}')
time.sleep(2)
while proc.poll() is None or saves.game_running(gd):
while run.running():
time.sleep(1)
ctx.log(f'play from Steam: the game ended (code {proc.returncode})')
# The end is told as Play's is (App.watch_game), with no window: a box for an end worth one. The logs come first,
# since the box waits for OK and Steam may end this process meanwhile.
end = run.end()
ctx.log(f'play from Steam: {end.log}')
if end.note:
note_exit_in_log(gd, end.note)
if end.alarm:
tell(end.message)
return 0