mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 19:47:47 +01:00
Fix NIFs being horrible and overriding prefs with byond savefiles
This commit is contained in:
@@ -220,7 +220,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
|
||||
save_data["b_wing3"] = pref.b_wing3
|
||||
save_data["digitigrade"] = pref.digitigrade
|
||||
|
||||
/datum/category_item/player_setup_item/general/body/sanitize_character(var/savefile/S)
|
||||
/datum/category_item/player_setup_item/general/body/sanitize_character()
|
||||
if(!pref.species || !(pref.species in GLOB.playable_species))
|
||||
pref.species = SPECIES_HUMAN
|
||||
pref.r_hair = sanitize_integer(pref.r_hair, 0, 255, initial(pref.r_hair))
|
||||
|
||||
@@ -38,23 +38,8 @@
|
||||
|
||||
/datum/category_item/player_setup_item/vore/nif/copy_to_mob(var/mob/living/carbon/human/character)
|
||||
//If you had a NIF...
|
||||
if((character.type == /mob/living/carbon/human) && ispath(pref.nif_path) && pref.nif_durability)
|
||||
new pref.nif_path(character,pref.nif_durability,pref.nif_savedata)
|
||||
|
||||
/*
|
||||
//And now here's the trick. We wipe these so that if they die, they lose the NIF.
|
||||
//Backup implants will start saving this again periodically, and so will cryo'ing out.
|
||||
pref.nif_path = null
|
||||
pref.nif_durability = null
|
||||
pref.nif_savedata = null
|
||||
*/
|
||||
//No we do not, that's lame and admins have to re-NIF them later.
|
||||
//If they leave round after they get their NIF extracted, it will save as 'gone' anyway
|
||||
//The NIF will save automatically every time durability changes too now.
|
||||
var/savefile/S = new /savefile(pref.path)
|
||||
if(!S) WARNING ("Couldn't load NIF save savefile? [pref.real_name]")
|
||||
S.cd = "/character[pref.default_slot]"
|
||||
save_character(S)
|
||||
if(istype(character) && ispath(pref.nif_path) && pref.nif_durability)
|
||||
new pref.nif_path(character, pref.nif_durability, pref.nif_savedata)
|
||||
|
||||
/datum/category_item/player_setup_item/vore/nif/content(var/mob/user)
|
||||
. += "<b>NIF:</b> [ispath(pref.nif_path) ? "Present" : "None"]"
|
||||
|
||||
@@ -460,7 +460,7 @@ var/list/preferences_datums = list()
|
||||
var/default
|
||||
var/list/charlist = list()
|
||||
|
||||
for(var/i = 1 to config.character_slots)
|
||||
for(var/i in 1 to config.character_slots)
|
||||
var/list/save_data = savefile.get_entry("character[i]", list())
|
||||
var/name = save_data["real_name"]
|
||||
var/nickname = save_data["nickname"]
|
||||
@@ -506,7 +506,7 @@ var/list/preferences_datums = list()
|
||||
|
||||
if(!name)
|
||||
name = "[i] - \[Unused Slot\]"
|
||||
if(i == default_slot)
|
||||
else if(i == default_slot)
|
||||
name = "►[i] - [name]"
|
||||
else
|
||||
name = "[i] - [name]"
|
||||
|
||||
@@ -41,8 +41,14 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
// Migration for client preferences
|
||||
if(current_version < 13)
|
||||
log_debug("[client_ckey] preferences migrating from [current_version] to v13....")
|
||||
to_chat(client, span_danger("Migrating savefile from version [current_version] to v13..."))
|
||||
|
||||
migration_13_preferences(S)
|
||||
|
||||
log_debug("[client_ckey] preferences successfully migrated from [current_version] to v13.")
|
||||
to_chat(client, span_danger("v13 savefile migration complete."))
|
||||
|
||||
|
||||
/datum/preferences/proc/update_character(current_version, list/save_data)
|
||||
// Migration from BYOND savefiles to JSON: Important milemark.
|
||||
@@ -52,6 +58,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
/// Migrates from byond savefile to json savefile
|
||||
/datum/preferences/proc/try_savefile_type_migration()
|
||||
log_debug("[client_ckey] preferences migrating from savefile to JSON...")
|
||||
to_chat(client, span_danger("Savefile migration to JSON in progress..."))
|
||||
|
||||
load_path(client.ckey, "preferences.sav") // old save file
|
||||
var/old_path = path
|
||||
load_path(client.ckey)
|
||||
@@ -60,6 +69,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
var/datum/json_savefile/json_savefile = new(path)
|
||||
json_savefile.import_byond_savefile(new /savefile(old_path))
|
||||
json_savefile.save()
|
||||
|
||||
log_debug("[client_ckey] preferences successfully migrated from savefile to JSON.")
|
||||
to_chat(client, span_danger("Savefile migration to JSON is complete."))
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/preferences/proc/load_path(ckey, filename = "preferences.json")
|
||||
|
||||
Reference in New Issue
Block a user