fix: stop the world wipe taking the world settings with it
A wipe was quietly turning a Sophie world into an Apocalypse one. 139 sandbox
values had reverted -- loot rates from 0.35 back to 0.9, ranged weapons and ammo
to 2.0, CharacterFreePoints from 0 to 60 -- and ten of Sophie's mod-added
options had vanished entirely.
The reset script was not deleting the settings. 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. The file is an output, not an
input. So once any world came up with defaults, the server stamped those defaults
into the file, and every wipe afterwards regenerated from them -- inheriting the
corruption rather than causing it, and with no way back out on its own. The same
shape as the admin-password deadlock.
The intended settings now live in config-template/, which the server has no
reason to touch, and a wipe restores Server/<name>_{SandboxVars,spawnregions,
spawnpoints}.lua from there before restarting. That is also the file to hand-edit
when changing the world: edit the template, wipe, and the new world has the edits.
Verified by wiping: 139 differences before, 0 after. The server still rewrites
the live file on boot -- 996 keys become 1061 as it adds newer options -- but
every Sophie value survives that now.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
05fc3b5c65
commit
1c467b1a76
@@ -23,6 +23,15 @@
|
|||||||
# than the container's subuid. Getting this wrong silently broke world resets:
|
# 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
|
# 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.
|
# stopped the server, so `@bot` resets did nothing at all.
|
||||||
|
- name: create zomboid canonical config directory
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ zomboid_path }}/config-template"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ podman_user }}"
|
||||||
|
group: "{{ podman_user }}"
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
- name: create zomboid host-side log directory
|
- name: create zomboid host-side log directory
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -219,6 +228,33 @@
|
|||||||
state: started
|
state: started
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
# The intended world settings, kept somewhere the server cannot reach.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
- name: seed canonical zomboid world settings
|
||||||
|
become: true
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "zomboid/sophie/{{ item }}.lua"
|
||||||
|
dest: "{{ zomboid_path }}/config-template/{{ item }}.lua"
|
||||||
|
force: "{{ zomboid_config_force | bool }}"
|
||||||
|
owner: "{{ podman_user }}"
|
||||||
|
group: "{{ podman_user }}"
|
||||||
|
mode: 0644
|
||||||
|
loop:
|
||||||
|
- SandboxVars
|
||||||
|
- spawnregions
|
||||||
|
- spawnpoints
|
||||||
|
tags: zomboid-conf
|
||||||
|
|
||||||
# The server's own logs, not the container's. PZ holds these fds open for the
|
# The server's own logs, not the container's. PZ holds these fds open for the
|
||||||
# life of the process, so copytruncate is mandatory -- a rename would leave it
|
# life of the process, so copytruncate is mandatory -- a rename would leave it
|
||||||
# writing into an unlinked inode and the file would appear to stop growing.
|
# writing into an unlinked inode and the file would appear to stop growing.
|
||||||
|
|||||||
@@ -55,6 +55,24 @@ else
|
|||||||
log "No database found at $DB_PATH"
|
log "No database found at $DB_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore the intended world settings before the server regenerates.
|
||||||
|
#
|
||||||
|
# Without this the wipe silently changes the game. PZ writes the running world's
|
||||||
|
# settings back over Server/<name>_SandboxVars.lua, so by the time we delete the
|
||||||
|
# save that file already describes the world we are throwing away -- and if that
|
||||||
|
# world had defaults, the replacement inherits them. Restoring from the canonical
|
||||||
|
# copy is what makes a wipe reset the world and keep the settings.
|
||||||
|
CONFIG_TEMPLATE="{{ podman_home }}/.local/share/volumes/zomboid/config-template"
|
||||||
|
SERVER_DIR="{{ podman_home }}/.local/share/volumes/zomboid/data/Server"
|
||||||
|
for f in SandboxVars spawnregions spawnpoints; do
|
||||||
|
if [[ -f "${CONFIG_TEMPLATE}/${f}.lua" ]]; then
|
||||||
|
podman unshare cp "${CONFIG_TEMPLATE}/${f}.lua" "${SERVER_DIR}/${SERVER_NAME}_${f}.lua"
|
||||||
|
log "Restored ${SERVER_NAME}_${f}.lua from canonical config"
|
||||||
|
else
|
||||||
|
log "WARNING: no canonical ${f}.lua; the new world will inherit whatever the server last wrote"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Start server
|
# Start server
|
||||||
log "Starting zomboid service..."
|
log "Starting zomboid service..."
|
||||||
systemctl --user start zomboid.service
|
systemctl --user start zomboid.service
|
||||||
|
|||||||
Reference in New Issue
Block a user