Files
RP412/tools/resbuild/build-res.ps1
T
CydandClaude Opus 5 8e2e00d8d3 The resource pipeline builds again
RPL4.RES is compiled from authored sources by RPL4TOOL -b, the original 1996
resource tool, which still builds in this tree. That pipeline did not work:
the tool aborted on the very first model, so the resource file could only be
consumed, never regenerated. Content could not be changed at all.

It died in PlugStream_FindEntryAndWriteObjectID resolving resource=
Translocation01 from AUDIO/PLYINT.SCP, a name defined in no file under
CONTENT/RP. The obvious suspect was the AWE32 soundbank path, since
AudioCard::LoadSBK is stubbed to return 1 by the Win32 port - but that is a
red herring. Supplying the banks changes nothing because nothing reads them
at build time. CreateStaticAudioStreamResource opens audio\static.scp, which
declares all 154 patch resources as plain text mapping each name to a bank
and patch number, and CONTENT/RP simply does not have that file. The sda4
developer drive does. Two more scripts included by 27 vehicles, VTVINT.SCP
and VTVEXT.SCP, were missing the same way. All three are kept in recovered/
because they are the keystone and are small.

No engine change was needed. The pipeline was missing content, not code.

build-res.ps1 assembles a build tree from the 4.10 content, those three
scripts, and the soundbanks and ~547 VIDEO files that RP412 ships complete
and the content tree does not. It never overwrites an authored file with a
shipped one, so archival content stays authoritative where it exists.

A model missing a skeleton is dropped SILENTLY - the tool logs and carries
on, producing a resource file with fewer models rather than failing. Check
the model count, which is why the script reports unresolved inputs.

-RestoreCutVehicles uncomments dark, blkspk and blktrn, three vehicles taken
out of the .bld after 4.10 shipped with their model ids left in place. All
three build clean and take the count from 42 to 45, exactly retail's, each
with its full subsystems, segments, damage zones and control mappings.

What this cannot do yet: eleven maps have no source. Five survive only on the
sda4 drive in a 1996 state older than retail, and otto, frstrm, burnt,
brewers, headoff and headmf are gone entirely - the .CAM cameras and .XST
existence boxes are here but the .MAP files are not. So a build from these
sources yields 45 models and zero maps against RP411's nine, and is not yet a
drop-in replacement for assets/RP411/RPL4.RES.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 17:12:00 -05:00

104 lines
4.8 KiB
PowerShell

# ============================================================================
# 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 <path>] [-Out <dir>] [-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`""