Fix NIFs being horrible and overriding prefs with byond savefiles

This commit is contained in:
ShadowLarkens
2024-09-07 14:11:18 -07:00
parent f9052dbb60
commit 3eb1849626
6 changed files with 30 additions and 44 deletions
@@ -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"]"
+2 -2
View File
@@ -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")
+10 -17
View File
@@ -353,27 +353,25 @@
if(selecting_slots)
to_chat(user, "<span class='warning'>You already have a slot selection dialog open!</span>")
return
var/savefile/S = new /savefile(path)
if(!S)
error("Somehow missing savefile path?! [path]")
if(!savefile)
return
var/name
var/nickname //vorestation edit - This set appends nicknames to the save slot
var/list/charlist = list()
var/default //VOREStation edit
for(var/i=1, i<= config.character_slots, i++)
S.cd = "/character[i]"
S["real_name"] >> name
S["nickname"] >> nickname //vorestation edit
var/default
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"]
if(!name)
name = "[i] - \[Unused Slot\]"
else if(i == default_slot)
name = "►[i] - [name]"
default = "[name][nickname ? " ([nickname])" : ""]"
else
name = "[i] - [name]"
if (i == default_slot) //VOREStation edit
default = "[name][nickname ? " ([nickname])" : ""]"
charlist["[name][nickname ? " ([nickname])" : ""]"] = i
var/remember_default = default_slot
@@ -396,11 +394,6 @@
return remember_default
/datum/preferences/proc/return_to_character_slot(mob/user, var/remembered_default)
var/savefile/S = new /savefile(path)
if(!S)
error("Somehow missing savefile path?! [path]")
return
load_character(remembered_default)
attempt_vr(user.client?.prefs_vr,"load_vore","") //VOREStation Edit
sanitize_preferences()
+2 -7
View File
@@ -260,10 +260,5 @@
prefs.nif_durability = null
prefs.nif_savedata = null
var/datum/category_group/player_setup_category/vore_cat = prefs.player_setup.categories_by_name["VORE"]
var/datum/category_item/player_setup_item/vore/nif/nif_prefs = vore_cat.items_by_name["NIF Data"]
var/savefile/S = new /savefile(prefs.path)
if(!S) warning("Persist (NIF): Couldn't load NIF save savefile? [prefs.real_name]")
S.cd = "/character[prefs.default_slot]"
nif_prefs.save_character(S)
prefs.save_character()
prefs.save_preferences()