Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/__DEFINES/~darkpack/savefile.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#define SAVEFILE_DARKPACK_VERSION_MIN 0 // 0 would mean this was a sheet before versioning in theory
#define SAVEFILE_DARKPACK_VERSION_MAX 1

#define SHOULD_UPDATE_DATA_DARKPACK(version) (version >= SAVE_DATA_NO_ERROR && version < SAVEFILE_DARKPACK_VERSION_MAX)
44 changes: 40 additions & 4 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
return save_version
return SAVE_DATA_EMPTY

// DARKPACK EDIT ADD START
/datum/preferences/proc/check_savedata_version_darkpack(list/save_data)
if(!save_data)
return SAVE_DATA_EMPTY
var/save_version = save_data["version_darkpack"]
if(isnull(save_version)) // Sanity for sheets before this was added.
save_version = 0

if(save_version < SAVEFILE_DARKPACK_VERSION_MIN)
return SAVE_DATA_OBSOLETE
if(save_version < SAVEFILE_DARKPACK_VERSION_MAX)
return save_version
return SAVE_DATA_EMPTY
// DARKPACK EDIT ADD END

//should these procs get fairly long
//just increase SAVEFILE_VERSION_MIN so it's not as far behind
//SAVEFILE_VERSION_MAX and then delete any obsolete if clauses
Expand Down Expand Up @@ -165,6 +180,17 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if(current_version < 51)
migrate_felinid_feature_keys(save_data)

// DARKPACK EDIT ADD START
/datum/preferences/proc/update_preferences_darkpack(current_version, datum/json_savefile/S)

