[MIRROR] Add a savefile migration to remove the /device from nif paths (#9102)

Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
Co-authored-by: Kashargul <KashL@t-online.de>
This commit is contained in:
CHOMPStation2
2024-09-30 12:52:17 -07:00
committed by GitHub
parent 5ea698a0ef
commit 3bc255e97c
3 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
/// Moves nif stuff to it's own file
/datum/preferences/proc/migration_15_nif_path(datum/json_savefile/S)
var/datum/json_savefile/new_savefile = new /datum/json_savefile(nif_savefile_path(client_ckey))
for(var/slot in 1 to CONFIG_GET(number/character_slots))
var/list/prefs = new_savefile.get_entry("character[slot]", null)
if(!islist(prefs))
continue
prefs["nif_path"] = replacetext(prefs["nif_path"], "/device", "")
new_savefile.set_entry("character[slot]", prefs)
new_savefile.save()

View File

@@ -1,5 +1,5 @@
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 14
#define SAVEFILE_VERSION_MAX 15
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
@@ -59,6 +59,16 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
log_debug("[client_ckey] preferences successfully migrated from [current_version] to v14.")
to_chat(client, span_danger("v14 savefile migration complete."))
// Migration for nifs, again, to get rid of the /device path
if(current_version < 15)
log_debug("[client_ckey] preferences migrating from [current_version] to v15....")
to_chat(client, span_danger("Migrating savefile from version [current_version] to v15..."))
migration_15_nif_path(S)
log_debug("[client_ckey] preferences successfully migrated from [current_version] to v15.")
to_chat(client, span_danger("v15 savefile migration complete."))
/datum/preferences/proc/update_character(current_version, list/save_data)
// Migration from BYOND savefiles to JSON: Important milemark.