diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index 0137953a65..8b8bc81ad2 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -2,13 +2,15 @@ SUBSYSTEM_DEF(persistence) name = "Persistence" init_order = INIT_ORDER_PERSISTENCE flags = SS_NO_FIRE + var/secret_satchels var/list/satchel_blacklist = list() //this is a typecache var/list/new_secret_satchels = list() //these are objects - var/list/old_secret_satchels = list() + var/list/old_secret_satchels = "" var/list/obj/structure/chisel_message/chisel_messages = list() var/list/saved_messages = list() + var/trophy_sav var/list/saved_trophies = list() /datum/controller/subsystem/persistence/Initialize() @@ -19,45 +21,30 @@ SUBSYSTEM_DEF(persistence) ..() /datum/controller/subsystem/persistence/proc/LoadSatchels() - var/placed_satchel = 0 - var/path - var/obj/item/storage/backpack/satchel/flat/F = new() - if(fexists("data/npc_saves/SecretSatchels.sav")) //legacy compatability to convert old format to new - var/savefile/secret_satchels = new /savefile("data/npc_saves/SecretSatchels.sav") - var/sav_text - secret_satchels[SSmapping.config.map_name] >> sav_text - fdel("data/npc_saves/SecretSatchels.sav") - if(sav_text) - old_secret_satchels = splittext(sav_text,"#") - if(old_secret_satchels.len >= 20) - var/satchel_string = pick_n_take(old_secret_satchels) - var/list/chosen_satchel = splittext(satchel_string,"|") - if(chosen_satchel.len == 3) - F.x = text2num(chosen_satchel[1]) - F.y = text2num(chosen_satchel[2]) - F.z = ZLEVEL_STATION - path = text2path(chosen_satchel[3]) - else - var/json_file = file("data/npc_saves/SecretSatchels[SSmapping.config.map_name].json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - old_secret_satchels = json["data"] - if(old_secret_satchels.len) - if(old_secret_satchels.len >= 20) //guards against low drop pools assuring that one player cannot reliably find his own gear. - var/pos = rand(1, old_secret_satchels.len) - old_secret_satchels.Cut(pos, pos+1) - F.x = old_secret_satchels[pos]["x"] - F.y = old_secret_satchels[pos]["y"] - F.z = ZLEVEL_STATION - path = text2path(old_secret_satchels[pos]["saved_obj"]) - if(!ispath(path)) + secret_satchels = file("data/npc_saves/SecretSatchels[SSmapping.config.map_name].json") + if(!fexists(secret_satchels)) return - if(isfloorturf(F.loc) && !istype(F.loc, /turf/open/floor/plating/)) - F.hide(1) - new path(F) - placed_satchel++ + satchel_blacklist = typecacheof(list(/obj/item/stack/tile/plasteel, /obj/item/crowbar)) + var/list/json = list() + json = json_decode(file2text(secret_satchels)) + old_secret_satchels = json["data"] + var/placed_satchel = 0 + if(old_secret_satchels.len) + if(old_secret_satchels.len >= 20) //guards against low drop pools assuring that one player cannot reliably find his own gear. + var/pos = rand(1, old_secret_satchels.len) + old_secret_satchels.Cut(pos, pos+1) + var/obj/item/storage/backpack/satchel/flat/F = new() + F.x = old_secret_satchels[pos]["x"] + F.y = old_secret_satchels[pos]["y"] + F.z = ZLEVEL_STATION + var/path = text2path(old_secret_satchels[pos]["saved_obj"]) + if(!ispath(path)) + return + if(isfloorturf(F.loc) && !istype(F.loc, /turf/open/floor/plating/)) + F.hide(1) + new path(F) + placed_satchel++ + var/list/free_satchels = list() for(var/turf/T in shuffle(block(locate(TRANSITIONEDGE,TRANSITIONEDGE,ZLEVEL_STATION), locate(world.maxx-TRANSITIONEDGE,world.maxy-TRANSITIONEDGE,ZLEVEL_STATION)))) //Nontrivially expensive but it's roundstart only if(isfloorturf(T) && !istype(T, /turf/open/floor/plating/)) @@ -71,25 +58,16 @@ SUBSYSTEM_DEF(persistence) break //Who's been duping the bird?! /datum/controller/subsystem/persistence/proc/LoadChiselMessages() - var/list/saved_messages = list() - if(fexists("data/npc_saves/ChiselMessages.sav")) //legacy compatability to convert old format to new - var/savefile/chisel_messages_sav = new /savefile("data/npc_saves/ChiselMessages.sav") - var/saved_json - chisel_messages_sav[SSmapping.config.map_name] >> saved_json - if(!saved_json) - return - saved_messages = json_decode(saved_json) - fdel("data/npc_saves/ChiselMessages.sav") - else - var/json_file = file("data/npc_saves/ChiselMessages[SSmapping.config.map_name].json") - if(!fexists(json_file)) - return - var/list/json - json = json_decode(file2text(json_file)) + var/json_file = file("data/npc_saves/ChiselMessages[SSmapping.config.map_name].json") + if(!fexists(json_file)) + return + var/list/json + json = json_decode(file2text(json_file)) - if(!json) - return - saved_messages = json["data"] + if(!json) + return + + var/list/saved_messages = json["data"] for(var/item in saved_messages) if(!islist(item)) @@ -117,23 +95,17 @@ SUBSYSTEM_DEF(persistence) log_world("Loaded [saved_messages.len] engraved messages on map [SSmapping.config.map_name]") /datum/controller/subsystem/persistence/proc/LoadTrophies() - if(fexists("data/npc_saves/TrophyItems.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/TrophyItems.sav") - var/saved_json - S >> saved_json - if(!saved_json) - return - saved_trophies = json_decode(saved_json) - fdel("data/npc_saves/TrophyItems.sav") - else - var/json_file = file("data/npc_saves/TrophyItems.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - if(!json) - return - saved_trophies = json["data"] + trophy_sav = file("data/npc_saves/TrophyItems.json") + if(!fexists(trophy_sav)) + return + var/list/json = list() + json = json_decode(file2text(trophy_sav)) + + if(!json) + return + + saved_trophies = json["data"] + SetUpTrophies(saved_trophies.Copy()) /datum/controller/subsystem/persistence/proc/SetUpTrophies(list/trophy_items) @@ -168,7 +140,6 @@ SUBSYSTEM_DEF(persistence) /datum/controller/subsystem/persistence/proc/CollectSecretSatchels() var/list/satchels = list() - satchel_blacklist = typecacheof(list(/obj/item/stack/tile/plasteel, /obj/item/crowbar)) for(var/A in new_secret_satchels) var/obj/item/storage/backpack/satchel/flat/F = A if(QDELETED(F) || F.z != ZLEVEL_STATION || F.invisibility != INVISIBILITY_MAXIMUM) @@ -188,11 +159,10 @@ SUBSYSTEM_DEF(persistence) data["y"] = F.y data["saved_obj"] = pick(savable_obj) satchels += list(data) - var/json_file = file("data/npc_saves/SecretSatchels[SSmapping.config.map_name].json") var/list/file_data = list() file_data["data"] = satchels - fdel(json_file) - WRITE_FILE(json_file, json_encode(file_data)) + fdel(secret_satchels) + WRITE_FILE(secret_satchels, json_encode(file_data)) /datum/controller/subsystem/persistence/proc/CollectChiselMessages() var/json_file = file("data/npc_saves/ChiselMessages[SSmapping.config.map_name].json") @@ -211,11 +181,10 @@ SUBSYSTEM_DEF(persistence) /datum/controller/subsystem/persistence/proc/CollectTrophies() - var/json_file = file("data/npc_saves/TrophyItems.json") var/list/file_data = list() file_data["data"] = saved_trophies - fdel(json_file) - WRITE_FILE(json_file, json_encode(file_data)) + fdel(trophy_sav) + WRITE_FILE(trophy_sav, json_encode(file_data)) /datum/controller/subsystem/persistence/proc/SaveTrophy(obj/structure/displaycase/trophy/T) if(!T.added_roundstart && T.showpiece) @@ -223,4 +192,4 @@ SUBSYSTEM_DEF(persistence) data["path"] = T.showpiece.type data["message"] = T.trophy_message data["placer_key"] = T.placer_key - saved_trophies += list(data) + saved_trophies += list(data) \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/interactive.dm b/code/modules/mob/living/carbon/human/interactive.dm index b1eaa5349b..7a80758eae 100644 --- a/code/modules/mob/living/carbon/human/interactive.dm +++ b/code/modules/mob/living/carbon/human/interactive.dm @@ -87,17 +87,12 @@ /// SNPC voice handling /mob/living/carbon/human/interactive/proc/loadVoice() - if(fexists("data/npc_saves/snpc.sav")) - var/savefile/S = new /savefile("data/npc_saves/snpc.sav") - S["knownStrings"] >> knownStrings - fdel(S) - else - var/json_file = file("data/npc_saves/snpc.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - knownStrings = json["knownStrings"] + var/json_file = file("data/npc_saves/snpc.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + knownStrings = json["knownStrings"] if(isnull(knownStrings)) knownStrings = list() @@ -295,7 +290,7 @@ //job specific favours switch(myjob.title) if("Assistant") - favoured_types = list(/obj/item/clothing, /obj/item/weapon) + favoured_types = list(/obj/item/clothing, /obj/item) if("Captain","Head of Personnel") favoured_types = list(/obj/item/clothing, /obj/item/stamp/captain, /obj/item/disk/nuclear) if("Cook") @@ -307,14 +302,14 @@ functions += "bartend" restrictedJob = 1 if("Station Engineer","Chief Engineer","Atmospheric Technician") - favoured_types = list(/obj/item/stack, /obj/item/weapon, /obj/item/clothing) + favoured_types = list(/obj/item/stack, /obj/item, /obj/item/clothing) if("Chief Medical Officer","Medical Doctor","Chemist","Virologist","Geneticist") favoured_types = list(/obj/item/reagent_containers/glass/beaker, /obj/item/storage/firstaid, /obj/item/stack/medical, /obj/item/reagent_containers/syringe) functions += "healpeople" if("Research Director","Scientist","Roboticist") favoured_types = list(/obj/item/reagent_containers/glass/beaker, /obj/item/stack, /obj/item/reagent_containers) if("Head of Security","Warden","Security Officer","Detective") - favoured_types = list(/obj/item/clothing, /obj/item/weapon, /obj/item/restraints) + favoured_types = list(/obj/item/clothing, /obj/item, /obj/item/restraints) if("Janitor") favoured_types = list(/obj/item/mop, /obj/item/reagent_containers/glass/bucket, /obj/item/reagent_containers/spray/cleaner, /obj/effect/decal/cleanable) functions += "dojanitor" @@ -324,7 +319,7 @@ if("Mime") functions -= "chatter" if("Botanist") - favoured_types = list(/obj/machinery/hydroponics, /obj/item/reagent_containers, /obj/item/weapon) + favoured_types = list(/obj/machinery/hydroponics, /obj/item/reagent_containers, /obj/item) functions += "botany" restrictedJob = 1 else @@ -644,7 +639,7 @@ insert_into_backpack() // dump random item into backpack to make space //---------ITEMS if(isitem(TARGET)) - if(istype(TARGET, /obj/item/weapon)) + if(istype(TARGET, /obj/item)) var/obj/item/W = TARGET if(W.force >= best_force || prob((FUZZY_CHANCE_LOW+FUZZY_CHANCE_HIGH)/2)) if(!get_item_for_held_index(1) || !get_item_for_held_index(2)) @@ -1484,7 +1479,7 @@ foundFav = 1 return if(!foundFav) - if(istype(test, /obj/item/weapon)) + if(istype(test, /obj/item)) var/obj/item/R = test if(R.force > 2) // make sure we don't equip any non-weaponlike items, ie bags and stuff if(!best) @@ -1509,7 +1504,7 @@ if(istype(A, /obj/item/gun)) // guns are for shooting, not throwing. continue if(prob(robustness)) - if(istype(A, /obj/item/weapon)) + if(istype(A, /obj/item)) var/obj/item/W = A if(W.throwforce > 19) // Only throw worthwile stuff, no more lobbing wrenches at wenches npcDrop(W,1) @@ -1623,4 +1618,4 @@ TRAITS |= TRAIT_ROBUST TRAITS |= TRAIT_SMART faction += "bot_power" - ..() + ..() \ No newline at end of file diff --git a/code/modules/mob/living/carbon/monkey/punpun.dm b/code/modules/mob/living/carbon/monkey/punpun.dm index 2cf821093d..711e771074 100644 --- a/code/modules/mob/living/carbon/monkey/punpun.dm +++ b/code/modules/mob/living/carbon/monkey/punpun.dm @@ -42,23 +42,15 @@ ..() /mob/living/carbon/monkey/punpun/proc/Read_Memory() - if(fexists("data/npc_saves/Punpun.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Punpun.sav") - S["ancestor_name"] >> ancestor_name - S["ancestor_chain"] >> ancestor_chain - S["relic_hat"] >> relic_hat - S["relic_mask"] >> relic_mask - fdel("data/npc_saves/Punpun.sav") - else - var/json_file = file("data/npc_saves/Punpun.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - ancestor_name = json["ancestor_name"] - ancestor_chain = json["ancestor_chain"] - relic_hat = json["relic_hat"] - relic_mask = json["relic_hat"] + var/json_file = file("data/npc_saves/Punpun.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + ancestor_name = json["ancestor_name"] + ancestor_chain = json["ancestor_chain"] + relic_hat = json["relic_hat"] + relic_mask = json["relic_hat"] /mob/living/carbon/monkey/punpun/proc/Write_Memory(dead, gibbed) var/json_file = file("data/npc_saves/Punpun.json") @@ -78,4 +70,4 @@ fdel(json_file) WRITE_FILE(json_file, json_encode(json_file)) if(!dead) - memory_saved = 1 + memory_saved = 1 \ No newline at end of file diff --git a/code/modules/mob/living/simple_animal/friendly/cat.dm b/code/modules/mob/living/simple_animal/friendly/cat.dm index 0e0b811810..ee8a25b679 100644 --- a/code/modules/mob/living/simple_animal/friendly/cat.dm +++ b/code/modules/mob/living/simple_animal/friendly/cat.dm @@ -113,17 +113,12 @@ ..() /mob/living/simple_animal/pet/cat/Runtime/proc/Read_Memory() - if(fexists("data/npc_saves/Runtime.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Runtime.sav") - S["family"] >> family - fdel("data/npc_saves/Runtime.sav") - else - var/json_file = file("data/npc_saves/Runtime.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - family = json["family"] + var/json_file = file("data/npc_saves/Runtime.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + family = json["family"] if(isnull(family)) family = list() @@ -280,4 +275,4 @@ ..() if(L.a_intent == INTENT_HARM && L.reagents && !stat) L.reagents.add_reagent("nutriment", 0.4) - L.reagents.add_reagent("vitamin", 0.4) + L.reagents.add_reagent("vitamin", 0.4) \ No newline at end of file diff --git a/code/modules/mob/living/simple_animal/friendly/dog.dm b/code/modules/mob/living/simple_animal/friendly/dog.dm index 244e77d33a..a6db2dc0b5 100644 --- a/code/modules/mob/living/simple_animal/friendly/dog.dm +++ b/code/modules/mob/living/simple_animal/friendly/dog.dm @@ -328,21 +328,14 @@ ..() /mob/living/simple_animal/pet/dog/corgi/Ian/proc/Read_Memory() - if(fexists("data/npc_saves/Ian.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Ian.sav") - S["age"] >> age - S["record_age"] >> record_age - S["saved_head"] >> saved_head - fdel("data/npc_saves/Ian.sav") - else - var/json_file = file("data/npc_saves/Ian.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - age = json["age"] - record_age = json["record_age"] - saved_head = json["saved_head"] + var/json_file = file("data/npc_saves/Ian.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + age = json["age"] + record_age = json["record_age"] + saved_head = json["saved_head"] if(isnull(age)) age = 0 if(isnull(record_age)) @@ -576,4 +569,4 @@ emote("me", 1, "yaps happily!") else if(M && stat != DEAD) // Same check here, even though emote checks it as well (poor form to check it only in the help case) - emote("me", 1, "growls!") + emote("me", 1, "growls!") \ No newline at end of file diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm index 66fd219358..ab39c35413 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm @@ -289,17 +289,12 @@ Difficulty: Very Hard memory_saved = TRUE /obj/machinery/smartfridge/black_box/proc/ReadMemory() - if(fexists("data/npc_saves/Blackbox.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Blackbox.sav") - S["stored_items"] >> stored_items - fdel("data/npc_saves/Blackbox.sav") - else - var/json_file = file("data/npc_saves/Blackbox.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - stored_items = json["data"] + var/json_file = file("data/npc_saves/Blackbox.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + stored_items = json["data"] if(isnull(stored_items)) stored_items = list() @@ -792,4 +787,4 @@ Difficulty: Very Hard #undef ACTIVATE_WEAPON #undef ACTIVATE_MAGIC -#undef MEDAL_PREFIX +#undef MEDAL_PREFIX \ No newline at end of file diff --git a/code/modules/mob/living/simple_animal/parrot.dm b/code/modules/mob/living/simple_animal/parrot.dm index aa96494745..9e347e3b7a 100644 --- a/code/modules/mob/living/simple_animal/parrot.dm +++ b/code/modules/mob/living/simple_animal/parrot.dm @@ -296,7 +296,7 @@ else parrot_state |= PARROT_FLEE //Otherwise, fly like a bat out of hell! drop_held_item(0) - if(stat != DEAD && M.a_intent == INTENT_HELP) + if(!stat && M.a_intent == INTENT_HELP) handle_automated_speech(1) //assured speak/emote return @@ -924,23 +924,15 @@ ..(gibbed) /mob/living/simple_animal/parrot/Poly/proc/Read_Memory() - if(fexists("data/npc_saves/Poly.sav")) //legacy compatability to convert old format to new - var/savefile/S = new /savefile("data/npc_saves/Poly.sav") - S["phrases"] >> speech_buffer - S["roundssurvived"] >> rounds_survived - S["longestsurvival"] >> longest_survival - S["longestdeathstreak"] >> longest_deathstreak - fdel("data/npc_saves/Poly.sav") - else - var/json_file = file("data/npc_saves/Poly.json") - if(!fexists(json_file)) - return - var/list/json = list() - json = json_decode(file2text(json_file)) - speech_buffer = json["phrases"] - rounds_survived = json["roundssurvived"] - longest_survival = json["longestsurvival"] - longest_deathstreak = json["longestdeathstreak"] + var/json_file = file("data/npc_saves/Poly.json") + if(!fexists(json_file)) + return + var/list/json = list() + json = json_decode(file2text(json_file)) + speech_buffer = json["phrases"] + rounds_survived = json["roundssurvived"] + longest_survival = json["longestsurvival"] + longest_deathstreak = json["longestdeathstreak"] if(!islist(speech_buffer)) speech_buffer = list()