Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(tools): dx11 and shadow checks kill their own game by id

Olcay Seygan7b312e65f531
diff --git a/dx11-check.ps1 b/dx11-check.ps1
index a13a80d65..b6b176479 100644
--- a/dx11-check.ps1
+++ b/dx11-check.ps1
@@ -84,13 +84,14 @@ function Shoot($c, $tag, $switches) {
'-msaa','0','-dx11post','off','-map',"`"Maps\$($c.map)\$($c.map).map`"",'-autoskirmish','4','-aidiff','easy',
'-seed','5','-maxframes',($c.f+80),'-screenshot',$c.f,'-camera',$c.x,$c.y,
'-logPrefix',"dx11chk_$tag`_",'-turbo') + $switches + $Extra
+ $process = Start-Process (Join-Path $run 'generals.exe') -ArgumentList $arguments -WorkingDirectory $run -PassThru
try {
- $process = Start-Process (Join-Path $run 'generals.exe') -ArgumentList $arguments -WorkingDirectory $run -PassThru
$process.PriorityClass = 'AboveNormal'
$null = $process.WaitForExit(900000)
}
finally {
- Get-Process -Name generals -ErrorAction SilentlyContinue | Stop-Process -Force
+ # By id: another session's game on the same machine is not this script's to end.
+ if (-not $process.HasExited) { Stop-Process -Id $process.Id -Force }
}
$file = Get-ChildItem "$shots\sshot*.bmp" -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime | Select-Object -Last 1
diff --git a/shadow-check.ps1 b/shadow-check.ps1
index f76f3d5e6..3b82b9efe 100644
--- a/shadow-check.ps1
+++ b/shadow-check.ps1
@@ -35,14 +35,15 @@ function Shoot($case, $tag, $extra) {
'-autoskirmish','4','-aidiff','easy','-seed','5','-maxframes',($case.f+80),
'-screenshot',$case.f,'-camera',$case.x,$case.y,'-logPrefix',"shd_$tag`_",'-turbo')
if ($extra) { $arguments += $extra }
+ $process = Start-Process (Join-Path $run "generals.exe") -ArgumentList $arguments `
+ -WorkingDirectory $run -PassThru
try {
- $process = Start-Process (Join-Path $run "generals.exe") -ArgumentList $arguments `
- -WorkingDirectory $run -PassThru
$process.PriorityClass = 'AboveNormal'
$null = $process.WaitForExit(900000)
}
finally {
- Get-Process -Name generals -ErrorAction SilentlyContinue | Stop-Process -Force
+ # By id: another session's game on the same machine is not this script's to end.
+ if (-not $process.HasExited) { Stop-Process -Id $process.Id -Force }
}
# The picture is written on the frame it was asked for and the process runs on to its frame
# limit, so the file can land a moment after the wait returns. A view that still has none is