windows: write steam_appid.txt before starting (the cause of the Steam error box); start the server window minimized
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7d8aa4a029
commit
d84d736846
4 files changed
+12
-8
No files matched your search
+8
-4
@@ -334,11 +334,15 @@ function Start-CsServer($root) {
|
||||
$y = $y -replace '(?m)^yb_difficulty ".*"', ('yb_difficulty "' + [int]$s.CS_BOT_DIFFICULTY + '"')
|
||||
Write-TextFile $ycfg $y
|
||||
$hargs = "-console -condebug -game cstrike -port $([int]$s.CS_PORT) +maxplayers $([int]$s.CS_MAXPLAYERS) +map $($s.CS_MAP) +log on"
|
||||
# On the first start after an install, the server's Steam part sets itself up and the server
|
||||
# stops with a "Fatal error: Unable to initialize Steam" box. A new start works, so that box
|
||||
# gets the server closed and started again.
|
||||
# A fresh install has no steam_appid.txt. hlds writes it while starting, but too late: Steam
|
||||
# has already failed and the server sits on a "Fatal error: Unable to initialize Steam" box.
|
||||
# 10 = Counter-Strike.
|
||||
$appid = Join-Path $h 'steam_appid.txt'
|
||||
if (-not (Test-Path -LiteralPath $appid) -or [IO.File]::ReadAllText($appid).Trim() -ne '10') { Write-TextFile $appid "10`r`n" }
|
||||
# If that box still shows up, close the server and start it again. The window starts minimized
|
||||
# so it doesn't take the keyboard away from whatever you're doing.
|
||||
for ($try = 1; $try -le 3; $try++) {
|
||||
$p = Start-Process -FilePath (Join-Path $h 'hlds.exe') -WorkingDirectory $h -ArgumentList $hargs -PassThru
|
||||
$p = Start-Process -FilePath (Join-Path $h 'hlds.exe') -WorkingDirectory $h -ArgumentList $hargs -PassThru -WindowStyle Minimized
|
||||
if (-not (Test-SteamFailure $p ([int]$s.CS_PORT))) { break }
|
||||
Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
Reference in new issue
Block a user