Merge pull request #4431 from VOREStation/upstream-merge-5675

[MIRROR] Ports Vote to SMC
This commit is contained in:
Aronai Sieyes
2018-10-20 17:58:12 -04:00
committed by GitHub
9 changed files with 397 additions and 415 deletions

View File

@@ -66,6 +66,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
// If the subsystem isn't listed here it's either DEFAULT or PROCESS (if it's a processing subsystem child)
#define FIRE_PRIORITY_SHUTTLES 5
#define FIRE_PRIORITY_ORBIT 8
#define FIRE_PRIORITY_VOTE 9
#define FIRE_PRIORITY_GARBAGE 15
#define FIRE_PRIORITY_AIRFLOW 30
#define FIRE_PRIORITY_AIR 35

5
code/__defines/vote.dm Normal file
View File

@@ -0,0 +1,5 @@
#define VOTE_RESTART "restart"
#define VOTE_GAMEMODE "gamemode"
#define VOTE_CREW_TRANSFER "crew_transfer"
#define VOTE_ADD_ANTAGONIST "add_antagonist"
#define VOTE_CUSTOM "custom"

View File

@@ -1,6 +0,0 @@
/datum/controller/process/vote/setup()
name = "vote"
schedule_interval = 10 // every second
/datum/controller/process/vote/doWork()
vote.process()

View File

@@ -16,13 +16,15 @@ datum/controller/transfer_controller/Destroy()
datum/controller/transfer_controller/proc/process()
currenttick = currenttick + 1
if (round_duration_in_ticks >= shift_last_vote - 2 MINUTES) //VOREStation Edit START
//VOREStation Edit START
if (round_duration_in_ticks >= shift_last_vote - 2 MINUTES)
shift_last_vote = 999999999999 //Setting to a stupidly high number since it'll be not used again.
to_world("<b>Warning: This upcoming round-extend vote will be your ONLY extend vote. Wrap up your scenes in the next 60 minutes if the round is extended.</b>") //VOREStation Edit
if (round_duration_in_ticks >= shift_hard_end - 1 MINUTE)
init_shift_change(null, 1)
shift_hard_end = timerbuffer + config.vote_autotransfer_interval //If shuttle somehow gets recalled, let's force it to call again next time a vote would occur.
timerbuffer = timerbuffer + config.vote_autotransfer_interval //Just to make sure a vote doesn't occur immediately afterwords.
else if (round_duration_in_ticks >= timerbuffer - 1 MINUTE) //VOREStation Edit END
vote.autotransfer()
else if (round_duration_in_ticks >= timerbuffer - 1 MINUTE)
SSvote.autotransfer()
//VOREStation Edit END
timerbuffer = timerbuffer + config.vote_autotransfer_interval

View File

