paavohtl Claude Opus 4.6 commited on
Commit
1d0cd99
·
1 Parent(s): 9233b4e

fix: use openwa-config registry lookup in replay-test.ps1

Browse files

The script had a hardcoded fallback path (I:\games\...) that broke on
machines with WA installed elsewhere. Now resolves the WA directory
using the same OPENWA_WA_PATH env var / HKCU registry key priority
as the openwa-config crate, matching run-tests.ps1 behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. replay-test.ps1 +22 -4
replay-test.ps1 CHANGED
@@ -13,8 +13,28 @@ param(
13
 
14
  $ErrorActionPreference = "Stop"
15
 
16
- $waExe = if ($env:OPENWA_WA_PATH) { $env:OPENWA_WA_PATH } else { "I:\games\SteamLibrary\steamapps\common\Worms Armageddon\WA.exe" }
17
- $gameDir = Split-Path $waExe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  $src = "target\i686-pc-windows-msvc\release"
19
  $logDir = "testdata\logs"
20
 
@@ -50,8 +70,6 @@ if (Test-Path "$gameDir\wkOpenWAValidator.dll") {
50
  }
51
 
52
  # 3. Launch via launcher with replay, env vars set
53
- $env:OPENWA_WA_PATH = $waExe
54
-
55
  if ($Headless) {
56
  Write-Host "Launching WA.exe in HEADLESS mode: $ReplayFile" -ForegroundColor Cyan
57
  Write-Host " (No window -- pure simulation via /getlog)" -ForegroundColor Yellow
 
13
 
14
  $ErrorActionPreference = "Stop"
15
 
16
+ # Resolve WA installation directory using the same priority order as openwa-config:
17
+ # 1. OPENWA_WA_PATH env var (may be WA.exe path or directory)
18
+ # 2. HKCU\SOFTWARE\Team17SoftwareLTD\WormsArmageddon, value PATH
19
+ function Get-WaDir {
20
+ if ($env:OPENWA_WA_PATH) {
21
+ $p = $env:OPENWA_WA_PATH
22
+ if ($p -match '\.exe$') { return Split-Path $p }
23
+ return $p
24
+ }
25
+ try {
26
+ $reg = Get-ItemPropertyValue -Path 'HKCU:\SOFTWARE\Team17SoftwareLTD\WormsArmageddon' -Name 'PATH' -ErrorAction Stop
27
+ if ($reg) { return $reg }
28
+ } catch {}
29
+ return $null
30
+ }
31
+
32
+ $gameDir = Get-WaDir
33
+ if (-not $gameDir) {
34
+ Write-Error "Cannot find WA installation. Set OPENWA_WA_PATH or ensure the registry key HKCU\SOFTWARE\Team17SoftwareLTD\WormsArmageddon\PATH is set."
35
+ exit 1
36
+ }
37
+ $waExe = Join-Path $gameDir "WA.exe"
38
  $src = "target\i686-pc-windows-msvc\release"
39
  $logDir = "testdata\logs"
40
 
 
70
  }
71
 
72
  # 3. Launch via launcher with replay, env vars set
 
 
73
  if ($Headless) {
74
  Write-Host "Launching WA.exe in HEADLESS mode: $ReplayFile" -ForegroundColor Cyan
75
  Write-Host " (No window -- pure simulation via /getlog)" -ForegroundColor Yellow