From ba83c969cb40a455a4792e5dd95a5abc5f7d3643 Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Sun, 8 May 2016 22:48:32 -0400 Subject: [PATCH] Saving is done! --- code/modules/vore/eating/belly_vr.dm | 3 + code/modules/vore/eating/bellymodes_vr.dm | 4 - code/modules/vore/eating/living_vr.dm | 160 +++++++++++++++------- code/modules/vore/eating/vore_vr.dm | 34 ++--- code/modules/vore/eating/vorepanel_vr.dm | 14 +- 5 files changed, 132 insertions(+), 83 deletions(-) diff --git a/code/modules/vore/eating/belly_vr.dm b/code/modules/vore/eating/belly_vr.dm index a93dc2023b0..645cca56e64 100644 --- a/code/modules/vore/eating/belly_vr.dm +++ b/code/modules/vore/eating/belly_vr.dm @@ -143,8 +143,11 @@ OR.trans_to(ML,OR.total_volume / absorbed_count) + world << "check_belly [M.loc]" var/datum/belly/B = check_belly(M.loc) + world << "check_belly returned: [B]" if(B) + world << "RSC adding: [M] to [B]" B.internal_contents += M owner.visible_message("[owner] expels [M] from their [lowertext(name)]!") diff --git a/code/modules/vore/eating/bellymodes_vr.dm b/code/modules/vore/eating/bellymodes_vr.dm index aa7fbbc71a1..99f174ea48c 100644 --- a/code/modules/vore/eating/bellymodes_vr.dm +++ b/code/modules/vore/eating/bellymodes_vr.dm @@ -2,10 +2,6 @@ // Called from /mob/living/Life() proc. /datum/belly/proc/process_Life() -///////////////////////////// TIMER ///////////////////////////// - if(!internal_contents.len || air_master.current_cycle%3 != 1) - return - /////////////////////////// Auto-Emotes /////////////////////////// if((digest_mode in emote_lists) && !emotePend) emotePend = 1 diff --git a/code/modules/vore/eating/living_vr.dm b/code/modules/vore/eating/living_vr.dm index 345b92d4925..0ca04896812 100644 --- a/code/modules/vore/eating/living_vr.dm +++ b/code/modules/vore/eating/living_vr.dm @@ -15,17 +15,21 @@ M.verbs += /mob/living/proc/insidePanel M.verbs += /mob/living/proc/escapeOOC - if(M.client && M.client.prefs_vr) - M.vore_organs = M.client.prefs_vr.belly_prefs - M.vore_selected = M.vore_organs[1] - M.digestable = M.client.prefs_vr.digestable - - //Creates at least the typical 'stomach' on every mob. - if(!M.vore_organs.len) + //Tries to load prefs if a client is present otherwise gives freebie stomach + if(!M.vore_organs || !M.vore_organs.len) spawn(20) //Wait a couple of seconds to make sure copy_to or whatever has gone - //In Polaris, when a character joins (not spawns), it creates some sort of 'Force' /mob/living/silicon/ai - //then immediately deletes it. I'm not sure why, but we should make sure M is still real 2 seconds later. - if(M && !M.vore_organs.len) + if(!M) return + + if(M.client && M.client.prefs_vr) + if(!M.copy_from_prefs_vr()) + M << "ERROR: You seem to have saved VOREStation prefs, but they couldn't be loaded." + return 0 + if(M.vore_organs && M.vore_organs.len) + M.vore_selected = M.vore_organs[1] + + if(!M.vore_organs || !M.vore_organs.len) + if(!M.vore_organs) + M.vore_organs = list() var/datum/belly/B = new /datum/belly(M) B.immutable = 1 B.name = "Stomach" @@ -76,33 +80,40 @@ var/mob/living/attacker = user // Typecast to living + world << "[G] with [G.affecting] and [G.assailant] clicked on [src] with intent [user.a_intent] and target [user.zone_sel.selecting]" // src is the mob clicked on - // If grab clicked on grabber - if(src == G.assailant) - if (is_vore_predator(src)) - if (src.feed_grabbed_to_self(src, G.affecting)) - qdel(G) //Delete grab - return 1 //Return 1 to exit upper procs - else - log_debug("[attacker] attempted to feed [G.affecting] to [user] ([user.type]) but it is not predator-capable") + if(src == G.affecting) + world << "1 is true" + if(attacker.a_intent == I_GRAB) + world << "2 is true" + if(attacker.zone_sel.selecting == BP_TORSO) + world << "3 is true" + if(is_vore_predator(G.affecting)) + world << "4 is true" - // If grab clicked on grabbed - if((src == G.affecting) && (user.a_intent == I_GRAB) && (user.zone_sel.selecting == BP_TORSO)) - if (is_vore_predator(G.affecting)) - if (attacker.feed_self_to_grabbed(attacker, G.affecting)) - qdel(G) //Delete grab - return 1 //Return 1 to exit upper procs + ///// If grab clicked on grabber + if((src == G.assailant) && (is_vore_predator(src))) + if (src.feed_grabbed_to_self(src, G.affecting)) + qdel(G) + return 1 else - log_debug("[attacker] attempted to feed [user] to [G.affecting] ([G.affecting.type]) but it is not predator-capable") + log_debug("[attacker] attempted to feed [G.affecting] to [user] ([user.type]) but it failed.") - // If grab clicked on anything else - else - if (is_vore_predator(src)) - if (attacker.feed_grabbed_to_other(attacker, G.affecting, src)) - qdel(G) //Delete grab - return 1 //Return 1 to exit upper procs + ///// If grab clicked on grabbed + else if((src == G.affecting) && (attacker.a_intent == I_GRAB) && (attacker.zone_sel.selecting == BP_TORSO) && (is_vore_predator(G.affecting))) + if (attacker.feed_self_to_grabbed(attacker, G.affecting)) + qdel(G) + return 1 else - log_debug("[attacker] attempted to feed [G.affecting] to [src] ([src.type]) but it is not predator-capable") + log_debug("[attacker] attempted to feed [user] to [G.affecting] ([G.affecting.type]) but it failed.") + + ///// If grab clicked on anyone else + else if((src != G.affecting) && (src != G.assailant) && (is_vore_predator(src))) + if (attacker.feed_grabbed_to_other(attacker, G.affecting, src)) + qdel(G) + return 1 + else + log_debug("[attacker] attempted to feed [G.affecting] to [src] ([src.type]) but it failed.") //Handle case: /obj/item/weapon/holder @@ -116,37 +127,83 @@ // Proc for updating vore organs and digestion/healing/absorbing // /mob/living/proc/handle_internal_contents() - for (var/bellytype in vore_organs) - var/datum/belly/B = vore_organs[bellytype] - for(var/atom/movable/M in B.internal_contents) - if(M.loc != src) - B.internal_contents -= M - log_debug("Had to remove [M] from belly [B] in [src]") - B.process_Life() + if(air_master.current_cycle%3 != 1) + return //The accursed timer + + for (var/I in vore_organs) + var/datum/belly/B = vore_organs[I] + if(B.internal_contents.len) + B.process_Life() //AKA 'do bellymodes_vr.dm' + + if(air_master.current_cycle%3 != 1) return //Occasionally do supercleanups. + for (var/I in vore_organs) + var/datum/belly/B = vore_organs[I] + if(B.internal_contents.len) + for(var/atom/movable/M in B.internal_contents) + if(M.loc != src) + B.internal_contents -= M + log_debug("Had to remove [M] from belly [B] in [src]") // // Verb for saving vore preferences to save file // /mob/living/proc/save_vore_prefs() - set name = "Save Vore Prefs" - set category = "Vore" + if(!(client || client.prefs_vr)) + return 0 + if(!copy_to_prefs_vr()) + return 0 + if(!client.prefs_vr.save_vore()) + return 0 - var/result = 0 + return 1 - if(client.prefs_vr) - result = client.prefs_vr.save_vore_preferences() - else +/mob/living/proc/apply_vore_prefs() + if(!(client || client.prefs_vr)) + return 0 + if(!client.prefs_vr.load_vore()) + return 0 + if(!copy_from_prefs_vr()) + return 0 + + return 1 + +/mob/living/proc/copy_to_prefs_vr() + if(!client || !client.prefs_vr) src << "You attempted to save your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev." - log_debug("[src] tried to save vore prefs but lacks a client.prefs var.") + return 0 - return result + var/datum/vore_preferences/P = client.prefs_vr + + P.digestable = src.digestable + P.belly_prefs = src.vore_organs + P.weight_gain = src.weight_gain + P.weight_loss = src.weight_loss + + return 1 // // Proc for applying vore preferences, given bellies // -/mob/living/proc/apply_vore_prefs(var/list/bellies) - if(!bellies || bellies.len == 0) - log_debug("Tried to apply bellies to [src] and failed.") +/mob/living/proc/copy_from_prefs_vr(var/list/bellies) + if(!client || !client.prefs_vr) + src << "You attempted to apply your vore prefs but somehow you're in this character without a client.prefs_vr variable. Tell a dev." + return 0 + + var/datum/vore_preferences/P = client.prefs_vr + + src.digestable = P.digestable + src.vore_organs = P.belly_prefs + src.weight_gain = P.weight_gain + src.weight_loss = P.weight_loss + + if(!src.vore_organs) //Emergency double-backup to stop runtimes from doing .len on this. + vore_organs = list() + + for(var/I in vore_organs) //Set the owner at runtime since... yanno. + var/datum/belly/B = vore_organs[I] + B.owner = src + + return 1 // // OOC Escape code for pref-breaking or AFK preds @@ -183,8 +240,6 @@ CB.release_specific_contents(src) message_admins("[key_name(src)] used the OOC escape button to get out of [key_name(pred)] (PC) ([pred ? "JMP" : "null"])") -/* POLARISTODO - Depends on dogborgs - //You're in a dogborg! else if(istype(src.loc, /obj/item/device/dogborg/sleeper)) var/mob/living/silicon/pred = src.loc.loc //Thing holding the belly! @@ -195,7 +250,6 @@ message_admins("[key_name(src)] used the OOC escape button to get out of [key_name(pred)] (BORG) ([pred ? "JMP" : "null"])") belly.go_out(src) //Just force-ejects from the borg as if they'd clicked the eject button. -*/ else src << "You aren't inside anyone, you clod." diff --git a/code/modules/vore/eating/vore_vr.dm b/code/modules/vore/eating/vore_vr.dm index d4d6bd7d77d..2b0f2310672 100644 --- a/code/modules/vore/eating/vore_vr.dm +++ b/code/modules/vore/eating/vore_vr.dm @@ -58,17 +58,6 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE client_ckey = C.ckey load_vore(C) -// -// Adding procs to types to support vore -// -/datum/vore_preferences/proc/save_vore_preferences() - save_vore() - return - -/datum/vore_preferences/proc/load_vore_preferences() - load_vore() - return - // // Check if an object is capable of eating things, based on vore_organs // @@ -95,24 +84,27 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE // // Save/Load Vore Preferences // -/datum/vore_preferences/proc/load_vore(filename="preferences_vr.sav") +/datum/vore_preferences/proc/load_vore() if(!client || !client_ckey) return 0 //No client, how can we save? - if(!path) - path = "data/player_saves/[copytext(client_ckey,1,2)]/[client_ckey]/[filename]" - if(!path) return 0 //Path couldn't be set? + + slot = client.prefs.default_slot + + path = client.prefs.path + + if(!path) return 0 //Path couldn't be set? + if(!fexists(path)) //Never saved before + save_vore() //Make the file first + return 1 var/savefile/S = new /savefile(path) if(!S) return 0 //Savefile object couldn't be created? - S.cd = "/" - if(!slot) - slot = client.prefs.default_slot - - slot = sanitize_integer(slot, 1, config.character_slots, initial(client.prefs.default_slot)) S.cd = "/character[slot]" S["digestable"] >> digestable S["belly_prefs"] >> belly_prefs + S["weight_gain"] >> weight_gain + S["weight_loss"] >> weight_loss return 1 @@ -125,5 +117,7 @@ V::::::V V::::::VO:::::::OOO:::::::ORR:::::R R:::::REE::::::EEEEEE S["digestable"] << digestable S["belly_prefs"] << belly_prefs + S["weight_gain"] << weight_gain + S["weight_loss"] << weight_loss return 1 \ No newline at end of file diff --git a/code/modules/vore/eating/vorepanel_vr.dm b/code/modules/vore/eating/vorepanel_vr.dm index d2aaf49b2c0..f25c9cebaf2 100644 --- a/code/modules/vore/eating/vorepanel_vr.dm +++ b/code/modules/vore/eating/vorepanel_vr.dm @@ -470,19 +470,21 @@ usr << "Can't delete bellies with contents!" else if(selected.immutable) usr << "This belly is marked as undeletable." + else if(user.vore_organs.len == 1) + usr << "You must have at least one belly." else var/alert = alert("Are you sure you want to delete [selected]?","Confirmation","Delete","Cancel") if(alert == "Delete" && !selected.internal_contents.len) user.vore_organs -= selected.name user.vore_organs.Remove(selected) - selected = null + selected = user.vore_organs[1] + user.vore_selected = user.vore_organs[1] if(href_list["saveprefs"]) - if(user.save_vore_prefs()) - user << "Saved belly preferences." + if(!user.save_vore_prefs()) + user << "ERROR: Virgo-specific preferences failed to save!" else - user << "ERROR: Could not save vore prefs." - log_debug("Could not save vore prefs on USER: [user].") + user << "Virgo-specific preferences saved!" if(href_list["toggledg"]) var/choice = alert(user, "This button is for those who don't like being digested. It can make you undigestable. Don't abuse this button by toggling it back and forth to extend a scene or whatever, or you'll make the admins cry. Digesting you is currently: [user.digestable ? "Allowed" : "Prevented"]", "", "Allow Digestion", "Cancel", "Prevent Digestion") @@ -496,7 +498,7 @@ message_admins("[key_name(user)] toggled their digestability to [user.digestable] ([user ? "JMP" : "null"])") - if(user.client.prefs) + if(user.client.prefs_vr) user.client.prefs_vr.digestable = user.digestable //Refresh when interacted with, returning 1 makes vore_look.Topic update