0.6.1: Emberwild is now Cinderwild (the old name's taken on Steam). Saves, identity and settings are copied across from the Emberwild folder on first start; the site moves to cinderwild.psbailey.uk; same protocol (18), so 0.6.0 and 0.6.1 play together

This commit is contained in:
Paul Bailey
2026-11-07 16:14:11 +00:00
parent 04b9d17826
commit c2c86b5f78
36 changed files with 262 additions and 173 deletions

View File

@@ -2,16 +2,17 @@ extends Node
## Autoload "Boot", first in the list: one-off start-up housekeeping that has
## to happen before anything reads user://.
##
## The game was called "Valheimlike" until it became "Emberwild". Godot names
## the user-data folder after the project, so the rename moved it from
## .../app_userdata/Valheimlike to .../app_userdata/Emberwild. The first time
## Emberwild starts, this copies saved worlds, your identity (key, name, look)
## and server settings across. It copies rather than moves, so the old folder
## stays as a backup, and it never overwrites anything already in the new
## folder. Test folders (test_*) and logs are skipped.
## The game has been renamed twice: "Valheimlike", then "Emberwild" (0.1.0 to
## 0.6.0), now "Cinderwild". Godot names the user-data folder after the
## project, so each rename moved it (.../app_userdata/<name>). The first time
## Cinderwild starts, this copies saved worlds, your identity (key, name,
## look), settings and server settings across from the newest old folder there
## is (it already holds what came from the one before). It copies rather than moves, so the old folders stay
## as a backup, and it never overwrites anything already in the new folder.
## Test folders (test_*) and logs are skipped.
const OLD_NAME := "Valheimlike"
const MARKER := "migrated_from_valheimlike.txt"
const OLD_NAMES := ["Emberwild", "Valheimlike"] ## newest first
const MARKER := "migrated_from_%s.txt"
const SKIP := ["logs", "shader_cache", "vulkan", "test_worlds", "test_net"]
var copied := 0
@@ -22,14 +23,25 @@ func _enter_tree() -> void:
## Returns the number of files copied (0 if there was nothing to do).
func migrate_user_data() -> int:
var new_dir := OS.get_user_data_dir()
var old_dir := new_dir.get_base_dir().path_join(OLD_NAME)
for old_name in OLD_NAMES:
var old_dir := new_dir.get_base_dir().path_join(old_name)
if DirAccess.dir_exists_absolute(old_dir) and old_dir != new_dir:
# Only the newest: it already holds whatever came across from the
# one before (a world deleted since shouldn't come back).
return migrate_from(old_dir, new_dir, old_name)
return 0
## Copies `old_dir` into `new_dir` once (a marker file in `new_dir` says it's
## been done). Returns the number of files copied.
func migrate_from(old_dir: String, new_dir: String, old_name: String) -> int:
if new_dir == old_dir or not DirAccess.dir_exists_absolute(old_dir):
return 0
if FileAccess.file_exists(new_dir.path_join(MARKER)):
var marker := new_dir.path_join(MARKER % old_name.to_lower())
if FileAccess.file_exists(marker):
return 0
copied = 0
_copy_tree(old_dir, new_dir)
var f := FileAccess.open(new_dir.path_join(MARKER), FileAccess.WRITE)
var f := FileAccess.open(marker, FileAccess.WRITE)
if f != null:
f.store_string("Copied %d files from %s on %s. The old folder was left as it was.\n" % [
copied, old_dir, Time.get_datetime_string_from_system()])
@@ -43,6 +55,8 @@ func _copy_tree(from: String, to: String) -> void:
if da == null:
return
for f in da.get_files():
if f.begins_with("migrated_from_"):
continue # (the old folder's own markers)
var dst := to.path_join(f)
if not FileAccess.file_exists(dst) and DirAccess.copy_absolute(from.path_join(f), dst) == OK:
copied += 1