From 8d00f11fc105b6b7e20e56ecfd35edd873caa350 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 20 Feb 2020 16:01:06 -0800 Subject: [PATCH 1/3] maybe this'll work. --- code/controllers/subsystem/vote.dm | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index f3513b7af7..532fe2b97c 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -211,20 +211,19 @@ SUBSYSTEM_DEF(vote) var/already_lost_runoff = list() var/list/cur_choices = choices.Copy() for(var/ckey in voted) - choices[choices[voted[ckey][1]]]++ // jesus christ how horrifying + choices["[voted[ckey][1]]"]++ // jesus christ how horrifying for(var/_this_var_unused_ignore_it in 1 to choices.len) // if it takes more than this something REALLY wrong happened for(var/ckey in voted) - cur_choices[cur_choices[voted[ckey][1]]]++ // jesus christ how horrifying + cur_choices["[voted[ckey][1]]]"]++ // oh god it's being done AGAIN var/least_vote = 100000 - var/least_voted = 1 - for(var/i in 1 to cur_choices.len) - var/option = cur_choices[i] - if(cur_choices[option] > voted.len/2) - return list(option) - else if(cur_choices[option] < least_vote && !(option in already_lost_runoff)) - least_vote = cur_choices[option] - least_voted = i - already_lost_runoff += cur_choices[least_voted] + var/least_voted = -1 + for(var/option in cur_choices) + if(cur_choices["[option]"] > voted.len/2) + return list("[option]") + else if(cur_choices["[option]"] < least_vote && !("[option]" in already_lost_runoff)) + least_vote = cur_choices["[option]"] + least_voted = option + already_lost_runoff += cur_choices["[least_voted]"] for(var/ckey in voted) voted[ckey] -= least_voted for(var/i in 1 to cur_choices.len) @@ -411,12 +410,12 @@ SUBSYSTEM_DEF(vote) return vote if(SCHULZE_VOTING,INSTANT_RUNOFF_VOTING) if(usr.ckey in voted) - if(vote in voted[usr.ckey]) - voted[usr.ckey] -= vote + if(choices[vote] in voted[usr.ckey]) + voted[usr.ckey] -= choices[vote] else voted += usr.ckey voted[usr.ckey] = list() - voted[usr.ckey] += vote + voted[usr.ckey] += choices[vote] saved -= usr.ckey if(SCORE_VOTING,MAJORITY_JUDGEMENT_VOTING) if(!(usr.ckey in voted)) From a49260e0ac93003dfcfd78c94e70e981297df407 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 20 Feb 2020 16:03:00 -0800 Subject: [PATCH 2/3] Revert "maybe this'll work." This reverts commit 8d00f11fc105b6b7e20e56ecfd35edd873caa350. --- code/controllers/subsystem/vote.dm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 532fe2b97c..f3513b7af7 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -211,19 +211,20 @@ SUBSYSTEM_DEF(vote) var/already_lost_runoff = list() var/list/cur_choices = choices.Copy() for(var/ckey in voted) - choices["[voted[ckey][1]]"]++ // jesus christ how horrifying + choices[choices[voted[ckey][1]]]++ // jesus christ how horrifying for(var/_this_var_unused_ignore_it in 1 to choices.len) // if it takes more than this something REALLY wrong happened for(var/ckey in voted) - cur_choices["[voted[ckey][1]]]"]++ // oh god it's being done AGAIN + cur_choices[cur_choices[voted[ckey][1]]]++ // jesus christ how horrifying var/least_vote = 100000 - var/least_voted = -1 - for(var/option in cur_choices) - if(cur_choices["[option]"] > voted.len/2) - return list("[option]") - else if(cur_choices["[option]"] < least_vote && !("[option]" in already_lost_runoff)) - least_vote = cur_choices["[option]"] - least_voted = option - already_lost_runoff += cur_choices["[least_voted]"] + var/least_voted = 1 + for(var/i in 1 to cur_choices.len) + var/option = cur_choices[i] + if(cur_choices[option] > voted.len/2) + return list(option) + else if(cur_choices[option] < least_vote && !(option in already_lost_runoff)) + least_vote = cur_choices[option] + least_voted = i + already_lost_runoff += cur_choices[least_voted] for(var/ckey in voted) voted[ckey] -= least_voted for(var/i in 1 to cur_choices.len) @@ -410,12 +411,12 @@ SUBSYSTEM_DEF(vote) return vote if(SCHULZE_VOTING,INSTANT_RUNOFF_VOTING) if(usr.ckey in voted) - if(choices[vote] in voted[usr.ckey]) - voted[usr.ckey] -= choices[vote] + if(vote in voted[usr.ckey]) + voted[usr.ckey] -= vote else voted += usr.ckey voted[usr.ckey] = list() - voted[usr.ckey] += choices[vote] + voted[usr.ckey] += vote saved -= usr.ckey if(SCORE_VOTING,MAJORITY_JUDGEMENT_VOTING) if(!(usr.ckey in voted)) From 9f9881b57e35a7ee717a31c6814c08aa94364fc9 Mon Sep 17 00:00:00 2001 From: Putnam Date: Thu, 20 Feb 2020 18:43:36 -0800 Subject: [PATCH 3/3] this is so sad --- code/controllers/subsystem/vote.dm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index f3513b7af7..0bd4840c7d 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -211,24 +211,24 @@ SUBSYSTEM_DEF(vote) var/already_lost_runoff = list() var/list/cur_choices = choices.Copy() for(var/ckey in voted) - choices[choices[voted[ckey][1]]]++ // jesus christ how horrifying + choices["[choices[voted[ckey][1]]]"]++ // jesus christ how horrifying for(var/_this_var_unused_ignore_it in 1 to choices.len) // if it takes more than this something REALLY wrong happened for(var/ckey in voted) - cur_choices[cur_choices[voted[ckey][1]]]++ // jesus christ how horrifying + cur_choices["[cur_choices[voted[ckey][1]]]]"]++ // jesus christ how horrifying var/least_vote = 100000 var/least_voted = 1 for(var/i in 1 to cur_choices.len) var/option = cur_choices[i] - if(cur_choices[option] > voted.len/2) - return list(option) - else if(cur_choices[option] < least_vote && !(option in already_lost_runoff)) - least_vote = cur_choices[option] + if(cur_choices["[option]"] > voted.len/2) + return list("[option]") + else if(cur_choices["[option]"] < least_vote && !("[option]" in already_lost_runoff)) + least_vote = cur_choices["[option]"] least_voted = i already_lost_runoff += cur_choices[least_voted] for(var/ckey in voted) voted[ckey] -= least_voted for(var/i in 1 to cur_choices.len) - cur_choices[cur_choices[i]] = 0 + cur_choices["[cur_choices[i]]"] = 0 /datum/controller/subsystem/vote/proc/announce_result() var/vote_title_text