@@ -1,64 +1,48 @@
var/datum/controller/vote/vote = new()
SUBSYSTEM_DEF(vote)
name = "Vote"
wait = 10
priority = FIRE_PRIORITY_VOTE
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT
flags = SS_KEEP_TIMING | SS_NO_INIT
var/list/round_voters = list()
var/global/list/round_voters = list() // Keeps track of the individuals voting for a given round, for use in forcedrafting.
#define VOTE_RESTART "restart"
#define VOTE_GAMEMODE "gamemode"
#define VOTE_CREW_TRANSFER "crew_transfer"
#define VOTE_ADD_ANTAGONIST "add_antagonist"
#define VOTE_CUSTOM "custom"
/datum/controller/vote
var/initiator = null // Key of the one who started the vote or "the server"
var/started_time = null
var/time_remaining = 0
var/mode = null
var/question = null
//Current vote
var/initiator
var/started_time
var/time_remaining
var/duration
var/mode
var/question
var/list/choices = list()
var/list/gamemode_names = list()
var/list/voted = list()
var/list/current_votes = list()
var/list/additional_text = list()
/datum/controller/vote/New()
if(vote != src)
if(istype(vote))
Recover()
qdel(vote)
vote = src
/datum/controller/vote/Destroy()
..()
// Tell qdel() to Del() this object.
return QDEL_HINT_HARDDEL_NOW
/datum/controller/vote/proc/process() //called by master_controller
/datum/controller/subsystem/vote/fire(resumed)
if(mode)
// No more change mode votes after the game has started.
time_remaining = round((started_time + duration - world.time)/10)
if(mode == VOTE_GAMEMODE && ticker.current_state >= GAME_STATE_SETTING_UP)
world << "<b>Voting aborted due to game start.</b>"
src.reset()
to_chat(world, "<b>Gamemode vote aborted: Game has alread ystarted.</b>")
reset()
return
// Calculate how much time is remaining by comparing current time, to time of vote start,
// plus vote duration
time_remaining = round((started_time + config.vote_period - world.time)/10)
if(time_remaining < 0)
if(time_remaining <= 0)
result()
reset()
/datum/controller/vote/proc/autotransfer()
/datum/controller/subsystem/vote/proc/autotransfer()
initiate_vote(VOTE_CREW_TRANSFER, "the server", 1)
log_debug("The server has called a crew transfer vote")
log_debug("The server has called a crew transfer vote.")
/datum/controller/vote/proc/autogamemode()
/datum/controller/subsystem/vote/proc/autogamemode()
initiate_vote(VOTE_GAMEMODE, "the server", 1)
log_debug("The server has called a gamemode vote")
log_debug("The server has called a gamemode vote.")
/datum/controller/vote/proc/reset()
/datum/controller/subsystem/vote/proc/reset()
initiator = null
time_remaining = 0
started_time = null
duration = null
time_remaining = null
mode = null
question = null
choices.Cut()
@@ -66,7 +50,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
current_votes.Cut()
additional_text.Cut()
/datum/controller/vote/proc/get_result() // Get the highest number of votes
/datum/controller/subsystem/vote/proc/get_result() // Get the highest number of votes
var/greatest_votes = 0
var/total_votes = 0
@@ -111,7 +95,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
if(choices[option] == greatest_votes)
. += option
/datum/controller/vote/proc/announce_result()
/datum/controller/subsystem/vote/proc/announce_result()
var/list/winners = get_result()
var/text
if(winners.len > 0)
@@ -135,9 +119,9 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
if(mode == VOTE_ADD_ANTAGONIST)
antag_add_failed = 1
log_vote(text)
world << "<font color='purple'>[text]</font>"
to_chat(world, "<font color='purple'>[text]</font>")
/datum/controller/vote/proc/result()
/datum/controller/subsystem/vote/proc/result()
. = announce_result()
var/restart = 0
if(.)
@@ -175,7 +159,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
log_game("Rebooting due to restart vote")
world.Reboot()
/datum/controller/vote/proc/submit_vote(var/ckey, var/newVote)
/datum/controller/subsystem/vote/proc/submit_vote(ckey, newVote)
if(mode)
if(config.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
return
@@ -187,7 +171,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
else
current_votes[ckey] = null
/datum/controller/vote/proc/initiate_vote(var/vote_type, var/initiator_key, var/automatic = 0)
/datum/controller/subsystem/vote/proc/initiate_vote(vote_type, initiator_key, automatic = FALSE, time = config.vote_period)
if(!mode)
if(started_time != null && !(check_rights(R_ADMIN) || automatic))
var/next_allowed_time = (started_time + config.vote_delay)
@@ -243,6 +227,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
mode = vote_type
initiator = initiator_key
started_time = world.time
duration = time
var/text = "[capitalize(mode)] vote started by [initiator]."
if(mode == VOTE_CUSTOM)
text += "\n[question]"
@@ -261,13 +246,13 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
return 1
return 0
/datum/controller/vote/proc/interface(var/client/C)
/datum/controller/subsystem/vote/proc/interface(var/client/C)
if(!istype(C))
return
var/admin = 0
var/admin = FALSE
if(C.holder)
if(C.holder.rights & R_ADMIN)
admin = 1
admin = TRUE
. = "<html><head><title>Voting Panel</title></head><body>"
if(mode)
@@ -337,7 +322,7 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
. += "<a href='?src=\ref[src];vote=close' style='position:absolute;right:50px'>Close</a></body></html>"
/datum/controller/vote/Topic(href, href_list[])
/datum/controller/subsystem/vote/Topic(href, href_list[])
if(!usr || !usr.client)
return
switch(href_list["vote"])
@@ -384,5 +369,5 @@ var/global/list/round_voters = list() // Keeps track of the individuals voting f
set category = "OOC"
set name = "Vote"
if(vote)
src << browse(vote.interface(src), "window=vote;size=500x[300 + vote.choices.len * 25]")
if(SSvote)
src << browse(SSvote.interface(src), "window=vote;size=500x[300 + SSvote.choices.len * 25]")

View File

@@ -130,9 +130,6 @@
if("Chemistry")
debug_variables(chemistryProcess)
feedback_add_details("admin_verb", "DChem")
if("Vote")
debug_variables(vote)
feedback_add_details("admin_verb", "DVote")
message_admins("Admin [key_name_admin(usr)] is debugging the [controller] controller.")
return

View File

@@ -44,7 +44,7 @@ var/global/datum/controller/gameticker/ticker
'sound/music/title2.ogg',\
'sound/music/clouds.s3m',\
'sound/music/space_oddity.ogg') //Ground Control to Major Tom, this song is cool, what's going on?
*/
*/ //VOREStation Edit End
send2mainirc("Server lobby is loaded and open at byond://[config.serverurl ? config.serverurl : (config.server ? config.server : "[world.address]:[world.port]")]")
@@ -53,21 +53,17 @@ var/global/datum/controller/gameticker/ticker
to_chat(world, "<B><FONT color='blue'>Welcome to the pregame lobby!</FONT></B>")
to_chat(world, "Please set up your character and select ready. The round will start in [pregame_timeleft] seconds.")
while(current_state == GAME_STATE_PREGAME)
for(var/i=0, i<10, i++)
sleep(1)
vote.process()
if(round_progressing)
pregame_timeleft--
if(pregame_timeleft == config.vote_autogamemode_timeleft)
if(!vote.time_remaining)
vote.autogamemode() //Quit calling this over and over and over and over.
while(vote.time_remaining)
for(var/i=0, i<10, i++)
if(!SSvote.time_remaining)
SSvote.autogamemode() //Quit calling this over and over and over and over.
while(SSvote.time_remaining)
sleep(1)
vote.process()
if(pregame_timeleft <= 0)
current_state = GAME_STATE_SETTING_UP
Master.SetRunLevel(RUNLEVEL_SETUP)
sleep(10)
while (!setup())
@@ -377,7 +373,7 @@ var/global/datum/controller/gameticker/ticker
if(!round_end_announced) // Spam Prevention. Now it should announce only once.
to_chat(world, "<span class='danger'>The round has ended!</span>")
round_end_announced = 1
vote.autotransfer()
SSvote.autotransfer()
return 1

