Skip to content

play.ps1: exit with the child's code, and let captures through (#3, #19) - #101

Closed
xiaotu030202 wants to merge 1 commit into
Zettrox:mainfrom
xiaotu030202:play-exit-code-and-captures
Closed

xiaotu030202 wants to merge 1 commit into
Zettrox:mainfrom
xiaotu030202:play-exit-code-and-captures

Conversation

@xiaotu030202

@xiaotu030202 xiaotu030202 commented Nov 25, 2026 •

Copy link
Copy Markdown

Closing this: #15 and #22 already do both halves, more precisely, and I did not check the open pull requests before writing it.

what this PR did already in flight
exit with the child's code (#3) #15 Launcher: propagate the native process exit code, +3/−1
-Capture / -Keys switches + README section (#19) #22 Docs: show a direct launch for captures and scripted input, +17/−1

The one thing #15 and #22 do not cover

$?-guarded exit code. #15 reads $LASTEXITCODE after the pipeline, which is right for a child that ran and failed. A command that cannot be started at all leaves $LASTEXITCODE untouched, so it reports the previous command's value — and #3's own reproduction is .\target\release\victory.exe run $missing, which is that case whenever -Exe does not resolve.

$code = if ($?) { $LASTEXITCODE } else { 1 }   # this PR
$code = $LASTEXITCODE                          # #15

With #17 (-Exe resolution, and it exits 1 when nothing is found) and #53 (directory errors) merged, that window closes from the other side, so #15 alone is fine. Noting it rather than asking for a change.

What I verified, in case it helps whoever reviews #15

Windows 11, Rust 1.98.1 (pinned), release build, no game files:

play.ps1 -Game <missing exe> -Exe <the built one>   -> 1   (was 0)
play.ps1 -Game <missing exe> -Exe <not there>       -> 1

And the switches, probed inside the script right after the clearing step, before I saw #22:

(none)              CAPTURE= FRAMES= DUMP= KEYS=
-Capture            CAPTURE=set FRAMES=set DUMP=set KEYS=
-Keys               CAPTURE= FRAMES= DUMP= KEYS=set
-KeepScriptedInput  CAPTURE=set FRAMES=set DUMP=set KEYS=set

Also: #4 does not reproduce on 90b529f

I ran a path with spaces through the launcher and compared it against a direct run:

direct:      victory.exe run "…\GTA 6\game scarlett master.exe" --execute
                 -> Error: malformed image: Could not read file magic
via launcher: play.ps1 -Game "…\GTA 6\game scarlett master.exe"
                 -> the same line, not "reading …\GTA"

Both reach victory.exe with the same argument, so the truncation in #4 is the -Exe default rather than argument splitting — which is what that thread concluded and what #17 fixes. Worth saying so on #4 once #17 lands.

Sorry for the duplicate. #100 (opcode coverage) is the one from me that is not already in flight.

The launcher ended on `Write-Host`, and a PowerShell script that ends normally
exits 0 whatever the commands inside did. It printed "Exited with 1" and the
log named the failure while the process returned 0, so a failed launch counted
as a successful sample in batch runs (Zettrox#3). It now exits with the child's code.

A command that cannot be started at all leaves `$LASTEXITCODE` untouched, so
reading it alone reports the previous command's 0 in exactly that case. `$?`
says whether the call ran, and 1 stands in when it did not.

`$PSScriptRoot` in the `-Exe` default is not touched here: PR Zettrox#17 fixes that
and does more with it (missing-file reporting, PATH lookup), so this change
stays out of its way and works with or without it merged.

The launcher also cleared `VICTORY_CAPTURE`, `VICTORY_CAPTURE_FRAMES`,
`VICTORY_DUMP_TARGETS` and `VICTORY_KEYS` unconditionally, so passing the
diagnostics executable with `-Exe` still could not capture or script input
(Zettrox#19). They are opt-in now: `-Capture`, `-Keys`, or `-KeepScriptedInput` for
both. The default is unchanged — a normal run captures nothing and presses
nothing.

Measured on Windows 11, Rust 1.98.1 (pinned), release build, no game files:

    play.ps1 -Game <missing exe> -Exe <the built one>   -> 1   (was 0)
    play.ps1 -Game <missing exe> -Exe <not there>       -> 1

and the switches, probed inside the script after the clearing step:

    (none)              CAPTURE= FRAMES= DUMP= KEYS=
    -Capture            CAPTURE=set FRAMES=set DUMP=set KEYS=
    -Keys               CAPTURE= FRAMES= DUMP= KEYS=set
    -KeepScriptedInput  CAPTURE=set FRAMES=set DUMP=set KEYS=set

A path with spaces reaches the child intact: `-Game "…\GTA 6\game scarlett
master.exe"` produces the same `malformed image` line from `victory.exe` as
running it directly does, so Zettrox#4's truncation does not reproduce on this build.

README: the launcher's exit code, and the three switches with both the switch
and the direct diagnostics launch.
@xiaotu030202
xiaotu030202 force-pushed the play-exit-code-and-captures branch from 1c02f2d to 6f2d470 Compare November 25, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant