mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
[MIRROR] Partial revert of datum poll creation, fixes duplicated irv votes (#3903)
* Partial revert of datum poll creation, fixes duplicated irv votes (#57462) * Partial revert of datum poll creation + stops duplicated votes from being trusted from clients Reverts the part of jordies poll refactor that allowed a duplicated vote in the db to make it back on the client's vote screen. Also fixes the code that would allowed duplicated votes to be passed from the client. (not from jordie's poll refactor pr.) The race condition still exists, thats harder to fix, counting code handles this correctly * Update poll.dm * Update poll.dm * Partial revert of datum poll creation, fixes duplicated irv votes Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com>
This commit is contained in:
co-authored by
Kyle Spier-Swenson
parent
df8f8b2336
commit
e18a62dfee
@@ -238,16 +238,14 @@
|
||||
var/list/prepared_options = list()
|
||||
//if they've already voted we use the order they voted in plus a shuffle of any options they haven't voted for, if any
|
||||
if(length(voted_for))
|
||||
var/list/option_copy = poll.options.Copy()
|
||||
for(var/vote_id in voted_for)
|
||||
for(var/o in poll.options)
|
||||
for(var/o in option_copy)
|
||||
var/datum/poll_option/option = o
|
||||
if(option.option_id == vote_id)
|
||||
prepared_options += option
|
||||
var/list/shuffle_options = poll.options - prepared_options
|
||||
if(length(shuffle_options))
|
||||
shuffle_options = shuffle(shuffle_options)
|
||||
for(var/shuffled in shuffle_options)
|
||||
prepared_options += shuffled
|
||||
option_copy -= option
|
||||
prepared_options += shuffle(option_copy)
|
||||
//otherwise just shuffle the options
|
||||
else
|
||||
prepared_options = shuffle(poll.options)
|
||||
@@ -547,9 +545,12 @@
|
||||
"ip" = "INET_ATON(?)",
|
||||
)
|
||||
|
||||
var/sql_votes = list()
|
||||
var/list/sql_votes = list()
|
||||
var/list/option_copy = poll.options.Copy()
|
||||
for(var/o in votelist)
|
||||
var/datum/poll_option/option = locate(o) in poll.options
|
||||
var/datum/poll_option/option = locate(o) in option_copy
|
||||
if (!option)
|
||||
to_chat(src, "<span class='warning'>invalid votes were trimmed from your ballot, please revote .</span>")
|
||||
sql_votes += list(list(
|
||||
"pollid" = sql_poll_id,
|
||||
"optionid" = option.option_id,
|
||||
|
||||
Reference in New Issue
Block a user