json encoding, how the merry fuck does it work
This commit is contained in:
@@ -211,11 +211,21 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
|
||||
new /datum/admins(localhost_rank, ckey, 1, 1)
|
||||
//preferences datum - also holds some persistent data for the client (because we may as well keep these datums to a minimum)
|
||||
prefs = GLOB.preferences_datums[ckey]
|
||||
prefs_vr = GLOB.vore_preferences_datums[ckey] //CITADEL EDIT bypassing a failing hook
|
||||
|
||||
if(prefs)
|
||||
prefs.parent = src
|
||||
else
|
||||
prefs = new /datum/preferences(src)
|
||||
GLOB.preferences_datums[ckey] = prefs
|
||||
|
||||
if(prefs_vr) //CITADEL EDIT bypassing a failing hook START
|
||||
prefs_vr.client = src
|
||||
else
|
||||
prefs_vr = new/datum/vore_preferences(src)
|
||||
GLOB.vore_preferences_datums[ckey] = prefs_vr
|
||||
//CITADEL EDIT bypassing a failing hook END
|
||||
|
||||
prefs.last_ip = address //these are gonna be used for banning
|
||||
prefs.last_id = computer_id //these are gonna be used for banning
|
||||
fps = prefs.clientfps
|
||||
@@ -409,8 +419,6 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
|
||||
if (menuitem)
|
||||
menuitem.Load_checked(src)
|
||||
|
||||
hook_vr("client_new",list(src)) // CIT CHANGE - hook for client/New() changes
|
||||
|
||||
Master.UpdateTickRate()
|
||||
|
||||
//////////////
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
default_color = "4B4B4B"
|
||||
species_traits = list(MUTCOLORS,EYECOLOR,LIPS,HAIR)
|
||||
inherent_biotypes = list(MOB_ORGANIC, MOB_HUMANOID)
|
||||
mutant_bodyparts = list("mam_tail", "mam_ears", "mam_body_markings", "snout", "taur")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "snout" = "Husky", "mam_tail" = "Husky", "mam_ears" = "Husky", "mam_body_markings" = "Husky", "taur" = "None")
|
||||
mutant_bodyparts = list("mam_tail", "mam_ears", "mam_body_markings", "snout", "taur", "legs")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "snout" = "Husky", "mam_tail" = "Husky", "mam_ears" = "Husky", "mam_body_markings" = "Husky", "taur" = "None", "legs" = "Normal Legs")
|
||||
attack_verb = "claw"
|
||||
attack_sound = 'sound/weapons/slash.ogg'
|
||||
miss_sound = 'sound/weapons/slashmiss.ogg'
|
||||
@@ -114,8 +114,8 @@
|
||||
default_color = "BCAC9B"
|
||||
species_traits = list(MUTCOLORS,EYECOLOR,LIPS,HAIR)
|
||||
inherent_biotypes = list(MOB_ORGANIC, MOB_HUMANOID)
|
||||
mutant_bodyparts = list("mam_tail", "mam_body_markings", "mam_ears", "taur")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "mam_tail" = "Shark", "mam_body_markings" = "Shark", "mam_ears" = "None", "snout" = "Round")
|
||||
mutant_bodyparts = list("mam_tail", "mam_body_markings", "mam_ears", "taur", "legs")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "mam_tail" = "Shark", "mam_body_markings" = "Shark", "mam_ears" = "None", "snout" = "Round", "taur" = "None", "legs" = "Normal Legs")
|
||||
attack_verb = "bite"
|
||||
attack_sound = 'sound/weapons/bite.ogg'
|
||||
miss_sound = 'sound/weapons/slashmiss.ogg'
|
||||
@@ -169,7 +169,7 @@
|
||||
species_traits = list(MUTCOLORS,EYECOLOR,LIPS,HAIR)
|
||||
inherent_biotypes = list(MOB_ORGANIC, MOB_HUMANOID, MOB_BUG)
|
||||
mutant_bodyparts = list("mam_body_markings", "mam_ears", "mam_tail", "taur", "moth_wings")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "mam_body_markings" = "Moth", "mam_tail" = "None", "mam_ears" = "None", "moth_wings" = "Plain", "snout" = "None")
|
||||
default_features = list("mcolor" = "FFF","mcolor2" = "FFF","mcolor3" = "FFF", "mam_body_markings" = "Moth", "mam_tail" = "None", "mam_ears" = "None", "moth_wings" = "Plain", "snout" = "None", "taur" = "None")
|
||||
attack_verb = "flutter" //wat?
|
||||
attack_sound = 'sound/weapons/slash.ogg'
|
||||
miss_sound = 'sound/weapons/slashmiss.ogg'
|
||||
|
||||
@@ -125,8 +125,12 @@
|
||||
"can_taste",
|
||||
"bulge_size",
|
||||
"silent",
|
||||
"transferchance",
|
||||
"transferlocation",
|
||||
"transferchance",
|
||||
"autotransferchance",
|
||||
"autotransferwait",
|
||||
"swallow_time",
|
||||
"vore_capacity",
|
||||
"struggle_messages_outside",
|
||||
"struggle_messages_inside",
|
||||
"digest_messages_owner",
|
||||
@@ -228,7 +232,7 @@
|
||||
SEND_SIGNAL(ML, COMSIG_CLEAR_MOOD_EVENT, "fedprey", /datum/mood_event/fedprey)
|
||||
SEND_SIGNAL(OW, COMSIG_ADD_MOOD_EVENT, "emptypred", /datum/mood_event/emptypred)
|
||||
SEND_SIGNAL(ML, COMSIG_ADD_MOOD_EVENT, "emptyprey", /datum/mood_event/emptyprey)
|
||||
|
||||
|
||||
if(ML.absorbed)
|
||||
ML.absorbed = FALSE
|
||||
if(ishuman(M) && ishuman(OW))
|
||||
@@ -252,14 +256,14 @@
|
||||
return
|
||||
if (prey.buckled)
|
||||
prey.buckled.unbuckle_mob(prey,TRUE)
|
||||
|
||||
|
||||
if(!isbelly(prey.loc))
|
||||
SEND_SIGNAL(owner, COMSIG_ADD_MOOD_EVENT, "fedpred", /datum/mood_event/fedpred)
|
||||
SEND_SIGNAL(prey, COMSIG_ADD_MOOD_EVENT, "fedprey", /datum/mood_event/fedprey)
|
||||
else
|
||||
SEND_SIGNAL(owner, COMSIG_CLEAR_MOOD_EVENT, "emptypred", /datum/mood_event/emptypred)
|
||||
SEND_SIGNAL(prey, COMSIG_CLEAR_MOOD_EVENT, "emptyprey", /datum/mood_event/emptyprey)
|
||||
|
||||
|
||||
prey.forceMove(src)
|
||||
var/sound/preyloop = sound('sound/vore/prey/loop.ogg', repeat = TRUE)
|
||||
if(!silent)
|
||||
|
||||
@@ -354,31 +354,43 @@
|
||||
// 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(!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
|
||||
|
||||
/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(!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
|
||||
|
||||
/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>"
|
||||
@@ -403,7 +415,9 @@
|
||||
// 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>"
|
||||
|
||||
@@ -27,16 +27,15 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
|
||||
//
|
||||
// The datum type bolted onto normal preferences datums for storing Vore stuff
|
||||
//
|
||||
|
||||
#define VORE_VERSION 2
|
||||
#define rustg_vore_write(fname, text) call(RUST_G, "file_write")(fname, text)
|
||||
#define WRITE_VORE(fname, text) rustg_vore_write(fname, text)
|
||||
GLOBAL_LIST_EMPTY(vore_preferences_datums)
|
||||
|
||||
/client
|
||||
var/datum/vore_preferences/prefs_vr
|
||||
|
||||
/hook/client_new/proc/add_prefs_vr(client/C)
|
||||
C.prefs_vr = new/datum/vore_preferences(C)
|
||||
if(C.prefs_vr)
|
||||
return TRUE
|
||||
|
||||
return FALSE
|
||||
|
||||
/datum/vore_preferences
|
||||
//Actual preferences
|
||||
var/digestable = FALSE
|
||||
@@ -80,31 +79,41 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
|
||||
// Save/Load Vore Preferences
|
||||
//
|
||||
/datum/vore_preferences/proc/load_path(ckey,slot,filename="character",ext="json")
|
||||
if(!ckey || !slot) return
|
||||
if(!ckey || !slot)
|
||||
return
|
||||
to_chat(world, "load_path fired for [ckey], [slot]")
|
||||
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.")
|
||||
if(!client.prefs || !client.prefs.default_slot)
|
||||
to_chat(world, "[client] prefs weren't found.")
|
||||
return FALSE //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?
|
||||
if(!path)
|
||||
return FALSE //Path couldn't be set?
|
||||
to_chat(world, "[path] is path")
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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"]
|
||||
@@ -133,36 +142,47 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
|
||||
allowmobvore = FALSE */
|
||||
|
||||
/datum/vore_preferences/proc/save_vore()
|
||||
if(!path) return FALSE
|
||||
|
||||
var/version = 1 //For "good times" use in the future
|
||||
var/list/settings_list = list(
|
||||
"version" = version,
|
||||
"digestable" = digestable,
|
||||
"devourable" = devourable,
|
||||
"vore_taste" = vore_taste,
|
||||
"belly_prefs" = belly_prefs,
|
||||
)
|
||||
to_chat(world, "save_vore triggered")
|
||||
var/json_file = path
|
||||
if(!path)
|
||||
return FALSE
|
||||
to_chat(world, "[json_file] is path")
|
||||
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
|
||||
|
||||
//List to JSON
|
||||
var/json_to_file = json_encode(settings_list)
|
||||
if(!json_to_file)
|
||||
testing("Saving: [path] failed jsonencode")
|
||||
to_chat(world, "Saving: json_to_file failed json_encode")
|
||||
return FALSE
|
||||
|
||||
//Write it out
|
||||
#ifdef RUST_G
|
||||
call(RUST_G, "file_write")(json_to_file, path)
|
||||
#else
|
||||
//#ifdef RUST_G
|
||||
// fdel(json_file)
|
||||
// WRITE_VORE(json_file, json_to_file)
|
||||
//#else
|
||||
// Fall back to using old format if we are not using rust-g
|
||||
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")
|
||||
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
|
||||
|
||||
/* commented out list things
|
||||
@@ -171,5 +191,13 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE
|
||||
"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)
|
||||
return json_from_file
|
||||
var/savefile_version
|
||||
json_from_file["version"] = savefile_version
|
||||
if(savefile_version < VORE_VERSION)
|
||||
return savefile_version
|
||||
return json_from_file
|
||||
#undef VORE_VERSION
|
||||
|
||||
Reference in New Issue
Block a user