TRUE/FALSE is not interchangable with 1/0 I guess. idfk

byond's save logic is fucking stupid
This commit is contained in:
Poojawa
2018-09-29 20:25:46 -05:00
parent eaca6b182a
commit c6c3b16ca0
4 changed files with 66 additions and 132 deletions
@@ -17,13 +17,12 @@
var/list/living_mobs = list()
// Release belly contents beforey being gc'd!
// Release belly contents before being gc'd!
/mob/living/simple_animal/Destroy()
release_vore_contents(silent = TRUE)
release_vore_contents(include_absorbed = TRUE, silent = TRUE)
prey_excludes.Cut()
. = ..()
// Update fullness based on size & quantity of belly contents
/mob/living/simple_animal/proc/update_fullness(var/atom/movable/M)
var/new_fullness = 0
@@ -393,13 +393,7 @@
// If digested prey is also a pred... anyone inside their bellies gets moved up.
if(is_vore_predator(M))
for(var/belly in M.vore_organs)
var/obj/belly/B = belly
for(var/thing in B)
var/atom/movable/AM = thing
AM.forceMove(owner.loc)
if(isliving(AM))
to_chat(AM,"As [M] melts away around you, you find yourself in [owner]'s [lowertext(name)]")
M.release_vore_contents(include_absorbed = TRUE, silent = TRUE)
//Drop all items into the belly
for(var/obj/item/W in M)
@@ -280,14 +280,6 @@
return 0
*/
//
// Release everything in every vore organ
//
/mob/living/proc/release_vore_contents(var/include_absorbed = TRUE)
for(var/belly in vore_organs)
var/obj/belly/B = belly
B.release_all_contents(include_absorbed)
//
// Custom resist catches for /mob/living
//
@@ -354,47 +346,29 @@
// Verb for saving vore preferences to save file
//
/mob/living/proc/save_vore_prefs()
to_chat(world, "Save_vore_prefs triggered")
if(!client)
to_chat(world, "No client detected, failed.")
return FALSE
if(client && !client.prefs_vr)
to_chat(world, "[client] client detected, but no prefs_vr confirmed")
return FALSE
if(!client || !client.prefs_vr)
return 0
if(!copy_to_prefs_vr())
to_chat(world, "copy_to_prefs_vr failed")
return FALSE
if(client && !client.prefs_vr.save_vore())
to_chat(world, "client detected, but client.prefs_vr.save_vore() failed.")
return FALSE
to_chat(world, "saving passed checks and returning TRUE")
return TRUE
return 0
if(!client.prefs_vr.save_vore())
return 0
return 1
/mob/living/proc/apply_vore_prefs()
to_chat(world, "apply_vore_prefs triggered")
if(!client)
to_chat(world, "No client detected, failed.")
return FALSE
if(client && !client.prefs_vr)
to_chat(world, "Client detected, but no prefs_vr confirmed")
return FALSE
if(client && !client.prefs_vr.load_vore())
to_chat(world, "client detected, but client.prefs_vr.load_vore() failed.")
return FALSE
if(!client || !client.prefs_vr)
return 0
if(!client.prefs_vr.load_vore())
return 0
if(!copy_from_prefs_vr())
to_chat(world, "copy_to_prefs_vr failed")
return FALSE
to_chat(world, "apply passed checks and returning TRUE")
return TRUE
return 0
return 1
/mob/living/proc/copy_to_prefs_vr()
to_chat(world, "copy_to_prefs_vr triggered")
if(!client)
to_chat(world, "No client detected, failed.")
return FALSE
if(client && !client.prefs_vr)
src << "<span class='warning'>You attempted to save your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>"
return FALSE
if(!client || !client.prefs_vr)
to_chat(src,"<span class='warning'>You attempted to save your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>")
return 0
var/datum/vore_preferences/P = client.prefs_vr
@@ -409,19 +383,15 @@
P.belly_prefs = serialized
return TRUE
return 1
//
// Proc for applying vore preferences, given bellies
//
/mob/living/proc/copy_from_prefs_vr()
to_chat(world, "copy_from_prefs_vr triggered")
if(!client)
to_chat(world, "No client detected, failed.")
return FALSE
if(client && !client.prefs_vr)
src << "<span class='warning'>You attempted to apply your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>"
return FALSE
if(!client || !client.prefs_vr)
to_chat(src,"<span class='warning'>You attempted to apply your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev.</span>")
return 0
var/datum/vore_preferences/P = client.prefs_vr
@@ -429,11 +399,20 @@
devourable = P.devourable
vore_taste = P.vore_taste
release_vore_contents(silent = TRUE)
vore_organs.Cut()
for(var/entry in P.belly_prefs)
list_to_object(entry,src)
return TRUE
return 1
//
// Release everything in every vore organ
//
/mob/living/proc/release_vore_contents(var/include_absorbed = TRUE, var/silent = FALSE)
for(var/belly in vore_organs)
var/obj/belly/B = belly
B.release_all_contents(include_absorbed, silent)
//
// Returns examine messages for bellies
@@ -79,41 +79,30 @@ GLOBAL_LIST_EMPTY(vore_preferences_datums)
// Save/Load Vore Preferences
//
/datum/vore_preferences/proc/load_path(ckey,slot,filename="character",ext="json")
if(!ckey || !slot)
return
to_chat(world, "load_path fired for [ckey], [slot]")
if(!ckey || !slot) return
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/vore/[filename][slot].[ext]"
/datum/vore_preferences/proc/load_vore()
if(!client || !client_ckey)
return FALSE //No client, how can we save?
to_chat(world, "[client], [client_ckey] detected for load_vore.")
return 0 //No client, how can we save?
if(!client.prefs || !client.prefs.default_slot)
to_chat(world, "[client] prefs weren't found.")
return FALSE //Need to know what character to load!
return 0 //Need to know what character to load!
slot = client.prefs.default_slot
to_chat(world, "[slot] is current slot")
load_path(client_ckey,slot)
if(!path)
return FALSE //Path couldn't be set?
to_chat(world, "[path] is path")
if(!path) return 0 //Path couldn't be set?
if(!fexists(path)) //Never saved before
to_chat(world, "[path] invalid or doesn't exist, attempting a save.")
save_vore() //Make the file first
return TRUE
return 1
var/list/json_from_file = json_decode(file2text(path))
if(!json_from_file)
to_chat(world, "[client] failed json_from_file check")
return FALSE //My concern grows
return 0 //My concern grows
var/version = json_from_file["version"]
json_from_file = patch_version(json_from_file,version)
to_chat(world, "[version] detected for load_vore.")
digestable = json_from_file["digestable"]
devourable = json_from_file["devourable"]
@@ -128,62 +117,41 @@ GLOBAL_LIST_EMPTY(vore_preferences_datums)
if(isnull(belly_prefs))
belly_prefs = list()
return TRUE
/*
allowmobvore = json_from_file["allowmobvore"]
can_be_drop_prey = json_from_file["can_be_drop_prey"]
can_be_drop_prey = json_from_file["can_be_drop_pred"]
if(isnull(allowmobvore))
allowmobvore = TRUE
if(isnull(can_be_drop_prey))
allowmobvore = FALSE
if(isnull(can_be_drop_pred))
allowmobvore = FALSE */
return 1
/datum/vore_preferences/proc/save_vore()
to_chat(world, "save_vore triggered")
var/json_file = path
if(!path)
return FALSE
to_chat(world, "[json_file] is path")
return 0
var/version = VORE_VERSION //For "good times" use in the future
to_chat(world, "[version] is version")
var/list/settings_list = list()
settings_list["version"] = version
settings_list["digestable"] = digestable
settings_list["devourable"] = devourable
settings_list["vore_taste"] = vore_taste
settings_list["belly_prefs"] = belly_prefs
var/list/settings_list = list(
"version" = version,
"digestable" = digestable,
"devourable" = devourable,
"vore_taste" = vore_taste,
"belly_prefs" = belly_prefs,
)
//List to JSON
var/json_to_file = json_encode(settings_list)
if(!json_to_file)
to_chat(world, "Saving: json_to_file failed json_encode")
return FALSE
testing("Saving: [path] failed jsonencode")
return 0
//Write it out
//#ifdef RUST_G
// fdel(json_file)
// WRITE_VORE(json_file, json_to_file)
//#else
#ifdef RUST_G
call(RUST_G, "file_write")(json_to_file, path)
#else
// Fall back to using old format if we are not using rust-g
to_chat(world, "Saving: RUST_G failed or was bypassed.")
var/list/json
if(fexists(json_file))
json = json_decode(file2text(json_file))
to_chat(world, "Saving: [json_file] being deleted and remade")
fdel(json_file) //Byond only supports APPENDING to files, not replacing.
else
json = list(json_to_file)
json = serialize_json()
WRITE_FILE(json_file, json_encode(json))
//#endif
if(!fexists(json_file))
to_chat(world, "Saving: [json_file] failed file write")
return FALSE
to_chat(world, "Saving: returning complete and TRUE")
return TRUE
if(fexists(path))
fdel(path) //Byond only supports APPENDING to files, not replacing.
text2file(json_to_file, path)
#endif
if(!fexists(path))
testing("Saving: [path] failed file write")
return 0
return 1
/* commented out list things
"allowmobvore" = allowmobvore,
@@ -191,13 +159,7 @@ GLOBAL_LIST_EMPTY(vore_preferences_datums)
"can_be_drop_pred" = can_be_drop_pred, */
//Can do conversions here
//datum/vore_preferences/proc/patch_version(var/list/json_from_file,var/version)
// return json_from_file
/datum/vore_preferences/proc/patch_version(var/list/json_from_file,var/version)
var/savefile_version
json_from_file["version"] = savefile_version
if(savefile_version < VORE_VERSION)
return savefile_version
datum/vore_preferences/proc/patch_version(var/list/json_from_file,var/version)
return json_from_file
#undef VORE_VERSION