Repacking dist keeps the player's files

The game stopped shipping environ.ini so a new build could land on an
existing folder without replacing anyone's settings. pack-dist.ps1 then
went on rebuilding dist\ from nothing every time, which threw away
environ.ini, bindings.txt, pilot.cfg and mfd_layout.cfg on every repack -
the one place the promise did not hold, and the folder we do most of our
own testing in.

They are now carried across the rebuild. -Fresh wipes them too, for
checking what a genuine first run does.

Restored last, after the tree is rebuilt, so nothing the pack writes can
land on top of them. Not restored at all under -Zip: the archive is taken
from dist\, so a preserved file would otherwise travel to whoever
downloads the release, and a release should always be built from a folder
with none of them in it.

Also fixes three paragraphs of the packaged README that have been saying
the opposite of the truth since the change: that environ.ini ships, that
it is the only one of the four that does, and that bindings.txt is the
only one never overwritten. Those edits were made at the time with
PowerShell .Replace() calls that silently matched nothing - which is
exactly why the same corrections here are made with an editor that fails
loudly instead.

Verified by editing all four files, repacking, and reading the first line
of each back out of the rebuilt folder; then again with -Fresh to confirm
all four are gone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-08-05 15:56:01 -05:00
co-authored by Claude Opus 5
parent 82e733c1a6
commit a0a0ad51d1
+54 -11
View File
@@ -11,10 +11,12 @@
# (environ.ini is NOT shipped - the exe writes it on first run)
# - start/joyconfig scripts, HANDBOOK.html, CONTROLS.txt and a README
#
# Usage: powershell -ExecutionPolicy Bypass -File pack-dist.ps1 [-Zip]
# Usage: powershell -ExecutionPolicy Bypass -File pack-dist.ps1 [-Zip] [-Fresh]
#
param(
[switch]$Zip
[switch]$Zip,
# Wipe the player's files too, for testing what a first run does.
[switch]$Fresh
)
$ErrorActionPreference = 'Stop'
@@ -52,6 +54,27 @@ if ($running) {
}
Write-Host "Packing into $dist"
# --- the player's own files ------------------------------------------------
# None of these ship: the game writes each one the first time it needs it and
# then leaves it alone, so a new build dropped over a folder keeps every
# setting. This script rebuilds dist\ from scratch, which would throw exactly
# those away - the one place the promise did not hold, and it is the folder we
# do most of our own testing in. Carry them across. -Fresh to start over.
$keepFiles = @('environ.ini', 'bindings.txt', 'pilot.cfg', 'mfd_layout.cfg')
$kept = @{}
if (-not $Fresh) {
foreach ($name in $keepFiles) {
$path = Join-Path $dist $name
if (Test-Path $path) { $kept[$name] = [System.IO.File]::ReadAllBytes($path) }
}
if ($kept.Count -gt 0) {
Write-Host " keeping $($kept.Keys -join ', ')"
}
} elseif (Test-Path $dist) {
Write-Host " -Fresh: the player's files go too"
}
if (Test-Path $dist) { Remove-Item -Recurse -Force $dist }
New-Item -ItemType Directory -Force "$dist\SPOOLS" | Out-Null
@@ -232,17 +255,19 @@ at its left, and the lower MFDs flanking the portrait map. The red
buttons around each MFD and the amber buttons beside the map are the
pod's real button banks: click them with the mouse, and they light up
as the game commands their lamps.
environ.ini is self-documenting: every option ships in the file with
a comment (Steam networking, keyboard lighting, stick inversion, LAN
hosting, developer keys, display scaling and radar placement, and more).
environ.ini is self-documenting: the game writes it on first run with
every option in it and a comment on each (Steam networking, keyboard
lighting, stick inversion, LAN hosting, developer keys, display scaling
and radar placement, and more).
HANDBOOK.html is the full manual - open it in a browser for the pad,
keyboard and pod-panel diagrams, the joystick setup, and what every file
in this folder is for. CONTROLS.txt is the controls half as plain text.
Four files here are yours. environ.ini is the only one that ships; the
game writes the rest when it first needs them, so deleting any of them
simply starts that part over:
Four files here are yours. None of them ship - the game writes each one
the first time it needs it and then leaves it alone, so a new build
unzipped over this folder keeps everything you have set. Delete any of
them to start that part over:
environ.ini every engine option, commented in place
bindings.txt every key, pad button, axis and joystick row
@@ -251,9 +276,11 @@ simply starts that part over:
Two that catch people out: environ.ini is applied OVER the environment,
so a variable set in a shell loses to an uncommented line in the file;
and bindings.txt is never overwritten once it exists, which is what
protects your edits - so after an update, delete it to pick up any new
default bindings.
and none of these four is ever overwritten once it exists, which is what
lets you keep a folder across builds. The trade is that a file carried
through several updates stops being offered new options - rpl4.log names
any it has not heard of, and deleting the file brings back the fully
documented current one.
Known prototype notes: pods race untextured (the player1-8 skins come
from the presets system, not shipped data), and text drawn on the plasma
@@ -262,6 +289,22 @@ glass may appear rotated.
Source: https://gitea.mysticmachines.com/VWE/RP412
"@
# --- the player's own files, back where they were --------------------------
# Last, so the rebuilt tree cannot overwrite them. The zip below is taken
# from dist\, so a preserved file would otherwise travel to whoever gets the
# package - hence the copies are put back only when we are NOT zipping, and a
# release is always built from a folder with none of them in it.
if ($kept.Count -gt 0) {
if ($Zip) {
Write-Host " -Zip: leaving $($kept.Keys -join ', ') out, so the release ships clean"
} else {
foreach ($name in $kept.Keys) {
[System.IO.File]::WriteAllBytes((Join-Path $dist $name), $kept[$name])
}
Write-Host " restored $($kept.Keys -join ', ')"
}
}
# --- summary / optional zip ------------------------------------------------
$size = (Get-ChildItem $dist -Recurse | Measure-Object Length -Sum).Sum
Write-Host ("dist ready: {0:N1} MB" -f ($size / 1MB))