mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-20 03:19:58 +01:00
* tgui the beginning * binaries and the like * Bring in the last of it * Example radio UI * delete example * NTOS Main Menu, start on manifest, tgui states * tasks.json * gunnery ui pt 1 * okay * fix everything * scss update * oops * manifest gigablast * downloader part 1 * download prt 2 * NTOSDownloader final * mfw committing to_worlds * gunnery console pt2 * i cooked * targeting (finished) * one vueui down * voting ui almost done * MY MIND FEELS LIKE AN ARCH ENEMYYYY * voting ui down * photocopier * ntos config + download fixes * photocopier 2 * refactor define * NTOS client manager + fixes * fax machine final (it also uses toner now) * marching forwards... left behind... * ntnrc part 1 * canister * add quotes * portable pumps pt1 + more backgrounds * oops * finish the portable pump * freezers so I'll keep on pushing forward... you haven't seen the last of me... oooooooh... * doors ui pt1 * finish doors UI (forgive me wildkins it's a bit of shitcode) * vitals monitor, make things use labeled lists, new backgrounds * mais j'envoyé aucun mayday... * maglock pt1 * pour ça je me suis perdu... * infrared * fix that * prox sensor pt1 * prox sensor * signaler (this was actually pretty hard) * atmos control pt1 * atmos control pt1.1 * atmos pt 2 * fuel injector * multitool UI * jammer * list viewer * APC * portgen * targeting console updates + SMES ui * new themes, shield generator * supermatter * Add ore detector and (shitty) NTNet Relay * orderterminal pt1 * orderterminal pt2 * smartfridge * Add (air-)tank GUI update ore detector size * Adds Transfer Valves * Add AtmoScrubber * analyzer pt1 * weapons analyzer pt2 * bodyscanner pt1 * bodyscanner pt2 * fix this shitcode * seed storage * appearance changer * appearance changer final * sleeper pt1 * sleeper * gps * vehicles * chem dispenser * lily request * holopad * tgui modules pt1 * ppanel * damage menu * fixes * im here too now * follow menu, search bars * quikpay * quikpay fixes * circuit printer * ppanel * ppanel updates * pai * turret controls (i want to kill myself) * tweak * remove the boardgame * guntracker * implant tracker * penal mechs come close to me, come close to me * chem codex * pai radio * doorjack * pai directives * signaler removal, sensors * ghost spawner * spawnpoint * fixes * teleporter * one more to the chopping block * account database * remove divider * scanner, atmos * latejoin ui pt1 * latejoin * records pt1 * RECORDS UI DONE * delete interpreter & records * CHAT FUCKING CLIENT * data updates * fix some things * final UI, log * basic nanoui fix * antag panel * remove vueui * atm update * vending update * warrants, cameras * ntmonitor * time comes for all * preserve this legacy * bring that back (oops) * rcon, ui auto update for computer UIs, remove rcon computers * alarm monitoring (a bit broke and also todo: add custom alarm monitoring programs to a few consoles) * A LIKE SUPREME * a * power monitor * lights on * fuck this code, fuck nanoui modules, and fuck nanoui * LEAVE IT OH SO FAR BEHIND * fix alarm monitoring for synths * I SAW IN YOU WHAT LIFE WAS MISSING * comms console * idcard and record updates * turn the light on * arcade * pt2 * news browser * static * crusher * f * COULD I JUST SLEIGH THE GOLD FROM THE BALLS? I'M SO FRUSTRATED OH COULD YOU TELL? IF I HEAR ONE MORE VUEUI OR ONE NANOUI I'M GONNA LOSE IT SO LET ME GOOOOOOOOOOOOOOOOO * codeowners & suit sensors * html ui style removal * make lint happy * tgchat * tgpanels pt1 * THE SOUL LONGS FOR OBLIVION!!!!!!!!!!!!!!!!! * figure out why stat isnt working * goodbye ping * shhh * stat updates * An oath sworn in scors! Omni vortex lies! * final almost edits * fix that * last skin adjustments * resist and disorder * i slowly get up and turn off the noise, already fed up... * pleaseeeeeeeeeeeeeee * THE CREDIT LARP IS NECESSARY * i hold the keys * RISE UP * fix that? * harry's suggestions xoxo * runtime fix pt2 * You are the only thing that I still care about * fix runtimes and cl * whoops * misc fixes * fix that too * adds build workflow * f * Update update_tgui.yml * adds some needed steps * ATM * misc fixes and tweaks * fixes 2 * make newscasters usable and fix use power on freezers * turret control is clearer * remove duplicate * makes some verb tabs work properly * makes verbs work properly for real * sans moi * fixes pt2 * fix the chat unnecessarily reloading * fixes * epic * fixes * fix missing consoles --------- Co-authored-by: John Wildkins <john.wildkins@gmail.com> Co-authored-by: Matt Atlas <liermattia@gmail.com> Co-authored-by: harryob <55142896+harryob@users.noreply.github.com> Co-authored-by: Werner <Arrow768@users.noreply.github.com> Co-authored-by: Geeves <ggrobler447@gmail.com> Co-authored-by: harryob <me@harryob.live>
443 lines
14 KiB
Plaintext
443 lines
14 KiB
Plaintext
var/datum/controller/subsystem/vote/SSvote
|
|
|
|
/datum/controller/subsystem/vote
|
|
name = "Voting"
|
|
wait = 1 SECOND
|
|
flags = SS_KEEP_TIMING | SS_NO_TICK_CHECK
|
|
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
|
|
priority = SS_PRIORITY_VOTE
|
|
|
|
var/next_transfer_time
|
|
|
|
var/initiator = null
|
|
var/started_time = null
|
|
var/time_remaining = 0
|
|
var/mode = null
|
|
var/question = null
|
|
var/list/choices = list()
|
|
var/list/voted = list()
|
|
var/list/current_votes = list()
|
|
var/auto_muted = 0
|
|
var/last_transfer_vote = null
|
|
|
|
var/list/round_voters = list()
|
|
|
|
/datum/controller/subsystem/vote/New()
|
|
NEW_SS_GLOBAL(SSvote)
|
|
|
|
/datum/controller/subsystem/vote/Initialize(timeofday)
|
|
next_transfer_time = config.vote_autotransfer_initial
|
|
|
|
/datum/controller/subsystem/vote/fire(resumed = FALSE)
|
|
if (mode)
|
|
// No more change mode votes after the game has started.
|
|
if(mode == "gamemode" && ROUND_IS_STARTED)
|
|
to_world("<b>Voting aborted due to game start.</b>")
|
|
reset()
|
|
return
|
|
|
|
if(((started_time + config.vote_period - world.time)) < 0)
|
|
result()
|
|
SStgui.close_uis(src)
|
|
reset()
|
|
|
|
if (get_round_duration() >= next_transfer_time - 600)
|
|
autotransfer()
|
|
next_transfer_time += config.vote_autotransfer_interval
|
|
|
|
/datum/controller/subsystem/vote/proc/autotransfer()
|
|
initiate_vote("crew_transfer","the server", 1)
|
|
log_debug("The server has called a crew transfer vote")
|
|
|
|
/datum/controller/subsystem/vote/proc/autogamemode()
|
|
for(var/thing in clients)
|
|
var/client/C = thing
|
|
window_flash(C)
|
|
initiate_vote("gamemode","the server", 1)
|
|
log_debug("The server has called a gamemode vote")
|
|
|
|
/datum/controller/subsystem/vote/proc/reset()
|
|
initiator = null
|
|
time_remaining = 0
|
|
mode = null
|
|
question = null
|
|
choices.Cut()
|
|
voted.Cut()
|
|
current_votes.Cut()
|
|
SStgui.update_uis(src)
|
|
|
|
/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]["votes"]
|
|
total_votes += votes
|
|
if(votes > greatest_votes)
|
|
greatest_votes = votes
|
|
//default-vote for everyone who didn't vote
|
|
if(!config.vote_no_default && choices.len)
|
|
var/non_voters = (clients.len - total_votes)
|
|
if(non_voters > 0)
|
|
if(mode == "restart")
|
|
choices["Continue Playing"]["votes"] += non_voters
|
|
if(choices["Continue Playing"]["votes"] >= greatest_votes)
|
|
greatest_votes = choices["Continue Playing"]["votes"]
|
|
else if(mode == "gamemode")
|
|
if(master_mode in choices)
|
|
choices[master_mode]["votes"] += non_voters
|
|
if(choices[master_mode]["votes"] >= greatest_votes)
|
|
greatest_votes = choices[master_mode]["votes"]
|
|
else if(mode == "crew_transfer")
|
|
var/factor = 0.5
|
|
switch(get_round_duration() / (10 * 60)) // minutes
|
|
if(0 to 60)
|
|
factor = 0.5
|
|
if(61 to 120)
|
|
factor = 0.8
|
|
if(121 to 240)
|
|
factor = 1
|
|
if(241 to 300)
|
|
factor = 1.2
|
|
else
|
|
factor = 1.4
|
|
choices["Initiate Crew Transfer"]["votes"] = round(choices["Initiate Crew Transfer"]["votes"] * factor)
|
|
to_world("<span class='vote'>Crew Transfer Factor: [factor]</span>")
|
|
greatest_votes = max(choices["Initiate Crew Transfer"]["votes"], choices["Continue The Round"]["votes"])
|
|
|
|
if(mode == "crew_transfer")
|
|
if(round(get_round_duration() / 36000)+12 <= 14)
|
|
// Credit to Scopes @ oldcode.
|
|
to_world("<span class='vote'><b>Majority voting rule in effect. 2/3rds majority needed to initiate transfer.</b></span>")
|
|
choices["Initiate Crew Transfer"]["votes"] = round(choices["Initiate Crew Transfer"]["votes"] - round(total_votes / 3))
|
|
greatest_votes = max(choices["Initiate Crew Transfer"]["votes"], choices["Continue The Round"]["votes"])
|
|
|
|
//get all options with that many votes and return them in a list
|
|
. = list()
|
|
if(greatest_votes)
|
|
for(var/option in choices)
|
|
if(choices[option]["votes"] == greatest_votes)
|
|
. += option
|
|
|
|
/datum/controller/subsystem/vote/proc/announce_result()
|
|
var/list/winners = get_result()
|
|
var/text
|
|
if(winners.len > 0)
|
|
if(winners.len > 1)
|
|
if(mode != "gamemode" || SSticker.hide_mode == 0) // Here we are making sure we don't announce potential game modes
|
|
text = "<b>Vote Tied Between:</b>\n"
|
|
for(var/option in winners)
|
|
text += "\t[option]\n"
|
|
. = pick(winners)
|
|
|
|
for(var/key in current_votes)
|
|
if(current_votes[key] == .)
|
|
round_voters += key // Keep track of who voted for the winning round.
|
|
|
|
if((mode == "gamemode" && . == "Extended") || SSticker.hide_mode == 0) // Announce Extended gamemode, but not other gamemodes
|
|
text += "<b>Vote Result: [.]</b>"
|
|
else
|
|
if(mode != "gamemode")
|
|
text += "<b>Vote Result: [.]</b>"
|
|
else
|
|
text += "<b>The vote has ended.</b>" // What will be shown if it is a gamemode vote that isn't extended
|
|
|
|
else
|
|
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
|
|
if(mode == "add_antagonist")
|
|
antag_add_failed = 1
|
|
log_vote(text)
|
|
to_world("<span class='vote'>[text]</span>")
|
|
|
|
/datum/controller/subsystem/vote/proc/result()
|
|
. = announce_result()
|
|
var/restart = 0
|
|
if(.)
|
|
switch(mode)
|
|
if("restart")
|
|
if(. == "Restart Round")
|
|
restart = 1
|
|
if("gamemode")
|
|
if(master_mode != .)
|
|
SSpersist_config.last_gamemode = .
|
|
if(SSticker.mode)
|
|
restart = 1
|
|
else
|
|
master_mode = .
|
|
if("crew_transfer")
|
|
if(. == "Initiate Crew Transfer")
|
|
init_shift_change(null, 1)
|
|
last_transfer_vote = get_round_duration()
|
|
if("add_antagonist")
|
|
if(isnull(.) || . == "None")
|
|
antag_add_failed = 1
|
|
else
|
|
additional_antag_types |= antag_names_to_ids[.]
|
|
|
|
if(mode == "gamemode") //fire this even if the vote fails.
|
|
if(!round_progressing)
|
|
round_progressing = 1
|
|
to_world("<span class='warning'><b>The round will start soon.</b></span>")
|
|
|
|
if(restart)
|
|
to_world("World restarting due to vote...")
|
|
feedback_set_details("end_error","restart vote")
|
|
sleep(50)
|
|
log_game("Rebooting due to restart vote")
|
|
world.Reboot()
|
|
|
|
/datum/controller/subsystem/vote/proc/submit_vote(ckey, vote)
|
|
if(mode)
|
|
if (mode == "crew_transfer")
|
|
if(config.vote_no_dead && usr && !usr.client.holder)
|
|
if (isnewplayer(usr))
|
|
to_chat(usr, "<span class='warning'>You must be playing or have been playing to start a vote.</span>")
|
|
return 0
|
|
else if (isobserver(usr))
|
|
var/mob/abstract/observer/O = usr
|
|
if (O.started_as_observer)
|
|
to_chat(usr, "<span class='warning'>You must be playing or have been playing to start a vote.</span>")
|
|
return 0
|
|
if(vote in choices)
|
|
if(current_votes[ckey])
|
|
choices[current_votes[ckey]]["votes"]--
|
|
var/vote_descriptor = ""
|
|
if(isnewplayer(usr))
|
|
vote_descriptor = ", from the lobby"
|
|
else if(isobserver(usr))
|
|
vote_descriptor = ", as an observer"
|
|
log_vote("[ckey] submitted their vote for: [vote][vote_descriptor]")
|
|
voted += usr.ckey
|
|
choices[vote]["votes"]++ //check this
|
|
current_votes[ckey] = vote
|
|
return 1
|
|
return 0
|
|
|
|
|
|
/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key, automatic = FALSE)
|
|
if(!mode)
|
|
if(started_time != null && !(check_rights(R_ADMIN|R_MOD) || automatic))
|
|
// Transfer votes are their own little special snowflake
|
|
var/next_allowed_time = 0
|
|
if (vote_type == "crew_transfer")
|
|
if (config.vote_no_dead && !usr.client.holder)
|
|
if (isnewplayer(usr))
|
|
to_chat(usr, "<span class='warning'>You must be playing or have been playing to start a vote.</span>")
|
|
return 0
|
|
else if (isobserver(usr))
|
|
var/mob/abstract/observer/O = usr
|
|
if (O.started_as_observer)
|
|
to_chat(usr, "<span class='warning'>You must be playing or have been playing to start a vote.</span>")
|
|
return 0
|
|
|
|
if (last_transfer_vote)
|
|
next_allowed_time = (last_transfer_vote + config.vote_delay)
|
|
else
|
|
next_allowed_time = config.transfer_timeout
|
|
else
|
|
next_allowed_time = (started_time + config.vote_delay)
|
|
|
|
if(next_allowed_time > get_round_duration())
|
|
return 0
|
|
|
|
//reset()
|
|
switch(vote_type)
|
|
if("restart")
|
|
AddChoice("Restart Round")
|
|
AddChoice("Continue Playing")
|
|
if("gamemode")
|
|
round_voters.Cut() //Delete the old list, since we are having a new gamemode vote
|
|
if(SSticker.current_state >= 2)
|
|
return 0
|
|
for (var/F in config.votable_modes)
|
|
var/datum/game_mode/M = gamemode_cache[F]
|
|
if(!M)
|
|
continue
|
|
AddChoice(F, capitalize(M.name), "[M.required_players]")
|
|
AddChoice(ROUNDTYPE_STR_SECRET, "Secret")
|
|
if(ROUNDTYPE_STR_MIXED_SECRET in choices)
|
|
AddChoice(ROUNDTYPE_STR_MIXED_SECRET, "Mixed Secret")
|
|
if("crew_transfer")
|
|
if(check_rights(R_ADMIN|R_MOD, 0))
|
|
question = "End the shift?"
|
|
AddChoice("Initiate Crew Transfer")
|
|
AddChoice("Continue The Round")
|
|
else
|
|
if (get_security_level() == "red" || get_security_level() == "delta")
|
|
to_chat(initiator_key, "The current alert status is too high to call for a crew transfer!")
|
|
return 0
|
|
if(SSticker.current_state <= 2)
|
|
to_chat(initiator_key, "The crew transfer button has been disabled!")
|
|
return 0
|
|
question = "End the shift?"
|
|
AddChoice("Initiate Crew Transfer")
|
|
AddChoice("Continue The Round")
|
|
if("add_antagonist")
|
|
if(!config.allow_extra_antags || SSticker.current_state >= 2)
|
|
return 0
|
|
for(var/antag_type in all_antag_types)
|
|
var/datum/antagonist/antag = all_antag_types[antag_type]
|
|
if(!(antag.id in additional_antag_types) && antag.is_votable())
|
|
AddChoice(antag.role_text)
|
|
AddChoice("None")
|
|
if("custom")
|
|
question = input(usr,"What is the vote for?") as text|null
|
|
if(!question) return 0
|
|
for(var/i=1,i<=10,i++)
|
|
var/option = capitalize(sanitize(input(usr,"Please enter an option or hit cancel to finish") as text|null))
|
|
if(!option || mode || !usr.client) break
|
|
AddChoice(option)
|
|
else
|
|
return 0
|
|
mode = vote_type
|
|
initiator = initiator_key
|
|
started_time = world.time
|
|
var/text = "[capitalize(mode)] vote started by [initiator]."
|
|
if(mode == "custom")
|
|
text += "\n[sanitizeSafe(question)]"
|
|
|
|
log_vote(text)
|
|
for(var/cc in clients)
|
|
var/client/C = cc
|
|
to_chat(C, "<span class='vote'><b>[text]</b>\nType <b>vote</b> or click <a href='?src=\ref[src];open=1'>here</a> to place your votes.\nYou have [config.vote_period/10] seconds to vote.</span>")
|
|
if(C.prefs.sfx_toggles & ASFX_VOTE) //Personal mute
|
|
switch(vote_type)
|
|
if("crew_transfer")
|
|
sound_to(C, sound('sound/effects/vote.ogg', repeat = 0, wait = 0, volume = 50, channel = 3))
|
|
if("gamemode")
|
|
sound_to(C, sound('sound/ambience/vote_alarm.ogg', repeat = 0, wait = 0, volume = 50, channel = 3))
|
|
if("custom")
|
|
sound_to(C, sound('sound/ambience/vote_alarm.ogg', repeat = 0, wait = 0, volume = 50, channel = 3))
|
|
if(mode == "gamemode" && round_progressing)
|
|
round_progressing = 0
|
|
to_world("<span class='warning'><b>Round start has been delayed.</b></span>")
|
|
SStgui.update_uis(src)
|
|
return 1
|
|
return 0
|
|
|
|
/datum/controller/subsystem/vote/proc/AddChoice(name, display_name, extra_text)
|
|
if(!display_name)
|
|
display_name = name
|
|
choices[name] = list("name" = display_name, "extra" = extra_text, "votes" = 0)
|
|
|
|
/datum/controller/subsystem/vote/ui_state(mob/user)
|
|
return always_state
|
|
|
|
/datum/controller/subsystem/vote/ui_status(mob/user, datum/ui_state/state)
|
|
return UI_INTERACTIVE
|
|
|
|
/datum/controller/subsystem/vote/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if (!ui)
|
|
ui = new(user, src, "Voting", "Voting", 400, 500)
|
|
ui.open()
|
|
|
|
/datum/controller/subsystem/vote/Topic(href, href_list)
|
|
. = ..()
|
|
if(href_list["open"])
|
|
SSvote.ui_interact(usr)
|
|
return TRUE
|
|
|
|
/datum/controller/subsystem/vote/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
|
|
. = TRUE
|
|
var/isstaff = ui.user.client.holder && (ui.user.client.holder.rights & (R_ADMIN|R_MOD))
|
|
|
|
switch(action)
|
|
if("cancel")
|
|
if(isstaff)
|
|
reset()
|
|
return TRUE
|
|
if("toggle_restart")
|
|
if(isstaff)
|
|
config.allow_vote_restart = !config.allow_vote_restart
|
|
SStgui.update_uis(src)
|
|
return TRUE
|
|
if("toggle_gamemode")
|
|
if(isstaff)
|
|
config.allow_vote_mode = !config.allow_vote_mode
|
|
SStgui.update_uis(src)
|
|
return TRUE
|
|
if("restart")
|
|
if(isstaff)
|
|
initiate_vote("restart", ui.user.key)
|
|
return TRUE
|
|
else if (config.allow_vote_restart)
|
|
var/admin_number_present = 0
|
|
var/admin_number_afk = 0
|
|
|
|
for (var/s in staff)
|
|
var/client/X = s
|
|
if (X.holder.rights & R_ADMIN)
|
|
admin_number_present++
|
|
if (X.is_afk())
|
|
admin_number_afk++
|
|
if (X.prefs.toggles & SOUND_ADMINHELP)
|
|
sound_to(X, 'sound/effects/adminhelp.ogg')
|
|
|
|
if ((admin_number_present - admin_number_afk) <= 0)
|
|
initiate_vote("restart", ui.user.key)
|
|
return TRUE
|
|
else
|
|
log_and_message_admins("tried to start a restart vote.", usr, null)
|
|
to_chat(ui.user, "<span class='notice'><b>There are active admins around! You cannot start a restart vote due to this.</b></span>")
|
|
if("gamemode")
|
|
if(config.allow_vote_mode || isstaff)
|
|
initiate_vote("gamemode", ui.user.key)
|
|
return TRUE
|
|
if("crew_transfer")
|
|
if(config.allow_vote_restart || isstaff)
|
|
initiate_vote("crew_transfer", ui.user.key)
|
|
return TRUE
|
|
if("add_antagonist")
|
|
if(!antag_add_failed && config.allow_extra_antags)
|
|
initiate_vote("add_antagonist", ui.user.key)
|
|
return TRUE
|
|
if("custom")
|
|
if(isstaff)
|
|
initiate_vote("custom", ui.user.key)
|
|
return TRUE
|
|
if("vote")
|
|
var/list/T = params["vote"]
|
|
var/our_vote = T["choice"]
|
|
if(our_vote)
|
|
if(submit_vote(ui.user.ckey, our_vote))
|
|
SStgui.update_uis(src)
|
|
return TRUE
|
|
|
|
/datum/controller/subsystem/vote/ui_data(mob/user)
|
|
var/list/data = list()
|
|
if(choices.len != LAZYLEN(data["choices"]))
|
|
data["choices"] = list()
|
|
for(var/choice in choices)
|
|
data["choices"] += list(list(
|
|
"choice" = choice,
|
|
"votes" = choices[choice]["votes"],
|
|
"extra" = choices[choice]["extra"]
|
|
))
|
|
|
|
data["mode"] = mode
|
|
data["voted"] = current_votes[user.ckey]
|
|
data["endtime"] = started_time + config.vote_period
|
|
data["allow_vote_restart"] = config.allow_vote_restart
|
|
data["allow_vote_mode"] = config.allow_vote_mode
|
|
data["allow_extra_antags"] = (!antag_add_failed && config.allow_extra_antags)
|
|
|
|
if(!question)
|
|
data["question"] = capitalize(mode)
|
|
else
|
|
data["question"] = question
|
|
data["is_staff"] = user.client.holder && (user.client.holder.rights & (R_ADMIN|R_MOD))
|
|
var/slevel = get_security_level()
|
|
data["is_code_red"] = (slevel == "red" || slevel == "delta")
|
|
return data
|
|
|
|
/mob/verb/vote()
|
|
set category = "OOC"
|
|
set name = "Vote"
|
|
|
|
SSvote.ui_interact(src)
|