View File

@@ -34,9 +34,11 @@
log_admin("[key_name(src)] has attempted to advertise in OOC: [msg]")
message_admins("[key_name_admin(src)] has attempted to advertise in OOC: [msg]")
return
if(vote && vote.mode)
src << "<span class='danger'>OOC is not allowed during voting.</span>"
//VOREStation Add - No talking during voting
if(SSvote && SSvote.mode)
to_chat(src,"<span class='danger'>OOC is not allowed during voting.</span>")
return
//VOREStation Add End
log_ooc(msg, src)

View File

@@ -70,6 +70,7 @@
#include "code\__defines\turfs.dm"
#include "code\__defines\typeids.dm"
#include "code\__defines\unit_tests.dm"
#include "code\__defines\vote.dm"
#include "code\__defines\xenoarcheaology.dm"
#include "code\__defines\ZAS.dm"
#include "code\_compatibility\509\_JSON.dm"
@@ -197,7 +198,6 @@
#include "code\controllers\master_controller.dm"
#include "code\controllers\subsystem.dm"
#include "code\controllers\verbs.dm"
#include "code\controllers\voting.dm"
#include "code\controllers\observer_listener\atom\observer.dm"
#include "code\controllers\Processes\alarm.dm"
#include "code\controllers\Processes\chemistry.dm"
@@ -213,7 +213,6 @@
#include "code\controllers\Processes\supply.dm"
#include "code\controllers\Processes\ticker.dm"
#include "code\controllers\Processes\turf.dm"
#include "code\controllers\Processes\vote.dm"
#include "code\controllers\ProcessScheduler\core\process.dm"
#include "code\controllers\ProcessScheduler\core\processScheduler.dm"
#include "code\controllers\subsystems\air.dm"
@@ -233,6 +232,7 @@
#include "code\controllers\subsystems\planets.dm"
#include "code\controllers\subsystems\shuttles.dm"
#include "code\controllers\subsystems\transcore_vr.dm"
#include "code\controllers\subsystems\vote.dm"
#include "code\controllers\subsystems\xenoarch.dm"
#include "code\datums\ai_law_sets.dm"
#include "code\datums\ai_laws.dm"