fix: leave world settings alone on a wipe, and snapshot them first

Reverts the restore-from-template behaviour. A wipe now resets the world and the
player database only; Server/<name>_{SandboxVars,spawnregions,spawnpoints}.lua
carry over untouched, so hand tuning survives it. Verified by checksum: all three
files byte-identical either side of a wipe.

That gives up the guarantee the restore bought. PZ writes the running world's
settings back over those files, so if a world is ever created with defaults the
file inherits them and later wipes regenerate from them -- which is how a Sophie
world became an Apocalypse one. Nothing corrects that automatically now, so the
wipe takes a snapshot of the settings before it starts, keeping the last ten
under config-backup/. Greg's edits were lost once because the only record of them
was a file the server had since overwritten; that is the hole this fills.
config-template/ still holds the pristine Sophie preset to copy back from.

The snapshot is best-effort throughout. The first version of it created the
directory with plain mkdir, the parent belongs to the container's subuid rather
than the podman user, and set -e turned that into a failed wipe -- the same shape
as the tee that broke this script before. Ansible owns the directory now and
every step of the snapshot tolerates failure, because a backup that cannot be
written is not a reason to refuse to wipe.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bastian de Byl
2026-08-26 23:10:37 -04:00
co-authored by Claude Opus 5
parent 1c467b1a76
commit 60d5ec4ae3
2 changed files with 45 additions and 28 deletions
@@ -23,14 +23,17 @@
# than the container's subuid. Getting this wrong silently broke world resets:
# the script's first log line failed with EACCES and set -e killed it before it
# stopped the server, so `@bot` resets did nothing at all.
- name: create zomboid canonical config directory
- name: create zomboid host-side config directories
become: true
ansible.builtin.file:
path: "{{ zomboid_path }}/config-template"
path: "{{ zomboid_path }}/{{ item }}"
state: directory
owner: "{{ podman_user }}"
group: "{{ podman_user }}"
mode: 0755
loop:
- config-template
- config-backup
- name: create zomboid host-side log directory
become: true
@@ -228,18 +231,17 @@
state: started
daemon_reload: true
# The intended world settings, kept somewhere the server cannot reach.
# A pristine copy of the Sophie preset, kept where the server cannot overwrite it.
#
# PZ reads Server/<name>_SandboxVars.lua only when it creates a world, and then
# writes the *running world's* settings back over that same file. So the file in
# Server/ is an output, not an input: once any world is created with defaults,
# the server stamps those defaults into it and every later wipe regenerates from
# them. That is how a Sophie world quietly became an Apocalypse one -- 139 values
# reverted, loot rates from 0.35 back to 0.9, CharacterFreePoints from 0 to 60.
# Reference only -- nothing applies this automatically. A wipe deliberately leaves
# the live settings alone so hand tuning survives it.
#
# This copy is what a wipe restores from, so settings survive it. Seeded once and
# then left alone, so it is the file to hand-edit when changing the world:
# edit here, then wipe, and the new world comes up with the edits.
# It exists because the live files cannot be trusted as a record of intent: PZ
# reads Server/<name>_SandboxVars.lua only when it creates a world, then writes
# the running world's settings back over it. The file in Server/ is an output as
# much as an input, and that is how a Sophie world quietly became an Apocalypse
# one -- 139 values reverted, loot from 0.35 back to 0.9, CharacterFreePoints
# from 0 to 60. When that happens again, this is what to copy back from.
- name: seed canonical zomboid world settings
become: true
ansible.builtin.copy: