Fixing conflicts

This commit is contained in:
Cadyn
2020-10-05 18:10:53 -07:00
2080 changed files with 1768339 additions and 30848 deletions

View File

@@ -7,7 +7,7 @@ datum/controller/transfer_controller
var/shift_last_vote = 0 //VOREStation Edit
datum/controller/transfer_controller/New()
timerbuffer = config.vote_autotransfer_initial
shift_hard_end = config.vote_autotransfer_initial + (config.vote_autotransfer_interval * 0) //VOREStation Edit //Change this "1" to how many extend votes you want there to be.
shift_hard_end = config.vote_autotransfer_initial + (config.vote_autotransfer_interval * 3) //CHOMPStation Edit //Change this "1" to how many extend votes you want there to be.
shift_last_vote = shift_hard_end - config.vote_autotransfer_interval //VOREStation Edit
START_PROCESSING(SSprocessing, src)
@@ -17,9 +17,9 @@ datum/controller/transfer_controller/Destroy()
datum/controller/transfer_controller/process()
currenttick = currenttick + 1
//VOREStation Edit START
if (round_duration_in_ds >= shift_last_vote - 2 MINUTES)
shift_last_vote = 99999999 //Setting to a stupidly high number since it'll be not used again.
to_world("<b>Warning: You have one hour left in the shift. Wrap up your scenes in the next 60 minutes before the transfer is called.</b>") //VOREStation Edit
if (round_duration_in_ds >= 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 last chance to vote for shift extension. Wrap up your scenes in the next 60 minutes if the round is extended.</b>") //CHOMPStation Edit
if (round_duration_in_ds >= 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.

View File

@@ -37,6 +37,7 @@ var/list/gamemode_cache = list()
var/static/vote_autotransfer_initial = 108000 // Length of time before the first autotransfer vote is called
var/static/vote_autotransfer_interval = 36000 // length of time before next sequential autotransfer vote
var/static/vote_autogamemode_timeleft = 100 //Length of time before round start when autogamemode vote is called (in seconds, default 100).
var/static/vote_autotransfer_amount = 3 //How many autotransfers to have
var/static/vote_no_default = 0 // vote does not default to nochange/norestart (tbi)
var/static/vote_no_dead = 0 // dead people can't vote (tbi)
// var/static/enable_authentication = 0 // goon authentication
@@ -215,7 +216,7 @@ var/list/gamemode_cache = list()
var/python_path = "" //Path to the python executable. Defaults to "python" on windows and "/usr/bin/env python2" on unix
var/use_lib_nudge = 0 //Use the C library nudge instead of the python nudge.
var/use_overmap = 0
var/static/list/engine_map = list("Supermatter Engine", "Edison's Bane") // Comma separated list of engines to choose from. Blank means fully random.
// Event settings
@@ -230,7 +231,7 @@ var/list/gamemode_cache = list()
// 15, 45, 70 minutes respectively
var/static/list/event_delay_upper = list(EVENT_LEVEL_MUNDANE = 9000, EVENT_LEVEL_MODERATE = 27000, EVENT_LEVEL_MAJOR = 42000)
var/static/aliens_allowed = 0
var/static/aliens_allowed = 1 //CHOMPedit to 1. This not only allows the natural spawning of xenos, but also the ability to lay eggs. Xenomorphs cannot lay eggs if this is 0
var/static/ninjas_allowed = 0
var/static/abandon_allowed = 1
var/static/ooc_allowed = 1
@@ -240,10 +241,9 @@ var/list/gamemode_cache = list()
var/persistence_disabled = FALSE
var/persistence_ignore_mapload = FALSE
var/allow_byond_links = 0
var/allow_discord_links = 0
var/allow_url_links = 0 // honestly if I were you i'd leave this one off, only use in dire situations
var/allow_byond_links = 1 //CHOMP Edit turned this on
var/allow_discord_links = 1 //CHOMP Edit turned this on
var/allow_url_links = 1 // honestly if I were you i'd leave this one off, only use in dire situations //CHOMP Edit: pussy.
var/starlight = 0 // Whether space turfs have ambient light or not
@@ -285,7 +285,7 @@ var/list/gamemode_cache = list()
// whether or not to use the nightshift subsystem to perform lighting changes
var/static/enable_night_shifts = FALSE
var/static/vgs_access_identifier = null // VOREStation Edit - VGS
var/static/vgs_server_port = null // VOREStation Edit - VGS
@@ -470,6 +470,9 @@ var/list/gamemode_cache = list()
if ("vote_autotransfer_interval")
config.vote_autotransfer_interval = text2num(value)
if ("vote_autotransfer_amount")
config.vote_autotransfer_amount = text2num(value) //YW addition, vote transfer amount
if ("vote_autogamemode_timeleft")
config.vote_autogamemode_timeleft = text2num(value)
@@ -588,6 +591,9 @@ var/list/gamemode_cache = list()
if("persistence_ignore_mapload")
config.persistence_ignore_mapload = TRUE
if("persistence_ignore_mapload")
config.persistence_ignore_mapload = TRUE
if ("probability")
var/prob_pos = findtext(value, " ")
var/prob_name = null
@@ -934,7 +940,7 @@ var/list/gamemode_cache = list()
if("enable_night_shifts")
config.enable_night_shifts = TRUE
// VOREStation Edit Start - Can't be in _vr file because it is loaded too late.
if("vgs_access_identifier")
config.vgs_access_identifier = value

View File

@@ -0,0 +1,43 @@
// Making this file to allow us to easily understand the location of any modifications to the config file made by Chompers and to try and prevent any conflicts happening in the future.
// Basically a copy pasta from virgo's configuration.dm file but it'll make life easer for us to just toggle on/off.
/datum/configuration
var/discord_restriction = 0
var/use_jobwhitelist = 1
var/emojis = 1
var/vorefootstep_volume = 75 //In future see about making a function to adjust volume serverside in config.txt, easy to do with reenable values. - Jack
/hook/startup/proc/read_ch_config()
var/list/Lines = file2list("config/config.txt")
for(var/t in Lines)
if(!t) continue
t = trim(t)
if (length(t) == 0)
continue
else if (copytext(t, 1, 2) == "#")
continue
var/pos = findtext(t, " ")
var/name = null
// var/value = null //Commenting out because config doesn't contain any values at the moment. - Jonathan
if (pos)
name = lowertext(copytext(t, 1, pos))
// value = copytext(t, pos + 1) //Commenting out because config doesn't contain any values at the moment. - Jonathan
else
name = lowertext(t)
if (!name)
continue
switch (name)
if ("discord_restriction")
config.discord_restriction = 1
if ("use_jobwhitelist")
config.use_jobwhitelist = 1
if ("disable_emojis")
config.emojis = 0
return 1

View File

@@ -0,0 +1,53 @@
/datum/configuration
var/shipping_auth = "memes"
var/list/authedservers = list()
// Example line in the config:
// 192.168.1.1:1234 ServerName;ServerPW (The PW of that server, ask them for it)
/datum/configuration/proc/loadshippinglist(filename)
var/list/Lines = file2list(filename)
for (var/t in Lines)
if(!t) continue
t = trim(t)
if (length(t) == 0)
continue
else if (copytext(t, 1, 2) == "#")
continue
var/pos = findtext(t, " ")
var/ip = null
var/value = null
if (pos)
ip = lowertext(copytext(t, 1, pos))
value = copytext(t, pos + 1)
else
ip = lowertext(t)
if (!ip)
continue
var/name
var/auth
pos = findtext(value, ";")
if (pos)
name = lowertext(copytext(value, 1, pos))
auth = copytext(value, pos + 1)
authedservers[ip] = new /datum/shippingservers(ip, name, auth)
world << "Added server: [ip] [name] [auth] to list"
/datum/shippingservers
var/serverip
var/servername
var/serverauth
var/list/allowedshipids
/datum/shippingservers/New(_serverip, _servername, _serverauth)
if(!_serverip || !_servername || !_serverauth)
throw EXCEPTION("Invalid arguments sent to shippingservers/New().")
serverip = _serverip
servername = _servername
serverauth = _serverauth

View File

@@ -58,7 +58,7 @@ var/global/datum/emergency_shuttle_controller/emergency_shuttle = new
if (evac)
emergency_shuttle_docked.Announce(replacetext(replacetext(using_map.emergency_shuttle_docked_message, "%dock_name%", "[using_map.dock_name]"), "%ETD%", "[estimated_time] minute\s"))
else
priority_announcement.Announce(replacetext(replacetext(using_map.shuttle_docked_message, "%dock_name%", "[using_map.dock_name]"), "%ETD%", "[estimated_time] minute\s"), "Transfer System", 'sound/AI/tramarrived.ogg') //VOREStation Edit - TTS
priority_announcement.Announce(replacetext(replacetext(using_map.shuttle_docked_message, "%dock_name%", "[using_map.dock_name]"), "%ETD%", "[estimated_time] minute\s")) //CHOMP reversion
//arm the escape pods
if (evac)
@@ -115,7 +115,7 @@ var/global/datum/emergency_shuttle_controller/emergency_shuttle = new
shuttle.move_time = SHUTTLE_TRANSIT_DURATION
var/estimated_time = round(estimate_arrival_time()/60,1)
priority_announcement.Announce(replacetext(replacetext(using_map.shuttle_called_message, "%dock_name%", "[using_map.dock_name]"), "%ETA%", "[estimated_time] minute\s"), "Transfer System", 'sound/AI/tramcalled.ogg') //VOREStation Edit - TTS
priority_announcement.Announce(replacetext(replacetext(using_map.shuttle_called_message, "%dock_name%", "[using_map.dock_name]"), "%ETA%", "[estimated_time] minute\s")) //CHOMP Reversion
atc.shift_ending()
//recalls the shuttle

View File

@@ -188,6 +188,9 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
to_chat(world, "<span class='boldannounce'>[msg]</span>")
log_world(msg)
send2chat("Server Initialization completed! - Took [time] second[time == 1 ? "" : "s"].", "bot announce")
if (!current_runlevel)
SetRunLevel(RUNLEVEL_LOBBY)

View File

@@ -0,0 +1,42 @@
#define SSBELLIES_PROCESSED 1
#define SSBELLIES_IGNORED 2
//
// Bellies subsystem - Process vore bellies
//
SUBSYSTEM_DEF(bellies)
name = "Bellies"
priority = 5
wait = 1 SECONDS
flags = SS_KEEP_TIMING|SS_NO_INIT
runlevels = RUNLEVEL_GAME|RUNLEVEL_POSTGAME
var/static/list/belly_list = list()
var/list/currentrun = list()
var/ignored_bellies = 0
/datum/controller/subsystem/bellies/stat_entry()
..("#: [belly_list.len] | P: [ignored_bellies]")
/datum/controller/subsystem/bellies/fire(resumed = 0)
if (!resumed)
ignored_bellies = 0
src.currentrun = belly_list.Copy()
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
var/times_fired = src.times_fired
while(currentrun.len)
var/obj/belly/B = currentrun[currentrun.len]
currentrun.len--
if(QDELETED(B))
belly_list -= B
else
B.HandleBellyReagents() //CHOMP reagent belly stuff, here to jam it into subsystems and avoid too much cpu usage
if(B.process_belly(times_fired,wait) == SSBELLIES_IGNORED)
ignored_bellies++
if (MC_TICK_CHECK)
return

View File

@@ -0,0 +1,35 @@
/**
* Sends a message to TGS chat channels.
*
* message - The message to send.
* channel_tag - Required. If "", the message with be sent to all connected (Game-type for TGS3) channels. Otherwise, it will be sent to TGS4 channels with that tag (Delimited by ','s).
*/
/proc/send2chat(message, channel_tag)
if(channel_tag == null || !world.TgsAvailable())
return
var/datum/tgs_version/version = world.TgsVersion()
if(channel_tag == "" || version.suite == 3)
world.TgsTargetedChatBroadcast(message, FALSE)
return
var/list/channels_to_use = list()
for(var/I in world.TgsChatChannelInfo())
var/datum/tgs_chat_channel/channel = I
var/list/applicable_tags = splittext(channel.tag, ",")
if(channel_tag in applicable_tags)
channels_to_use += channel
if(channels_to_use.len)
world.TgsChatBroadcast(message, channels_to_use)
/**
* Sends a message to TGS admin chat channels.
*
* category - The category of the mssage.
* message - The message to send.
*/
/proc/send2adminchat(category, message)
category = replacetext(replacetext(category, "\proper", ""), "\improper", "")
message = replacetext(replacetext(message, "\proper", ""), "\improper", "")
world.TgsTargetedChatBroadcast("[category] | [message]", TRUE)

View File

@@ -0,0 +1,40 @@
//
// Additions to mapping subsystem handles initialization of random map elements at server start
// I'm kidnapping Vores random engine spawn code - Gozulio.
//
/datum/controller/subsystem/mapping/proc/pickEngine(pickedEngine)
if(!engine_loader_pickable)
to_world_log("Ignoring player picked engine")
return // Either this map doesn't use this engine loader or doesn't need one at all.
var/turf/T = get_turf(engine_loader_pickable)
if(!isturf(T))
to_world_log("[log_info_line(engine_loader_pickable)] not on a turf! Cannot place engine template.")
return
// Choose an engine type
var/datum/map_template/engine/chosen_type = null
if (LAZYLEN(config.engine_map))
var/chosen_name = pickedEngine //Instead of using the config, we'll take an argument.
chosen_type = map_templates[chosen_name]
if(!istype(chosen_type))
error("Configured engine map [chosen_name] is not a valid engine map name!")
if(!istype(chosen_type))
var/list/engine_types = list()
for(var/map in map_templates)
var/datum/map_template/engine/MT = map_templates[map]
if(istype(MT))
engine_types += MT
chosen_type = pick(engine_types)
global_announcer.autosay("Engineering has selected [chosen_type.name] as todays engine.", "Engine Constructor")
to_world_log("Chose Engine Map: [chosen_type.name]")
admin_notice("<span class='danger'>Chose Engine Map: [chosen_type.name]</span>", R_DEBUG)
// Annihilate movable atoms
engine_loader_pickable.annihilate_bounds()
//CHECK_TICK //Don't let anything else happen for now
// Actually load it
chosen_type.load(T)
sleep(1)
engine_loader_pickable.lateload_init()

View File

@@ -85,7 +85,8 @@ SUBSYSTEM_DEF(persist)
var/sql_bal = text2num("[C.department_hours[department_earning]]")
var/sql_total = text2num("[C.play_hours[department_earning]]")
var/DBQuery/query = dbcon.NewQuery("INSERT INTO vr_player_hours (ckey, department, hours, total_hours) VALUES ('[sql_ckey]', '[sql_dpt]', [sql_bal], [sql_total]) ON DUPLICATE KEY UPDATE hours = VALUES(hours), total_hours = VALUES(total_hours)")
query.Execute()
if(!query.Execute()) //CHOMPEdit
log_admin(query.ErrorMsg()) //CHOMPEdit
if (MC_TICK_CHECK)
return

View File

@@ -70,7 +70,7 @@ SUBSYSTEM_DEF(plants)
// Make sure any seed packets that were mapped in are updated
// correctly (since the seed datums did not exist a tick ago).
for(var/obj/item/seeds/S in all_seed_packs)
for(var/obj/item/seeds/S in GLOB.all_seed_packs)
S.update_seed()
//Might as well mask the gene types while we're at it.

View File

@@ -205,7 +205,8 @@ SUBSYSTEM_DEF(supply)
else if(islist(SP.access) && SP.one_access)
var/list/L = SP.access // access var is a plain var, we need a list
A.req_one_access = L.Copy()
A.req_access.Cut()
if(A.req_access) //Chompstation Edit (TODO: Figure out why the fuck this works for others but not us)
A.req_access.Cut() //Chompstation Edit
else if(islist(SP.access) && !SP.one_access)
var/list/L = SP.access
A.req_access = L.Copy()

View File

@@ -178,7 +178,7 @@ var/global/datum/controller/subsystem/ticker/ticker
if (S.name != "AI")
qdel(S)
to_world("<span class='boldannounce notice'><em>Enjoy the game!</em></span>")
world << sound('sound/AI/welcome.ogg') // Skie
world << sound('sound/AI/welcome.ogg') //CHOMPEdit: Reverted to default welcome from Yawn edit
//Holiday Round-start stuff ~Carn
Holiday_Game_Start()

View File

@@ -46,8 +46,8 @@ SUBSYSTEM_DEF(vote)
break
if(!players_are_in_round)
log_debug("The crew transfer shuttle was automatically called at vote time due to no players being present.")
init_shift_change(null, 1)
log_debug("The crew transfer shuttle would have been called at vote time due to no players being present.") //YW Edit
// init_shift_change(null, 1) //YW Edit
return
initiate_vote(VOTE_CREW_TRANSFER, "the server", 1)
@@ -221,7 +221,7 @@ SUBSYSTEM_DEF(vote)
if(ticker.current_state <= GAME_STATE_SETTING_UP)
to_chat(initiator_key, "The crew transfer button has been disabled!")
return 0
question = "Your PDA beeps with a message from Central. Would you like an additional hour to finish ongoing projects?" //VOREStation Edit
question = "Your PDA beeps with a message from Central. Would you like an additional hour to finish ongoing projects?" //Yawn Wider Edit //CHOMP EDIT: Changed to 'one' hour.
choices.Add("Initiate Crew Transfer", "Extend the Shift") //VOREStation Edit
if(VOTE_ADD_ANTAGONIST)
if(!config.allow_extra_antags || ticker.current_state >= GAME_STATE_SETTING_UP)
@@ -255,7 +255,7 @@ SUBSYSTEM_DEF(vote)
to_world("<font color='purple'><b>[text]</b>\nType <b>vote</b> or click <a href='?src=\ref[src]'>here</a> to place your votes.\nYou have [config.vote_period / 10] seconds to vote.</font>")
if(vote_type == VOTE_CREW_TRANSFER || vote_type == VOTE_GAMEMODE || vote_type == VOTE_CUSTOM)
world << sound('sound/ambience/alarm4.ogg', repeat = 0, wait = 0, volume = 50, channel = 3)
world << sound('sound/ambience/alarm4.ogg', repeat = 0, wait = 0, volume = 50, channel = 3) //CHOMPStation Edit TFF 10/5/20 - revert to old soundtrack contrary to YW
if(mode == VOTE_GAMEMODE && round_progressing)
gamemode_vote_called = TRUE

393
code/controllers/vote.dm Normal file
View File

@@ -0,0 +1,393 @@
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()
//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/subsystem/vote/fire(resumed)
if(mode)
time_remaining = round((started_time + duration - world.time)/10)
if(mode == VOTE_GAMEMODE && ticker.current_state >= GAME_STATE_SETTING_UP)
to_chat(world, "<b>Gamemode vote aborted: Game has already started.</b>")
reset()
return
if(time_remaining <= 0)
result()
reset()
/datum/controller/subsystem/vote/proc/autotransfer()
// Before doing the vote, see if anyone is playing.
// If not, just do the transfer.
var/players_are_in_round = FALSE
for(var/a in player_list) // Mobs with clients attached.
var/mob/living/L = a
if(!istype(L)) // Exclude ghosts and other weird things.
continue
if(L.stat == DEAD) // Dead mobs aren't playing.
continue
// Everything else is, however.
players_are_in_round = TRUE
break
//CHOMPStation Edit Start TFF 21/1/20 - Revert removal of auto-transfer for no transfer if people aren't in the round.
if(!players_are_in_round)
log_debug("The crew transfer shuttle was automatically called at vote time due to no players being present.")
init_shift_change(null, 1)
return
//CHOMPStation Edit End
initiate_vote(VOTE_CREW_TRANSFER, "the server", 1)
log_debug("The server has called a crew transfer vote.")
/datum/controller/subsystem/vote/proc/autogamemode()
initiate_vote(VOTE_GAMEMODE, "the server", 1)
log_debug("The server has called a gamemode vote.")
/datum/controller/subsystem/vote/proc/reset()
initiator = null
started_time = null
duration = null
time_remaining = null
mode = null
question = null
choices.Cut()
voted.Cut()
current_votes.Cut()
additional_text.Cut()
/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
if(!config.vote_no_default && choices.len) // Default-vote for everyone who didn't vote
var/non_voters = (GLOB.clients.len - total_votes)
if(non_voters > 0)
if(mode == VOTE_RESTART)
choices["Continue Playing"] += non_voters
if(choices["Continue Playing"] >= greatest_votes)
greatest_votes = choices["Continue Playing"]
else if(mode == VOTE_GAMEMODE)
if(master_mode in choices)
choices[master_mode] += non_voters
if(choices[master_mode] >= greatest_votes)
greatest_votes = choices[master_mode]
else if(mode == VOTE_CREW_TRANSFER)
var/factor = 0.5
switch(world.time / (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"] = round(choices["Initiate Crew Transfer"] * factor)
world << "<font color='#AD5AAD'>Crew Transfer Factor: [factor]</font>"
greatest_votes = max(choices["Initiate Crew Transfer"], choices["Extend the Shift"]) //VOREStation Edit
. = list() // Get all options with that many votes and return them in a list
if(greatest_votes)
for(var/option in choices)
if(choices[option] == 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 != VOTE_GAMEMODE || ticker.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(choices[current_votes[key]] == .)
round_voters += key // Keep track of who voted for the winning round.
if(mode != VOTE_GAMEMODE || . == "Extended" || ticker.hide_mode == 0) // Announce Extended gamemode, but not other gamemodes
text += "<b>Vote Result: [mode == VOTE_GAMEMODE ? gamemode_names[.] : .]</b>"
else
text += "<b>The vote has ended.</b>"
else
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
if(mode == VOTE_ADD_ANTAGONIST)
antag_add_failed = 1
log_vote(text)
to_chat(world, "<font color='#AD5AAD'>[text]</font>")
/datum/controller/subsystem/vote/proc/result()
. = announce_result()
var/restart = 0
if(.)
switch(mode)
if(VOTE_RESTART)
if(. == "Restart Round")
restart = 1
if(VOTE_GAMEMODE)
if(master_mode != .)
world.save_mode(.)
if(ticker && ticker.mode)
restart = 1
else
master_mode = .
if(VOTE_CREW_TRANSFER)
if(. == "Initiate Crew Transfer")
init_shift_change(null, 1)
if(VOTE_ADD_ANTAGONIST)
if(isnull(.) || . == "None")
antag_add_failed = 1
else
additional_antag_types |= antag_names_to_ids[.]
if(mode == VOTE_GAMEMODE) //fire this even if the vote fails.
if(!round_progressing)
round_progressing = 1
world << "<font color='red'><b>The round will start soon.</b></font>"
if(restart)
world << "World restarting due to vote..."
feedback_set_details("end_error", "restart vote")
if(blackbox)
blackbox.save_all_data_to_sql()
sleep(50)
log_game("Rebooting due to restart vote")
world.Reboot()
/datum/controller/subsystem/vote/proc/submit_vote(ckey, newVote)
if(mode)
if(config.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
return
if(current_votes[ckey])
choices[choices[current_votes[ckey]]]--
if(newVote && newVote >= 1 && newVote <= choices.len)
choices[choices[newVote]]++
current_votes[ckey] = newVote
else
current_votes[ckey] = null
/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)
if(next_allowed_time > world.time)
return 0
reset()
switch(vote_type)
if(VOTE_RESTART)
choices.Add("Restart Round", "Continue Playing")
if(VOTE_GAMEMODE)
if(ticker.current_state >= GAME_STATE_SETTING_UP)
return 0
choices.Add(config.votable_modes)
for(var/F in choices)
var/datum/game_mode/M = gamemode_cache[F]
if(!M)
continue
gamemode_names[M.config_tag] = capitalize(M.name) //It's ugly to put this here but it works
additional_text.Add("<td align = 'center'>[M.required_players]</td>")
gamemode_names["secret"] = "Secret"
if(VOTE_CREW_TRANSFER)
if(!check_rights(R_ADMIN|R_MOD, 0)) // The gods care not for the affairs of the mortals
if(get_security_level() == "red" || get_security_level() == "delta")
initiator_key << "The current alert status is too high to call for a crew transfer!"
return 0
if(ticker.current_state <= GAME_STATE_SETTING_UP)
initiator_key << "The crew transfer button has been disabled!"
return 0
question = "Your PDA beeps with a message from Central. Would you like an additional hour to finish ongoing projects?" //Yawn Wider Edit //CHOMP EDIT: Changed to 'one' hour.
choices.Add("Initiate Crew Transfer", "Extend the Shift") //VOREStation Edit
if(VOTE_ADD_ANTAGONIST)
if(!config.allow_extra_antags || ticker.current_state >= GAME_STATE_SETTING_UP)
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())
choices.Add(antag.role_text)
choices.Add("None")
if(VOTE_CUSTOM)
question = sanitizeSafe(input(usr, "What is the vote for?") as text|null)
if(!question)
return 0
for(var/i = 1 to 10)
var/option = capitalize(sanitize(input(usr, "Please enter an option or hit cancel to finish") as text|null))
if(!option || mode || !usr.client)
break
choices.Add(option)
else
return 0
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]"
log_vote(text)
world << "<font color='#AD5AAD'><b>[text]</b>\nType <b>vote</b> or click <a href='?src=\ref[src]'>here</a> to place your votes.\nYou have [config.vote_period / 10] seconds to vote.</font>"
if(vote_type == VOTE_CREW_TRANSFER || vote_type == VOTE_GAMEMODE || vote_type == VOTE_CUSTOM)
world << sound('sound/ambience/alarm4.ogg', repeat = 0, wait = 0, volume = 50, channel = 3)
if(mode == VOTE_GAMEMODE && round_progressing)
round_progressing = 0
world << "<font color='red'><b>Round start has been delayed.</b></font>"
time_remaining = round(config.vote_period / 10)
return 1
return 0
/datum/controller/subsystem/vote/proc/interface(var/client/C)
if(!istype(C))
return
var/admin = FALSE
if(C.holder)
if(C.holder.rights & R_ADMIN)
admin = TRUE
. = "<html><head><title>Voting Panel</title></head><body>"
if(mode)
if(question)
. += "<h2>Vote: '[question]'</h2>"
else
. += "<h2>Vote: [capitalize(mode)]</h2>"
. += "Time Left: [time_remaining] s<hr>"
. += "<table width = '100%'><tr><td align = 'center'><b>Choices</b></td><td align = 'center'><b>Votes</b></td>"
if(mode == VOTE_GAMEMODE)
.+= "<td align = 'center'><b>Minimum Players</b></td></tr>"
for(var/i = 1 to choices.len)
var/votes = choices[choices[i]]
if(!votes)
votes = 0
. += "<tr>"
var/thisVote = (current_votes[C.ckey] == i)
if(mode == VOTE_GAMEMODE)
. += "<td>[thisVote ? "<b>" : ""]<a href='?src=\ref[src];vote=[i]'>[gamemode_names[choices[i]]]</a>[thisVote ? "</b>" : ""]</td><td align = 'center'>[votes]</td>"
else
. += "<td>[thisVote ? "<b>" : ""]<a href='?src=\ref[src];vote=[i]'>[choices[i]]</a>[thisVote ? "</b>" : ""]</td><td align = 'center'>[votes]</td>"
if (additional_text.len >= i)
. += additional_text[i]
. += "</tr>"
. += "<tr><td><a href='?src=\ref[src];vote=unvote'>Unvote</a></td></tr>"
. += "</table><hr>"
if(admin)
. += "(<a href='?src=\ref[src];vote=cancel'>Cancel Vote</a>) "
else
. += "<h2>Start a vote:</h2><hr><ul><li>"
if(admin || config.allow_vote_restart)
. += "<a href='?src=\ref[src];vote=restart'>Restart</a>"
else
. += "<font color='grey'>Restart (Disallowed)</font>"
. += "</li><li>"
if(admin || config.allow_vote_restart)
. += "<a href='?src=\ref[src];vote=crew_transfer'>Crew Transfer</a>"
else
. += "<font color='grey'>Crew Transfer (Disallowed)</font>"
if(admin)
. += "\t(<a href='?src=\ref[src];vote=toggle_restart'>[config.allow_vote_restart ? "Allowed" : "Disallowed"]</a>)"
. += "</li><li>"
if(admin || config.allow_vote_mode)
. += "<a href='?src=\ref[src];vote=gamemode'>GameMode</a>"
else
. += "<font color='grey'>GameMode (Disallowed)</font>"
if(admin)
. += "\t(<a href='?src=\ref[src];vote=toggle_gamemode'>[config.allow_vote_mode ? "Allowed" : "Disallowed"]</a>)"
. += "</li><li>"
if(!antag_add_failed && config.allow_extra_antags)
. += "<a href='?src=\ref[src];vote=add_antagonist'>Add Antagonist Type</a>"
else
. += "<font color='grey'>Add Antagonist (Disallowed)</font>"
. += "</li>"
if(admin)
. += "<li><a href='?src=\ref[src];vote=custom'>Custom</a></li>"
. += "</ul><hr>"
. += "<a href='?src=\ref[src];vote=close' style='position:absolute;right:50px'>Close</a></body></html>"
/datum/controller/subsystem/vote/Topic(href, href_list[])
if(!usr || !usr.client)
return
switch(href_list["vote"])
if("close")
usr << browse(null, "window=vote")
return
if("cancel")
if(usr.client.holder)
reset()
if("toggle_restart")
if(usr.client.holder)
config.allow_vote_restart = !config.allow_vote_restart
if("toggle_gamemode")
if(usr.client.holder)
config.allow_vote_mode = !config.allow_vote_mode
if(VOTE_RESTART)
if(config.allow_vote_restart || usr.client.holder)
initiate_vote(VOTE_RESTART, usr.key)
if(VOTE_GAMEMODE)
if(config.allow_vote_mode || usr.client.holder)
initiate_vote(VOTE_GAMEMODE, usr.key)
if(VOTE_CREW_TRANSFER)
if(config.allow_vote_restart || usr.client.holder)
initiate_vote(VOTE_CREW_TRANSFER, usr.key)
if(VOTE_ADD_ANTAGONIST)
if(config.allow_extra_antags || usr.client.holder)
initiate_vote(VOTE_ADD_ANTAGONIST, usr.key)
if(VOTE_CUSTOM)
if(usr.client.holder)
initiate_vote(VOTE_CUSTOM, usr.key)
if("unvote")
submit_vote(usr.ckey, null)
else
var/t = round(text2num(href_list["vote"]))
if(t) // It starts from 1, so there's no problem
submit_vote(usr.ckey, t)
usr.client.vote()
/client/verb/vote()
set category = "OOC"
set name = "Vote"
if(SSvote)
src << browse(SSvote.interface(src), "window=vote;size=500x[300 + SSvote.choices.len * 25]")