diff --git a/code/controllers/subsystem/persistence.dm b/code/controllers/subsystem/persistence.dm index 4dae7bcd4b..e717f8c1bf 100644 --- a/code/controllers/subsystem/persistence.dm +++ b/code/controllers/subsystem/persistence.dm @@ -20,6 +20,7 @@ SUBSYSTEM_DEF(persistence) var/list/antag_rep = list() var/list/antag_rep_change = list() var/list/picture_logging_information = list() + var/list/saved_votes = list() var/list/obj/structure/sign/picture_frame/photo_frames var/list/obj/item/storage/photo_album/photo_albums @@ -33,6 +34,7 @@ SUBSYSTEM_DEF(persistence) LoadRecentRulesets() LoadRecentMaps() LoadPhotoPersistence() + LoadSavedVotes() if(CONFIG_GET(flag/use_antag_rep)) LoadAntagReputation() LoadRandomizedRecipes() @@ -207,6 +209,15 @@ SUBSYSTEM_DEF(persistence) return antag_rep = json_decode(json) +/datum/controller/subsystem/persistence/proc/LoadSavedVotes() + var/json_file = file("data/SavedVotes.json") + if(!fexists(json_file)) + return + var/list/json = json_decode(file2text(json_file)) + if(!json) + return + saved_votes = json["data"] + /datum/controller/subsystem/persistence/proc/SetUpTrophies(list/trophy_items) for(var/A in GLOB.trophy_cases) var/obj/structure/displaycase/trophy/T = A @@ -484,3 +495,10 @@ SUBSYSTEM_DEF(persistence) fdel(json_file) WRITE_FILE(json_file, json_encode(file_data)) + +/datum/controller/subsystem/persistence/proc/SaveSavedVotes() + var/json_file = file("data/SavedVotes.json") + var/list/file_data = list() + file_data["data"] = saved_votes + fdel(json_file) + WRITE_FILE(json_file, json_encode(file_data)) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 0828c3b196..4219f4942a 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -18,6 +18,7 @@ SUBSYSTEM_DEF(vote) var/list/choice_descs = list() // optional descriptions var/list/voted = list() var/list/voting = list() + var/list/saved = list() var/list/generated_actions = list() var/next_pop = 0 @@ -29,6 +30,7 @@ SUBSYSTEM_DEF(vote) if(mode) if(end_time < world.time) result() + SSpersistence.SaveSavedVotes() for(var/client/C in voting) C << browse(null, "window=vote;can_close=0") reset() @@ -282,6 +284,7 @@ SUBSYSTEM_DEF(vote) voted += usr.ckey voted[usr.ckey] = list() voted[usr.ckey] += vote + saved -= usr.ckey return 0 /datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key, hideresults, votesystem = PLURALITY_VOTING, forced = FALSE)//CIT CHANGE - adds hideresults argument to votes to allow for obfuscated votes @@ -367,6 +370,9 @@ SUBSYSTEM_DEF(vote) C.player_details.player_actions += V V.Grant(C.mob) generated_actions += V + if((vote_type in SSpersistence.saved_votes) && (C.ckey in SSpersistence.saved_votes[vote_type])) + voted[C.ckey] = SSpersistence.saved_votes[vote_type][C.ckey] + saved += C.ckey if(forced) var/datum/browser/popup = new(C, "vote", "Voting Panel",nwidth=600,nheight=700) popup.set_window_options("can_close=0") @@ -399,8 +405,6 @@ SUBSYSTEM_DEF(vote) if(RANKED_CHOICE_VOTING) var/list/myvote = voted[C.ckey] . += "