From b7f34db888866bd2ba3e62dba5f658b8633e258a Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Mon, 18 Jul 2016 17:01:44 -0700 Subject: [PATCH] Makes old savefiles properly work in new system. --- code/modules/client/preferences_savefile.dm | 83 +++++---------------- 1 file changed, 17 insertions(+), 66 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 9bc900a61cf..5042ae817ba 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -1,8 +1,8 @@ //This is the lowest supported version, anything below this is completely obsolete and the entire savefile will be wiped. -#define SAVEFILE_VERSION_MIN 8 +#define SAVEFILE_VERSION_MIN 10 //This is the current version, anything below this will attempt to update (if it's not obsolete) -#define SAVEFILE_VERSION_MAX 15 +#define SAVEFILE_VERSION_MAX 16 /* SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn This proc checks if the current directory of the savefile S needs updating @@ -31,7 +31,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car return -1 -/datum/preferences/proc/update_antagchoices(current_version) +/datum/preferences/proc/update_antagchoices(current_version, savefile/S) if((!islist(be_special) || old_be_special ) && current_version < 12) //Archived values of when antag pref defines were a bitfield+fitflags var/B_traitor = 1 @@ -87,7 +87,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car be_special += ROLE_ABDUCTOR -/datum/preferences/proc/update_preferences(current_version) +/datum/preferences/proc/update_preferences(current_version, savefile/S) if(current_version < 10) toggles |= MEMBER_PUBLIC if(current_version < 11) @@ -97,6 +97,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car ignoring = list() if(current_version < 15) toggles |= SOUND_ANNOUNCEMENTS + //should this proc get fairly long (say 3 versions long), //just increase SAVEFILE_VERSION_MIN so it's not as far behind @@ -104,65 +105,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //from this proc. //It's only really meant to avoid annoying frequent players //if your savefile is 3 months out of date, then 'tough shit'. -/datum/preferences/proc/update_character(current_version) - if(current_version < 9) //an example, underwear were an index for a hardcoded list, converting to a string - if(gender == MALE) - switch(underwear) - if(1) - underwear = "Mens White" - if(2) - underwear = "Mens Grey" - if(3) - underwear = "Mens Green" - if(4) - underwear = "Mens Blue" - if(5) - underwear = "Mens Black" - if(6) - underwear = "Mankini" - if(7) - underwear = "Mens Hearts Boxer" - if(8) - underwear = "Mens Black Boxer" - if(9) - underwear = "Mens Grey Boxer" - if(10) - underwear = "Mens Striped Boxer" - if(11) - underwear = "Mens Kinky" - if(12) - underwear = "Mens Red" - if(13) - underwear = "Nude" - else - switch(underwear) - if(1) - underwear = "Ladies Red" - if(2) - underwear = "Ladies White" - if(3) - underwear = "Ladies Yellow" - if(4) - underwear = "Ladies Blue" - if(5) - underwear = "Ladies Black" - if(6) - underwear = "Ladies Thong" - if(7) - underwear = "Babydoll" - if(8) - underwear = "Ladies Baby-Blue" - if(9) - underwear = "Ladies Green" - if(10) - underwear = "Ladies Pink" - if(11) - underwear = "Ladies Kinky" - if(12) - underwear = "Tankini" - if(13) - underwear = "Nude" - +/datum/preferences/proc/update_character(current_version, savefile/S) if(pref_species && !(pref_species.id in roundstart_species)) var/rando_race = pick(config.roundstart_races) pref_species = new rando_race() @@ -173,6 +116,14 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car backbag = DSATCHEL else backbag = DBACKPACK + if(current_version < 16) + var/berandom + S["userandomjob"] >> berandom + if (berandom) + joblessrole = BERANDOMJOB + else + joblessrole = BEASSISTANT + /datum/preferences/proc/load_path(ckey,filename="preferences.sav") @@ -223,8 +174,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //try to fix any outdated data if necessary if(needs_update >= 0) - update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer) - update_antagchoices(needs_update) + update_preferences(needs_update, S) //needs_update = savefile_version if we need an update (positive integer) + update_antagchoices(needs_update, S) //Sanitize ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor))) @@ -359,7 +310,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //try to fix any outdated data if necessary if(needs_update >= 0) - update_character(needs_update) //needs_update == savefile_version if we need an update (positive integer) + update_character(needs_update, S) //needs_update == savefile_version if we need an update (positive integer) //Sanitize metadata = sanitize_text(metadata, initial(metadata))