# ============================================================================ # build-res.ps1 - rebuild RPL4.RES from the 4.10 content sources # ============================================================================ # # Assembles a build tree from three places and runs the original resource # compiler (Release\RPL4TOOL.exe -b). See README.md in this folder for what # each piece is and why it is needed. # # 1. TeslaRel410\CONTENT\RP the authored content: models, solids, # audio scripts, gauge art, the .bld script # 2. recovered\ three audio scripts missing from (1), # recovered from the sda4 developer drive. # Without STATIC.SCP nothing builds at all. # 3. assets\RP411\ the soundbanks and the .SKL skeletons that # (1) is missing - RP412 ships complete sets # # Usage: powershell -ExecutionPolicy Bypass -File tools\resbuild\build-res.ps1 # [-Content ] [-Out ] [-RestoreCutVehicles] # param( [string]$Content = 'C:\VWE\TeslaRel410\CONTENT\RP', [string]$Out = "$env:TEMP\rp412-resbuild", # Uncomment dark / blkspk / blktrn in the .bld before building. They were # commented out after 4.10 shipped; their sources are all still here. [switch]$RestoreCutVehicles ) $ErrorActionPreference = 'Stop' $root = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) $tool = Join-Path $root 'Release\RPL4TOOL.exe' $assets = Join-Path $root 'assets\RP411' $recovered = Join-Path $PSScriptRoot 'recovered' if (-not (Test-Path $tool)) { throw "$tool not found - build the solution first (BUILD.md 2)." } if (-not (Test-Path $Content)) { throw "content tree not found: $Content" } # --- assemble --------------------------------------------------------------- Write-Host "Assembling build tree in $Out" if (Test-Path $Out) { Remove-Item -Recurse -Force $Out } New-Item -ItemType Directory -Force $Out | Out-Null Copy-Item "$Content\*" $Out -Recurse -Force # The soundbanks. AUDIO.INI names audio\audio1.res and audio2.res; the content # tree carries only a 1-byte AUDIO.RES stub. RP412's copies are hash-identical # to the 1996 originals in the pod image. foreach ($bank in 'AUDIO1.RES', 'AUDIO2.RES') { Copy-Item (Join-Path $assets "AUDIO\$bank") "$Out\AUDIO\" -Force } # The keystone. CreateStaticAudioStreamResource opens audio\static.scp, which # defines all 154 PatchResources by name (Translocation01 -> bank 2, patch 29 # and so on). Every model's audio script resolves its resource= names against # them, so without this file the very first model aborts the build. Copy-Item "$recovered\*.SCP" "$Out\AUDIO\" -Force # Skeletons and geometry the content tree is missing (BAN/BUN/DUN/MAN.SKL and # their S variants at least). Fill gaps only - never overwrite authored content # with the shipped copy, so archival files stay authoritative where they exist. $filled = 0 foreach ($src in Get-ChildItem (Join-Path $assets 'VIDEO') -File) { $dst = Join-Path "$Out\VIDEO" $src.Name if (-not (Test-Path $dst) -or (Get-Item $dst).Length -eq 0) { Copy-Item $src.FullName $dst -Force; $filled++ } } Write-Host " filled $filled missing VIDEO file(s)" if ($RestoreCutVehicles) { $bld = Join-Path $Out 'RPL4.BLD' (Get-Content $bld -Raw) -replace '(?m)^//(model=(dark|blkspk|blktrn)\.mod)', '$1' | Set-Content $bld -Encoding ascii Write-Host " restored dark, blkspk, blktrn in RPL4.BLD" } Copy-Item $tool $Out -Force # --- build ------------------------------------------------------------------ # RPL4TOOL ends in _getch() (RPL4TOOL.cpp:76), so it never exits on its own # when stdout is redirected. Run it detached and reap it once the file lands. Write-Host "Building..." $log = Join-Path $Out 'build.log' $p = Start-Process -FilePath (Join-Path $Out 'RPL4TOOL.exe') ` -ArgumentList '-b', 'rpl4.bld' -WorkingDirectory $Out ` -RedirectStandardOutput $log -PassThru -WindowStyle Hidden if (-not $p.WaitForExit(300000)) { Start-Sleep -Seconds 2 } if (-not $p.HasExited) { Stop-Process -Id $p.Id -Force } $res = Join-Path $Out 'rpl4.res' if (-not (Test-Path $res)) { Get-Content $log -Tail 20 | ForEach-Object { Write-Host " $_" } throw "build produced no rpl4.res - see $log" } # --- report ----------------------------------------------------------------- $missing = Select-String -Path $log -Pattern 'Does not exist!|is empty or missing!|has no Segments!' | ForEach-Object { $_.Line.Trim() } | Sort-Object -Unique Write-Host ("rpl4.res: {0:N0} bytes" -f (Get-Item $res).Length) if ($missing) { Write-Host "Unresolved inputs ($($missing.Count)) - see README.md 'What is still missing':" $missing | ForEach-Object { Write-Host " $_" } } Write-Host "Output: $res" Write-Host "List it with: Release\RPL4TOOL.exe -l `"$res`""