Linux/Proton: restart victory.exe directly without PowerShell (Fixes #1954) #2434

Open
github-bot wants to merge 1 commit from github-bot/gh-2434 into main AGit
Owner

@⁠steven-seagull27 on GitHub · 2026-11-29 13:00 UTC · original
steven-seagull27:fix/1954-direct-restart-without-powershell → main · +927 −39 · 3 files · 1 commits · open

Fixes #1954

Summary

  • Root cause: Menu::restart_as in crates/victory-gpu/src/host/menu.rs unconditionally spawned powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Sleep 3; ... & $env:VICTORY_MENU_PLAY ..." before calling TerminateProcess. Under Linux/Proton (Wine), powershell.exe is either absent or Wine's stub executable (which CreateProcessW starts successfully and which then exits immediately without running anything — matching docs/linux-proton.md and #1954). As a result, both the one-time warmup restart (Menu::warmup) and F1 settings restarts closed the game without relaunching victory.exe.
  • Direct .exe relaunch without PowerShell (crates/victory-gpu/src/host/menu.rs):
    • Added Wine/Proton detection via ntdll.dll's wine_get_version (on_wine()), matching apps/victory/src/main.rs and crates/victory-hle/src/modules/xmem.rs.
    • Added parse_menu_args to parse VICTORY_MENU_ARGS (single-quoted PowerShell tokens, escaped '', and $env:VICTORY_MENU_EXE expansion) into raw OsString arguments while rejecting unclosed quotes or unquoted shell operators.
    • Added MSVCRT / CommandLineToArgvW-compliant Windows command-line quoting (build_windows_command_line) and sorted UTF-16 environment block construction (build_env_block, CREATE_UNICODE_ENVIRONMENT) for CreateProcessW with CREATE_NEW_CONSOLE.
    • Added plan_restart strategy selection:
      • Launches native .exe targets directly without PowerShell under Wine/Proton (never hitting Wine's stub powershell.exe), when restarting victory.exe itself, and for own_command (save import).
      • Preserves PowerShell launch for .ps1 launcher scripts on native Windows (and uses PowerShell with direct-spawn fallback for third-party .exe launchers on native Windows).
      • Refuses cleanly with a warning log and drawable menu note — without terminating the running game — if a non-.exe launcher or unparseable args cannot be restarted under Wine/Proton.
  • Startup delay and error hold for direct restarts (apps/victory/src/main.rs, apps/victory/src/play.rs):
    • Direct restarts pass VICTORY_RESTART_DELAY_SECS=3 and the requested Then override (VICTORY_PRELOAD=1 / VICTORY_CLEAR_SHADERS=1, clearing stale flags) directly in the child environment block.
    • At the very start of main() (before GPU/runtime initialization, address-space reservation, or child process spawns), victory.exe reads and immediately removes VICTORY_RESTART_DELAY_SECS (clamped to 30s), sleeps so the previous process exits and releases GPU/file locks cleanly, and holds the console window on startup error (play::hold_window) when restarted directly.

Verification (synthetic tests only)

  • cargo test --locked -j 3 -p victory-gpu --lib -- menu --nocapture --test-threads=1 — 19 passed, 0 failed:
    • parse_menu_args_handles_quotes_unicode_and_env_expansion (spaces, Unicode, typographic apostrophes #563, escaped ', quotes, backslashes, $env:VICTORY_MENU_EXE, invalid syntax rejection)
    • windows_command_line_round_trips_through_command_line_to_argv_w (Win32 CommandLineToArgvW round-trip)
    • build_env_block_applies_case_insensitive_overrides_and_removals (Then::Play / Preload / ClearShaders, VICTORY_RESTART_DELAY_SECS=3, stale flag clearing)
    • plan_restart_selects_direct_powershell_fallback_and_unavailable (Wine/Proton vs native Windows, .exe vs .ps1, own_command, menu glyph/width checks)
    • direct_restart_spawns_exe_without_powershell_and_passes_env_and_args (end-to-end CreateProcessW direct restart verifying cwd, args with spaces/Unicode/typographic apostrophes/quotes/backslashes, VICTORY_RESTART_DELAY_SECS=3, VICTORY_CLEAR_SHADERS=1, and stale VICTORY_PRELOAD removal)
    • preload_restart_preserves_paths_and_working_directory (existing .ps1 PowerShell path preserved)
  • cargo test --locked -j 3 -p victory --bin victory -- --nocapture — 80 passed, 0 failed (including restart_delay_parses_clamps_and_rejects_invalid_values, take_restart_delay_clears_env_so_children_do_not_inherit_it, and all existing play::tests::*).
  • cargo clippy --locked -j 3 -p victory-gpu -p victory --bins --tests — 0 warnings in touched files.
  • git diff --check — clean.
**@⁠steven-seagull27** on GitHub · 2026-11-29 13:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2434) `steven-seagull27:fix/1954-direct-restart-without-powershell` → `main` · +927 −39 · 3 files · 1 commits · open Fixes #1954 ## Summary - **Root cause:** `Menu::restart_as` in `crates/victory-gpu/src/host/menu.rs` unconditionally spawned `powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Sleep 3; ... & $env:VICTORY_MENU_PLAY ..."` before calling `TerminateProcess`. Under Linux/Proton (Wine), `powershell.exe` is either absent or Wine's stub executable (which `CreateProcessW` starts successfully and which then exits immediately without running anything — matching `docs/linux-proton.md` and #1954). As a result, both the one-time warmup restart (`Menu::warmup`) and F1 settings restarts closed the game without relaunching `victory.exe`. - **Direct `.exe` relaunch without PowerShell (`crates/victory-gpu/src/host/menu.rs`):** - Added Wine/Proton detection via `ntdll.dll`'s `wine_get_version` (`on_wine()`), matching `apps/victory/src/main.rs` and `crates/victory-hle/src/modules/xmem.rs`. - Added `parse_menu_args` to parse `VICTORY_MENU_ARGS` (single-quoted PowerShell tokens, escaped `''`, and `$env:VICTORY_MENU_EXE` expansion) into raw `OsString` arguments while rejecting unclosed quotes or unquoted shell operators. - Added MSVCRT / `CommandLineToArgvW`-compliant Windows command-line quoting (`build_windows_command_line`) and sorted UTF-16 environment block construction (`build_env_block`, `CREATE_UNICODE_ENVIRONMENT`) for `CreateProcessW` with `CREATE_NEW_CONSOLE`. - Added `plan_restart` strategy selection: - Launches native `.exe` targets directly without PowerShell under Wine/Proton (never hitting Wine's stub `powershell.exe`), when restarting `victory.exe` itself, and for `own_command` (save import). - Preserves PowerShell launch for `.ps1` launcher scripts on native Windows (and uses PowerShell with direct-spawn fallback for third-party `.exe` launchers on native Windows). - Refuses cleanly with a warning log and drawable menu note — without terminating the running game — if a non-`.exe` launcher or unparseable args cannot be restarted under Wine/Proton. - **Startup delay and error hold for direct restarts (`apps/victory/src/main.rs`, `apps/victory/src/play.rs`):** - Direct restarts pass `VICTORY_RESTART_DELAY_SECS=3` and the requested `Then` override (`VICTORY_PRELOAD=1` / `VICTORY_CLEAR_SHADERS=1`, clearing stale flags) directly in the child environment block. - At the very start of `main()` (before GPU/runtime initialization, address-space reservation, or child process spawns), `victory.exe` reads and immediately removes `VICTORY_RESTART_DELAY_SECS` (clamped to 30s), sleeps so the previous process exits and releases GPU/file locks cleanly, and holds the console window on startup error (`play::hold_window`) when restarted directly. ## Verification (synthetic tests only) - `cargo test --locked -j 3 -p victory-gpu --lib -- menu --nocapture --test-threads=1` — **19 passed, 0 failed**: - `parse_menu_args_handles_quotes_unicode_and_env_expansion` (spaces, Unicode, typographic apostrophes `#563`, escaped `'`, quotes, backslashes, `$env:VICTORY_MENU_EXE`, invalid syntax rejection) - `windows_command_line_round_trips_through_command_line_to_argv_w` (Win32 `CommandLineToArgvW` round-trip) - `build_env_block_applies_case_insensitive_overrides_and_removals` (`Then::Play` / `Preload` / `ClearShaders`, `VICTORY_RESTART_DELAY_SECS=3`, stale flag clearing) - `plan_restart_selects_direct_powershell_fallback_and_unavailable` (Wine/Proton vs native Windows, `.exe` vs `.ps1`, `own_command`, menu glyph/width checks) - `direct_restart_spawns_exe_without_powershell_and_passes_env_and_args` (end-to-end `CreateProcessW` direct restart verifying cwd, args with spaces/Unicode/typographic apostrophes/quotes/backslashes, `VICTORY_RESTART_DELAY_SECS=3`, `VICTORY_CLEAR_SHADERS=1`, and stale `VICTORY_PRELOAD` removal) - `preload_restart_preserves_paths_and_working_directory` (existing `.ps1` PowerShell path preserved) - `cargo test --locked -j 3 -p victory --bin victory -- --nocapture` — **80 passed, 0 failed** (including `restart_delay_parses_clamps_and_rejects_invalid_values`, `take_restart_delay_clears_env_so_children_do_not_inherit_it`, and all existing `play::tests::*`). - `cargo clippy --locked -j 3 -p victory-gpu -p victory --bins --tests` — **0 warnings** in touched files. - `git diff --check` — clean.
Relaunch native .exe targets directly via CreateProcessW instead of routing through powershell.exe when running under Wine/Proton (where powershell.exe is absent or a stub that exits immediately) or when restarting victory.exe itself, and fall back to direct launch if powershell.exe fails to spawn for third-party .exe launchers on Windows.

Pass VICTORY_RESTART_DELAY_SECS=3 and Then (VICTORY_PRELOAD / VICTORY_CLEAR_SHADERS) in the child process Unicode environment block, sleep and immediately clear VICTORY_RESTART_DELAY_SECS at startup in victory.exe (keeping the console open on error), and refuse cleanly with a warning and menu note instead of terminating the game when a non-.exe launcher cannot be restarted without PowerShell under Wine/Proton.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 13:00:44 +00:00
github-bot force-pushed github-bot/gh-2434 from d11f1e0164 to a4513f4c25 2026-11-30 18:34:26 +00:00 Compare
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-30 18:33 UTC · original

Rebased cleanly onto latest main (e1251c31, including #4067 where Steam launches victory.exe play directly and play-nvidia.ps1). Re-verified victory-gpu menu tests, victory binary tests, Clippy, and xtask policy --staged.

**@⁠steven-seagull27** on GitHub · 2026-11-30 18:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2434#issuecomment-7288027713) Rebased cleanly onto latest `main` (`e1251c31`, including `#4067` where Steam launches `victory.exe play` directly and `play-nvidia.ps1`). Re-verified `victory-gpu` menu tests, `victory` binary tests, Clippy, and `xtask policy --staged`.
github-bot force-pushed github-bot/gh-2434 from a4513f4c25 to 1309b1bf2f 2026-12-01 01:08:51 +00:00 Compare
github-bot force-pushed github-bot/gh-2434 from 1309b1bf2f to 2bf395ffba 2026-12-01 01:58:06 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/menu.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2434/head:github-bot/gh-2434'
git switch 'github-bot/gh-2434'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2434'
git switch 'github-bot/gh-2434'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2434'
git switch 'github-bot/gh-2434'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2434'
git switch 'main'
git merge --squash 'github-bot/gh-2434'
git switch 'main'
git merge --ff-only 'github-bot/gh-2434'
git switch 'main'
git merge 'github-bot/gh-2434'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2434
No description provided.