# Test the PATCHED wait logic, using the exact snapshot + loop text lifted # out of the shipped play_solo.bat. Three cases, one of them the regression # guard that matters most (nothing running must never spin). $scratch = 'C:\Users\epilectrik\AppData\Local\Temp\claude\C--git-bt411\89ab96e9-6cf0-4555-939d-05bf3708745a\scratchpad' $bat = Get-Content 'C:\git\bt411\players\play_solo.bat' -Raw # lift the two patched blocks verbatim $snap = [regex]::Match($bat, '(?ms)^setlocal EnableDelayedExpansion\r?\nset "BT_PRE=,".*?^\)\r?\n').Value $loop = [regex]::Match($bat, '(?ms)^:btwait\r?\nset "BT_STILL_RUNNING=".*?^\)\r?\n').Value if (-not $snap -or -not $loop) { throw "could not lift the blocks from play_solo.bat" } "lifted snapshot block : $($snap.Split("`n").Count) lines" "lifted wait block : $($loop.Split("`n").Count) lines" function Probe($label, $snapshotFirst) { # $snapshotFirst = does the decoy exist when we take the snapshot? $body = "@echo off`r`n" if ($snapshotFirst) { $body += $snap } else { # snapshot with nothing running, decoy starts after -> looks like OURS $body += "setlocal EnableDelayedExpansion`r`nset `"BT_PRE=,`"`r`n" } $body += $loop $body += 'if defined BT_STILL_RUNNING (echo VERDICT: SPIN) else (echo VERDICT: SIGN-OFF)' + "`r`n" $p = Join-Path $scratch 'loop_probe.bat' Set-Content $p $body -Encoding Ascii $r = & cmd.exe /c $p " {0,-42} {1}" -f $label, $r } '=== C: nothing running (REGRESSION GUARD -- must sign off) ===' Probe 'no btl4 anywhere' $true $env:BT_LOG='loopprobe.log'; $env:BT_START_INSIDE='1' foreach ($v in 'BT_RELAY','BT_FE_LOOP') { Remove-Item -LiteralPath "Env:\$v" -ErrorAction SilentlyContinue } $decoy = Start-Process 'C:\git\bt411\build\Release\btl4.exe' -ArgumentList '-egg','ARENA1.EGG' ` -WorkingDirectory 'C:\git\bt411\content' -PassThru "decoy btl4 pid $($decoy.Id)" Start-Sleep -Seconds 6 '=== A: someone ELSE''s btl4 (in the snapshot) -- must sign off ===' Probe 'unrelated instance alive' $true '=== B: OUR generation (not in the snapshot) -- must keep waiting ===' Probe 'our own generation alive' $false Stop-Process -Id $decoy.Id -Force -ErrorAction SilentlyContinue Start-Sleep -Seconds 2 '=== C2: decoy gone, re-check the guard ===' Probe 'nothing running again' $true