Makes vote weight and preferred map actually work (#17880)

This commit is contained in:
adamsong
2023-02-17 01:56:39 -05:00
committed by GitHub
parent 22657a9023
commit f6ed8e4b0b

View File

@@ -42,12 +42,7 @@ SUBSYSTEM_DEF(vote)
/datum/controller/subsystem/vote/proc/get_result()
//get the highest number of votes
var/greatest_votes = 0
var/total_votes = 0
for(var/option in choices)
var/votes = choices[option]
total_votes += votes
if(votes > greatest_votes)
greatest_votes = votes
//default-vote for everyone who didn't vote
if(!CONFIG_GET(flag/default_no_vote) && choices.len)
var/list/non_voters = GLOB.directory.Copy()
@@ -70,19 +65,21 @@ SUBSYSTEM_DEF(vote)
for (var/non_voter_ckey in non_voters)
var/client/C = non_voters[non_voter_ckey]
var/preferred_map = C.prefs.read_preference(/datum/preference/choiced/preferred_map)
if(isnull(global.config.defaultmap))
continue
if(!preferred_map)
if(global.config.defaultmap.map_name)
preferred_map = global.config.defaultmap.map_name
if(preferred_map)
choices[preferred_map] += 1
greatest_votes = max(greatest_votes, choices[preferred_map])
. = list()
if(greatest_votes)
for(var/option in choices)
if(choices[option] == greatest_votes)
. += option
for(var/option in choices)
var/weight = 1
if(mode == "map")
var/datum/map_config/VM = config.maplist[option]
weight = VM.voteweight
var/votes = choices[option] * weight
if(votes == greatest_votes)
. += option
if(votes > greatest_votes)
. = list(option)
greatest_votes = votes
return .
/datum/controller/subsystem/vote/proc/announce_result()