/datum/preferences/proc/update_character_darkpack(current_version, list/save_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wazzup with these empty procs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its future proofing for when we need to update prefs. e.g #745

/*
if (current_version < 2)
if(read_preference(/datum/preference/choiced/subsplat/garou_breed) == "Metis")
write_preference(GLOB.preference_entries[/datum/preference/choiced/subsplat/garou_breed], BREED_CRINOS)
*/
// DARKPACK EDIT ADD END

/// checks through keybindings for outdated unbound keys and updates them
/datum/preferences/proc/check_keybindings()
if(!parent)
Expand Down Expand Up @@ -226,7 +252,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
return FALSE

var/data_validity_integer = check_savedata_version(savefile.get_entry())
if(load_and_save && IS_DATA_OBSOLETE(data_validity_integer)) //fatal, can't load any data
var/data_validity_integer_darkpack = check_savedata_version_darkpack(savefile.get_entry()) // DARKPACK EDIT ADD
if(load_and_save && (IS_DATA_OBSOLETE(data_validity_integer) || IS_DATA_OBSOLETE(data_validity_integer_darkpack))) //fatal, can't load any data // DARKPACK EDIT CHANGE
var/bacpath = PREFS_BACKUP_PATH(path) //todo: if the savefile version is higher then the server, check the backup, and give the player a prompt to load the backup
if (fexists(bacpath))
fdel(bacpath) //only keep 1 version of backup
Expand Down Expand Up @@ -261,12 +288,13 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
key_bindings = savefile.get_entry("key_bindings", key_bindings)

//try to fix any outdated data if necessary
if(SHOULD_UPDATE_DATA(data_validity_integer))
if(SHOULD_UPDATE_DATA(data_validity_integer) || SHOULD_UPDATE_DATA_DARKPACK(data_validity_integer_darkpack)) // DARKPACK EDIT CHANGE
var/bacpath = PREFS_BACKUP_PATH(path) //todo: if the savefile version is higher then the server, check the backup, and give the player a prompt to load the backup
if (fexists(bacpath))
fdel(bacpath) //only keep 1 version of backup
fcopy(savefile.path, bacpath) //byond helpfully lets you use a savefile for the first arg.
update_preferences(data_validity_integer, savefile)
update_preferences_darkpack(data_validity_integer_darkpack, savefile) // DARKPACK EDIT ADD

check_keybindings() // this apparently fails every time and overwrites any unloaded prefs with the default values, so don't load anything after this line or it won't actually save

Expand All @@ -280,7 +308,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

key_bindings_by_key = get_key_bindings_by_key(key_bindings)

if(SHOULD_UPDATE_DATA(data_validity_integer)) //save the updated version
if(SHOULD_UPDATE_DATA(data_validity_integer) || SHOULD_UPDATE_DATA_DARKPACK(data_validity_integer_darkpack)) //save the updated version // DARKPACK EDIT CHANGE
var/old_default_slot = default_slot
var/old_max_save_slots = max_save_slots

Expand Down Expand Up @@ -308,6 +336,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
return TRUE

savefile.set_entry("version", SAVEFILE_VERSION_MAX) //updates (or failing that the sanity checks) will ensure data is not invalid at load. Assume up-to-date
savefile.set_entry("version_darkpack", SAVEFILE_DARKPACK_VERSION_MAX) // DARKPACK EDIT ADD

for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference = GLOB.preference_entries[preference_type]
Expand Down Expand Up @@ -346,7 +375,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
var/tree_key = "character[slot]"
var/list/save_data = savefile.get_entry(tree_key)
var/data_validity_integer = check_savedata_version(save_data)
if(IS_DATA_OBSOLETE(data_validity_integer)) //fatal, can't load any data
var/data_validity_integer_darkpack = check_savedata_version_darkpack(save_data) // DARKPACK EDIT ADD
if(IS_DATA_OBSOLETE(data_validity_integer) || IS_DATA_OBSOLETE(data_validity_integer_darkpack)) //fatal, can't load any data // DARKPACK EDIT CHANGE
return FALSE

// Read everything into cache
Expand Down Expand Up @@ -376,6 +406,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if(SHOULD_UPDATE_DATA(data_validity_integer))
update_character(data_validity_integer, save_data)

// DARKPACK EDIT ADD START
if(SHOULD_UPDATE_DATA_DARKPACK(data_validity_integer_darkpack))
update_character_darkpack(data_validity_integer_darkpack, save_data)
// DARKPACK EDIT ADD END

// DARKPACK EDIT ADD START - STORYTELLER_STATS
if(!stats_list)
preference_storyteller_stats = create_new_stat_prefs(preference_storyteller_stats)
Expand Down Expand Up @@ -428,6 +463,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
write_preference(preference, preference.serialize(value_cache[preference.type]))

save_data["version"] = SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date.
save_data["version_darkpack"] = SAVEFILE_DARKPACK_VERSION_MAX // DARKPACK EDIT ADD

// This is the version when the random security department was removed.
// When the minimum is higher than that version, it's impossible for someone to have the "Random" department.
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DM Environment file for tgstation.dme.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\dwelling\code\area_dwelling.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\dwelling\code\_dwelling_gvars_defines.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\quirks\code\quirks.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\drugs\code\bloodpacks\bloodpack_adulteration.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\werewolf_the_apocalypse\code\old\gifts.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\werewolf_the_apocalypse\code\gifts\tribes\tribes.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\weather\code\weather.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\computers\code\computer.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\computers\code\app.dm.

Check failure on line 1 in tgstation.dme

View workflow job for this annotation

GitHub Actions / Run Linters / linters

Ticked File Enforcement

Missing include for modular_darkpack\modules\computers\code\app_types.dm.
// All manual changes should be made outside the BEGIN_ and END_ blocks.
// New source code should be placed in .dm files: choose File/New --> Code File.

Expand Down Expand Up @@ -454,6 +454,7 @@
#include "code\__DEFINES\~darkpack\names.dm"
#include "code\__DEFINES\~darkpack\phones.dm"
#include "code\__DEFINES\~darkpack\radio_networks.dm"
#include "code\__DEFINES\~darkpack\savefile.dm"
#include "code\__DEFINES\~darkpack\sight.dm"
#include "code\__DEFINES\~darkpack\signals_kindred.dm"
#include "code\__DEFINES\~darkpack\sound.dm"
Expand Down
Loading