From 02b2248f3a4d97a064f75a6b71a65497f8013485 Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 05:56:34 -0700 Subject: [PATCH 1/7] i am not smart at all --- code/modules/vore/eating/living.dm | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/code/modules/vore/eating/living.dm b/code/modules/vore/eating/living.dm index 6949a7030f..8923e9107d 100644 --- a/code/modules/vore/eating/living.dm +++ b/code/modules/vore/eating/living.dm @@ -273,16 +273,7 @@ to_chat(src,"You attempted to apply your vore prefs but somehow you're in this character without a client.prefs variable. Tell a dev.") return FALSE ENABLE_BITFIELD(vore_flags,VOREPREF_INIT) - - // garbage data coming back the other way or breaking absorbed would be bad, so instead we do this - vore_flags |= CHECK_BITFIELD(client.prefs.vore_flags,DIGESTABLE) // set to 1 if prefs is 1 - vore_flags |= CHECK_BITFIELD(client.prefs.vore_flags,DEVOURABLE) - vore_flags |= CHECK_BITFIELD(client.prefs.vore_flags,FEEDING) - - vore_flags &= CHECK_BITFIELD(client.prefs.vore_flags,DIGESTABLE) // set to 0 if prefs is 0 - vore_flags &= CHECK_BITFIELD(client.prefs.vore_flags,DEVOURABLE) - vore_flags &= CHECK_BITFIELD(client.prefs.vore_flags,FEEDING) - + COPY_SPECIFIC_BITFIELDS(vore_flags,client.prefs.vore_flags,DIGESTABLE | DEVOURABLE | FEEDING | LICKABLE) vore_taste = client.prefs.vore_taste release_vore_contents(silent = TRUE) From 3839343cd87ee9058236e2fe8345eddeffe8c388 Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 05:57:46 -0700 Subject: [PATCH 2/7] i forgot to save the #define --- code/__DEFINES/_flags/_flags.dm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/_flags/_flags.dm b/code/__DEFINES/_flags/_flags.dm index ffa3f1c751..cdf2fc27c9 100644 --- a/code/__DEFINES/_flags/_flags.dm +++ b/code/__DEFINES/_flags/_flags.dm @@ -9,7 +9,12 @@ #define DISABLE_BITFIELD(variable, flag) (variable &= ~(flag)) #define CHECK_BITFIELD(variable, flag) (variable & (flag)) #define TOGGLE_BITFIELD(variable, flag) (variable ^= (flag)) - +#define COPY_SPECIFIC_BITFIELDS(a,b,flags)\ + do{ + var/_old = a & ~(flags);\ + var/_cleaned = b & (flags);\ + a = _old | _cleaned + } while(0); #define CHECK_MULTIPLE_BITFIELDS(flagvar, flags) (((flagvar) & (flags)) == (flags)) GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768)) From 8704949694a7d3816b1c350c500867560e2c9f0c Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 05:58:04 -0700 Subject: [PATCH 3/7] whoops forgot a semicolon --- code/__DEFINES/_flags/_flags.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/_flags/_flags.dm b/code/__DEFINES/_flags/_flags.dm index cdf2fc27c9..d18f1bbd78 100644 --- a/code/__DEFINES/_flags/_flags.dm +++ b/code/__DEFINES/_flags/_flags.dm @@ -13,7 +13,7 @@ do{ var/_old = a & ~(flags);\ var/_cleaned = b & (flags);\ - a = _old | _cleaned + a = _old | _cleaned;\ } while(0); #define CHECK_MULTIPLE_BITFIELDS(flagvar, flags) (((flagvar) & (flags)) == (flags)) From 0aec88eaed1e8802963bb84926a6178312636d5f Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 06:12:10 -0700 Subject: [PATCH 4/7] escape those newlines --- code/__DEFINES/_flags/_flags.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/_flags/_flags.dm b/code/__DEFINES/_flags/_flags.dm index d18f1bbd78..a1d8006dbd 100644 --- a/code/__DEFINES/_flags/_flags.dm +++ b/code/__DEFINES/_flags/_flags.dm @@ -10,7 +10,7 @@ #define CHECK_BITFIELD(variable, flag) (variable & (flag)) #define TOGGLE_BITFIELD(variable, flag) (variable ^= (flag)) #define COPY_SPECIFIC_BITFIELDS(a,b,flags)\ - do{ + do{\ var/_old = a & ~(flags);\ var/_cleaned = b & (flags);\ a = _old | _cleaned;\ From f8200a58384ae8db137ae2c78667f598a807045c Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 06:40:09 -0700 Subject: [PATCH 5/7] Shitcode fixing inop code. --- code/modules/client/preferences_savefile.dm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 23d0288163..0249d20ec5 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -609,8 +609,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["vore_flags"] >> vore_flags S["vore_taste"] >> vore_taste - S["belly_prefs"] >> belly_prefs - + var/vr_path = "data/player_saves/[parent.ckey[1]]/[parent.ckey]/vore/character[default_slot]_v2.json" + if(fexists(vr_path)) + var/list/json_from_file = json_decode(file2text(vr_path)) + if(json_from_file) + belly_prefs = json_from_file["belly_prefs"] //gear loadout var/text_to_load S["loadout"] >> text_to_load @@ -877,7 +880,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["vore_flags"] , vore_flags) WRITE_FILE(S["vore_taste"] , vore_taste) - WRITE_FILE(S["belly_prefs"] , belly_prefs) + var/vr_path = "data/player_saves/[parent.ckey[1]]/[parent.ckey]/vore/character[default_slot]_v2.json" + var/belly_prefs = safe_json_encode(list("belly_prefs" = belly_prefs)) + if(fexists(vr_path)) + fdel(path) + text2file(belly_prefs,path) WRITE_FILE(S["persistent_scars"] , persistent_scars) WRITE_FILE(S["scars1"] , scars_list["1"]) From 0c7003b3a5124f829e841f0f81ac6002b5adbc65 Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 20:37:48 -0700 Subject: [PATCH 6/7] never code while tired --- code/modules/client/preferences_savefile.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 0249d20ec5..50a6f5e9dc 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -881,10 +881,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["vore_flags"] , vore_flags) WRITE_FILE(S["vore_taste"] , vore_taste) var/vr_path = "data/player_saves/[parent.ckey[1]]/[parent.ckey]/vore/character[default_slot]_v2.json" - var/belly_prefs = safe_json_encode(list("belly_prefs" = belly_prefs)) + var/belly_prefs_json = safe_json_encode(list("belly_prefs" = belly_prefs)) if(fexists(vr_path)) fdel(path) - text2file(belly_prefs,path) + text2file(belly_prefs_json,path) WRITE_FILE(S["persistent_scars"] , persistent_scars) WRITE_FILE(S["scars1"] , scars_list["1"]) From c644495e5e26e156e74c577b8d530a6c4665ae4c Mon Sep 17 00:00:00 2001 From: Putnam Date: Tue, 29 Sep 2020 21:07:41 -0700 Subject: [PATCH 7/7] dodgin bullets --- code/modules/client/preferences.dm | 1 + code/modules/client/preferences_savefile.dm | 15 ++++++++------- code/modules/unit_tests/character_saving.dm | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index a673012118..1d94c01c24 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -8,6 +8,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/client/parent //doohickeys for savefiles var/path + var/vr_path var/default_slot = 1 //Holder so it doesn't default to slot 1, rather the last one used var/max_save_slots = 16 diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 50a6f5e9dc..85bd7fe104 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -212,6 +212,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car if(!ckey) return path = "data/player_saves/[ckey[1]]/[ckey]/[filename]" + vr_path = "data/player_saves/[ckey[1]]/[ckey]/vore" /datum/preferences/proc/load_preferences() if(!path) @@ -609,9 +610,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["vore_flags"] >> vore_flags S["vore_taste"] >> vore_taste - var/vr_path = "data/player_saves/[parent.ckey[1]]/[parent.ckey]/vore/character[default_slot]_v2.json" - if(fexists(vr_path)) - var/list/json_from_file = json_decode(file2text(vr_path)) + var/char_vr_path = "[vr_path]/character_[default_slot]_v2.json" + if(fexists(char_vr_path)) + var/list/json_from_file = json_decode(file2text(char_vr_path)) if(json_from_file) belly_prefs = json_from_file["belly_prefs"] //gear loadout @@ -880,11 +881,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["vore_flags"] , vore_flags) WRITE_FILE(S["vore_taste"] , vore_taste) - var/vr_path = "data/player_saves/[parent.ckey[1]]/[parent.ckey]/vore/character[default_slot]_v2.json" + var/char_vr_path = "[vr_path]/character_[default_slot]_v2.json" var/belly_prefs_json = safe_json_encode(list("belly_prefs" = belly_prefs)) - if(fexists(vr_path)) - fdel(path) - text2file(belly_prefs_json,path) + if(fexists(char_vr_path)) + fdel(char_vr_path) + text2file(belly_prefs_json,char_vr_path) WRITE_FILE(S["persistent_scars"] , persistent_scars) WRITE_FILE(S["scars1"] , scars_list["1"]) diff --git a/code/modules/unit_tests/character_saving.dm b/code/modules/unit_tests/character_saving.dm index bdcb0f0276..8d978a630d 100644 --- a/code/modules/unit_tests/character_saving.dm +++ b/code/modules/unit_tests/character_saving.dm @@ -10,5 +10,9 @@ Fail("Flavor text is failing to save.") if(P.features["ooc_notes"] != "Bar") Fail("OOC text is failing to save.") + P.save_character() + P.load_character() + if(P.features["flavor_text"] != "Foo") + Fail("Repeated saving and loading possibly causing save deletion.") catch(var/exception/e) Fail("Failed to save and load character due to exception [e.file]:[e.line], [e.name]")