mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Replaces the voting system. It should fix a pretty serious server-crashing exploit and simplify the code a fair bit.
Removed all the voting-related adminverbs. It's all built into ooc vote verb. Admins can now make custom votes for literally anything. If a vote draws it will pick one of the winners at random. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4677 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -21,8 +21,8 @@
|
|||||||
var/allow_admin_jump = 1 // allows admin jumping
|
var/allow_admin_jump = 1 // allows admin jumping
|
||||||
var/allow_admin_spawning = 1 // allows admin item spawning
|
var/allow_admin_spawning = 1 // allows admin item spawning
|
||||||
var/allow_admin_rev = 1 // allows admin revives
|
var/allow_admin_rev = 1 // allows admin revives
|
||||||
var/vote_delay = 600 // minimum time between voting sessions (seconds, 10 minute default)
|
var/vote_delay = 6000 // minimum time between voting sessions (deciseconds, 10 minute default)
|
||||||
var/vote_period = 60 // length of voting period (seconds, default 1 minute)
|
var/vote_period = 600 // length of voting period (deciseconds, default 1 minute)
|
||||||
var/vote_no_default = 0 // vote does not default to nochange/norestart (tbi)
|
var/vote_no_default = 0 // vote does not default to nochange/norestart (tbi)
|
||||||
var/vote_no_dead = 0 // dead people can't vote (tbi)
|
var/vote_no_dead = 0 // dead people can't vote (tbi)
|
||||||
// var/enable_authentication = 0 // goon authentication
|
// var/enable_authentication = 0 // goon authentication
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ datum/controller/game_controller/proc/process()
|
|||||||
var/start_time = world.timeofday
|
var/start_time = world.timeofday
|
||||||
controller_iteration++
|
controller_iteration++
|
||||||
|
|
||||||
|
vote.process()
|
||||||
|
|
||||||
//AIR
|
//AIR
|
||||||
timer = world.timeofday
|
timer = world.timeofday
|
||||||
last_thing_processed = air_master.type
|
last_thing_processed = air_master.type
|
||||||
|
|||||||
233
code/controllers/voting.dm
Normal file
233
code/controllers/voting.dm
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
var/datum/controller/vote/vote = new()
|
||||||
|
|
||||||
|
datum/controller/vote
|
||||||
|
var/initiator = null
|
||||||
|
var/started_timeofday = null
|
||||||
|
var/time_remaining = 0
|
||||||
|
var/mode = null
|
||||||
|
var/question = null
|
||||||
|
var/list/choices = list()
|
||||||
|
var/list/voted = list()
|
||||||
|
var/list/voting = list()
|
||||||
|
|
||||||
|
New()
|
||||||
|
if(vote != src)
|
||||||
|
if(istype(vote))
|
||||||
|
del(vote)
|
||||||
|
vote = src
|
||||||
|
|
||||||
|
proc/process() //called by master_controller
|
||||||
|
if(mode)
|
||||||
|
time_remaining = started_timeofday + config.vote_period
|
||||||
|
if(world.timeofday < started_timeofday)
|
||||||
|
time_remaining -= 864000
|
||||||
|
time_remaining = round((time_remaining - world.timeofday)/10)
|
||||||
|
|
||||||
|
var/i=1
|
||||||
|
if(time_remaining < 0)
|
||||||
|
result()
|
||||||
|
while(i<=voting.len)
|
||||||
|
var/client/C = voting[i]
|
||||||
|
if(C)
|
||||||
|
C << browse(null,"window=vote;can_close=0")
|
||||||
|
i++
|
||||||
|
reset()
|
||||||
|
else
|
||||||
|
while(i<=voting.len)
|
||||||
|
var/client/C = voting[i]
|
||||||
|
if(C)
|
||||||
|
C << browse(vote.interface(C),"window=vote;can_close=0")
|
||||||
|
i++
|
||||||
|
else
|
||||||
|
voting.Cut(i,i+1)
|
||||||
|
|
||||||
|
proc/reset()
|
||||||
|
initiator = null
|
||||||
|
time_remaining = 0
|
||||||
|
mode = null
|
||||||
|
question = null
|
||||||
|
choices.Cut()
|
||||||
|
voted.Cut()
|
||||||
|
voting.Cut()
|
||||||
|
|
||||||
|
proc/get_result()
|
||||||
|
//get the highest number of votes
|
||||||
|
var/greatest_votes = 0
|
||||||
|
for(var/option in choices)
|
||||||
|
var/votes = choices[option]
|
||||||
|
if(votes > greatest_votes)
|
||||||
|
greatest_votes = 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] == greatest_votes)
|
||||||
|
. += option
|
||||||
|
return .
|
||||||
|
|
||||||
|
proc/announce_result()
|
||||||
|
var/list/winners = get_result()
|
||||||
|
var/text
|
||||||
|
if(winners.len > 0)
|
||||||
|
if(winners.len > 1)
|
||||||
|
text = "<b>Vote Tied Between:</b>\n"
|
||||||
|
for(var/option in winners)
|
||||||
|
text += "\t[option]\n"
|
||||||
|
. = pick(winners)
|
||||||
|
text += "<b>Vote Result: [.]</b>"
|
||||||
|
else
|
||||||
|
text += "<b>Vote Result: Inconclusive - No Votes!</b>"
|
||||||
|
log_vote(text)
|
||||||
|
world << "<font color='purple'>[text]</font>"
|
||||||
|
return .
|
||||||
|
|
||||||
|
proc/result()
|
||||||
|
. = announce_result()
|
||||||
|
var/restart = 0
|
||||||
|
if(.)
|
||||||
|
switch(mode)
|
||||||
|
if("restart")
|
||||||
|
if(. == "Restart Round")
|
||||||
|
restart = 1
|
||||||
|
if("gamemode")
|
||||||
|
if(master_mode != .)
|
||||||
|
world.save_mode(.)
|
||||||
|
if(ticker && ticker.mode)
|
||||||
|
restart = 1
|
||||||
|
else
|
||||||
|
master_mode = .
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
return .
|
||||||
|
|
||||||
|
proc/submit_vote(var/vote)
|
||||||
|
if(mode)
|
||||||
|
if(config.vote_no_dead && usr.stat == DEAD && !usr.client.holder)
|
||||||
|
return 0
|
||||||
|
if(!(usr.ckey in voted))
|
||||||
|
if(vote && 1<=vote && vote<=choices.len)
|
||||||
|
voted += usr.ckey
|
||||||
|
choices[choices[vote]]++ //check this
|
||||||
|
return vote
|
||||||
|
return 0
|
||||||
|
|
||||||
|
proc/initiate_vote(var/vote_type, var/initiator_key)
|
||||||
|
if(!mode)
|
||||||
|
if(started_timeofday != null)
|
||||||
|
var/next_allowed_timeofday = (started_timeofday + config.vote_delay)
|
||||||
|
if(world.timeofday < started_timeofday)
|
||||||
|
next_allowed_timeofday -= 864000
|
||||||
|
if(next_allowed_timeofday > world.timeofday)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
reset()
|
||||||
|
switch(vote_type)
|
||||||
|
if("restart") choices.Add("Restart Round","Continue Playing")
|
||||||
|
if("gamemode") choices.Add(config.votable_modes)
|
||||||
|
if("custom")
|
||||||
|
question = html_encode(input(usr,"What is the vote for?") as text|null)
|
||||||
|
if(!question) return 0
|
||||||
|
for(var/i=1,i<=10,i++)
|
||||||
|
var/option = capitalize(html_encode(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_timeofday = world.timeofday
|
||||||
|
var/text = "[capitalize(mode)] vote started by [initiator]."
|
||||||
|
log_vote(text)
|
||||||
|
world << "<font color='purple'><b>[text]</b>\nType vote to place your votes.\nYou have [config.vote_period/10] seconds to vote.</font>"
|
||||||
|
time_remaining = round(config.vote_period/10)
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
proc/interface(var/client/C)
|
||||||
|
if(!C) return
|
||||||
|
var/admin = 0
|
||||||
|
if(C.holder)
|
||||||
|
admin = 1
|
||||||
|
voting |= C
|
||||||
|
|
||||||
|
. = "<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><ul>"
|
||||||
|
for(var/i=1,i<=choices.len,i++)
|
||||||
|
var/votes = choices[choices[i]]
|
||||||
|
if(!votes) votes = 0
|
||||||
|
. += "<li><a href='?src=\ref[src];vote=[i]'>[choices[i]]</a> ([votes] votes)</li>"
|
||||||
|
. += "</ul><hr>"
|
||||||
|
if(admin)
|
||||||
|
. += "(<a href='?src=\ref[src];vote=cancel'>Cancel Vote</a>) "
|
||||||
|
else
|
||||||
|
. += "<h2>Start a vote:</h2><hr><ul><li>"
|
||||||
|
//restart
|
||||||
|
if(admin || config.allow_vote_restart)
|
||||||
|
. += "<a href='?src=\ref[src];vote=restart'>Restart</a>"
|
||||||
|
else
|
||||||
|
. += "<font color='grey'>Restart (Disallowed)</font>"
|
||||||
|
if(admin)
|
||||||
|
. += "\t(<a href='?src=\ref[src];vote=toggle_restart'>[config.allow_vote_restart?"Allowed":"Disallowed"]</a>)"
|
||||||
|
. += "</li><li>"
|
||||||
|
//gamemode
|
||||||
|
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>"
|
||||||
|
//custom
|
||||||
|
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>"
|
||||||
|
return .
|
||||||
|
|
||||||
|
|
||||||
|
Topic(href,href_list[],hsrc)
|
||||||
|
if(!usr || !usr.client) return //not necessary but meh...just in-case somebody does something stupid
|
||||||
|
switch(href_list["vote"])
|
||||||
|
if("close")
|
||||||
|
voting -= usr.ckey
|
||||||
|
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("restart")
|
||||||
|
if(config.allow_vote_restart || usr.client.holder)
|
||||||
|
initiate_vote("restart",usr.key)
|
||||||
|
if("gamemode")
|
||||||
|
if(config.allow_vote_mode || usr.client.holder)
|
||||||
|
initiate_vote("gamemode",usr.key)
|
||||||
|
if("custom")
|
||||||
|
if(usr.client.holder)
|
||||||
|
initiate_vote("custom",usr.key)
|
||||||
|
else
|
||||||
|
submit_vote(round(text2num(href_list["vote"])))
|
||||||
|
usr.vote()
|
||||||
|
|
||||||
|
|
||||||
|
/mob/verb/vote()
|
||||||
|
set category = "OOC"
|
||||||
|
set name = "Vote"
|
||||||
|
|
||||||
|
if(vote)
|
||||||
|
src << browse(vote.interface(client),"window=vote;can_close=0")
|
||||||
@@ -1,353 +0,0 @@
|
|||||||
/datum/vote
|
|
||||||
var/voting = 0 // true if currently voting
|
|
||||||
var/nextvotetime = 0 // time at which next vote can be started
|
|
||||||
var/votetime = 60 // time at which voting will end
|
|
||||||
var/mode = 0 // 0 = restart vote, 1 = mode vote
|
|
||||||
// modes which can be voted for
|
|
||||||
var/winner = null // the vote winner
|
|
||||||
|
|
||||||
/datum/vote/New()
|
|
||||||
|
|
||||||
nextvotetime = world.timeofday // + 10*config.vote_delay
|
|
||||||
|
|
||||||
|
|
||||||
/datum/vote/proc/canvote()//marker1
|
|
||||||
var/excess = world.timeofday - vote.nextvotetime
|
|
||||||
|
|
||||||
if(excess < -10000) // handle clock-wrapping problems - very long delay (>20 hrs) if wrapped
|
|
||||||
vote.nextvotetime = world.timeofday
|
|
||||||
return 1
|
|
||||||
return (excess >= 0)
|
|
||||||
|
|
||||||
/datum/vote/proc/nextwait()
|
|
||||||
return timetext( round( (nextvotetime - world.timeofday)/10) )
|
|
||||||
|
|
||||||
/datum/vote/proc/endwait()
|
|
||||||
return timetext( round( (votetime - world.timeofday)/10) )
|
|
||||||
|
|
||||||
/datum/vote/proc/timetext(var/interval)
|
|
||||||
var/minutes = round(interval / 60)
|
|
||||||
var/seconds = round(interval % 60)
|
|
||||||
|
|
||||||
var/tmin = "[minutes>0?num2text(minutes)+"min":null]"
|
|
||||||
var/tsec = "[seconds>0?num2text(seconds)+"sec":null]"
|
|
||||||
|
|
||||||
if(tmin && tsec) // hack to skip inter-space if either field is blank
|
|
||||||
return "[tmin] [tsec]"
|
|
||||||
else
|
|
||||||
if(!tmin && !tsec) // return '0sec' if 0 time left
|
|
||||||
return "0sec"
|
|
||||||
return "[tmin][tsec]"
|
|
||||||
|
|
||||||
/datum/vote/proc/getvotes()
|
|
||||||
var/list/L = list()
|
|
||||||
for(var/mob/M in player_list)
|
|
||||||
if(M.client && M.client.inactivity < 1200) // clients inactive for 2 minutes don't count
|
|
||||||
L[M.client.vote] += 1
|
|
||||||
|
|
||||||
return L
|
|
||||||
|
|
||||||
|
|
||||||
/datum/vote/proc/endvote()
|
|
||||||
|
|
||||||
if(!voting) // means that voting was aborted by an admin
|
|
||||||
return
|
|
||||||
|
|
||||||
world << "\red <B>***Voting has closed.</B>"
|
|
||||||
|
|
||||||
log_vote("Voting closed, result was [winner]")
|
|
||||||
voting = 0
|
|
||||||
nextvotetime = world.timeofday + 10*config.vote_delay
|
|
||||||
|
|
||||||
for(var/mob/M in player_list) // clear vote window from all clients
|
|
||||||
if(M.client)
|
|
||||||
M << browse(null, "window=vote")
|
|
||||||
M.client.showvote = 0
|
|
||||||
|
|
||||||
calcwin()
|
|
||||||
|
|
||||||
if(mode)
|
|
||||||
if(!ticker)
|
|
||||||
if(!going)
|
|
||||||
world << "<B>The game will start soon.</B>"
|
|
||||||
going = 1
|
|
||||||
var/wintext = capitalize(winner)
|
|
||||||
if(winner=="default")
|
|
||||||
world << "Result is \red No change."
|
|
||||||
return
|
|
||||||
|
|
||||||
// otherwise change mode
|
|
||||||
|
|
||||||
|
|
||||||
world << "Result is change to \red [wintext]"
|
|
||||||
world.save_mode(winner)
|
|
||||||
|
|
||||||
if(ticker && ticker.mode)
|
|
||||||
world <<"\red <B>World will reboot in 10 seconds</B>"
|
|
||||||
|
|
||||||
feedback_set_details("end_error","mode vote - [winner]")
|
|
||||||
|
|
||||||
if(blackbox)
|
|
||||||
blackbox.save_all_data_to_sql()
|
|
||||||
|
|
||||||
sleep(100)
|
|
||||||
log_game("Rebooting due to mode vote")
|
|
||||||
world.Reboot()
|
|
||||||
else
|
|
||||||
master_mode = winner
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
if(winner=="default")
|
|
||||||
world << "Result is \red No restart."
|
|
||||||
return
|
|
||||||
|
|
||||||
world << "Result is \red Restart round."
|
|
||||||
|
|
||||||
world <<"\red <B>World will reboot in 5 seconds</B>"
|
|
||||||
|
|
||||||
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()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
/datum/vote/proc/calcwin()
|
|
||||||
|
|
||||||
var/list/votes = getvotes()
|
|
||||||
|
|
||||||
if(vote.mode)
|
|
||||||
var/best = -1
|
|
||||||
|
|
||||||
for(var/v in votes)
|
|
||||||
if(v=="none")
|
|
||||||
continue
|
|
||||||
if(best < votes[v])
|
|
||||||
best = votes[v]
|
|
||||||
|
|
||||||
|
|
||||||
var/list/winners = list()
|
|
||||||
|
|
||||||
for(var/v in votes)
|
|
||||||
if(votes[v] == best)
|
|
||||||
winners += v
|
|
||||||
|
|
||||||
var/ret = ""
|
|
||||||
|
|
||||||
|
|
||||||
for(var/w in winners)
|
|
||||||
if(lentext(ret) > 0)
|
|
||||||
ret += "/"
|
|
||||||
if(w=="default")
|
|
||||||
winners = list("default")
|
|
||||||
ret = "No change"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
ret += capitalize(w)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(winners.len != 1)
|
|
||||||
ret = "Tie: " + ret
|
|
||||||
|
|
||||||
|
|
||||||
if(winners.len == 0)
|
|
||||||
vote.winner = "default"
|
|
||||||
ret = "No change"
|
|
||||||
else
|
|
||||||
vote.winner = pick(winners)
|
|
||||||
|
|
||||||
return ret
|
|
||||||
else
|
|
||||||
|
|
||||||
if(votes["default"] < votes["restart"])
|
|
||||||
|
|
||||||
vote.winner = "restart"
|
|
||||||
return "Restart"
|
|
||||||
else
|
|
||||||
vote.winner = "default"
|
|
||||||
return "No restart"
|
|
||||||
|
|
||||||
|
|
||||||
/mob/verb/vote()
|
|
||||||
set category = "OOC"
|
|
||||||
set name = "Vote"
|
|
||||||
usr.client.showvote = 1
|
|
||||||
|
|
||||||
|
|
||||||
var/text = "<HTML><HEAD><TITLE>Voting</TITLE></HEAD><BODY scroll=no>"
|
|
||||||
|
|
||||||
var/footer = "<HR><A href='?src=\ref[vote];vclose=1'>Close</A></BODY></HTML>"
|
|
||||||
|
|
||||||
|
|
||||||
if(config.vote_no_dead && usr.stat == 2)
|
|
||||||
text += "Voting while dead has been disallowed."
|
|
||||||
text += footer
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
usr.client.showvote = 0
|
|
||||||
usr.client.vote = "none"
|
|
||||||
return
|
|
||||||
|
|
||||||
if(vote.voting)
|
|
||||||
// vote in progress, do the current
|
|
||||||
|
|
||||||
text += "Vote to [vote.mode?"change mode":"restart round"] in progress.<BR>"
|
|
||||||
text += "[vote.endwait()] until voting is closed.<BR>"
|
|
||||||
|
|
||||||
var/list/votes = vote.getvotes()
|
|
||||||
|
|
||||||
if(vote.mode) // true if changing mode
|
|
||||||
|
|
||||||
text += "Current game mode is: <B>[master_mode]</B>.<BR>Select the mode to change to:<UL>"
|
|
||||||
|
|
||||||
for(var/md in config.votable_modes)
|
|
||||||
var/disp = capitalize(md)
|
|
||||||
if(md=="default")
|
|
||||||
disp = "No change"
|
|
||||||
|
|
||||||
//world << "[md]|[disp]|[src.client.vote]|[votes[md]]"
|
|
||||||
|
|
||||||
if(src.client.vote == md)
|
|
||||||
text += "<LI><B>[disp]</B>"
|
|
||||||
else
|
|
||||||
text += "<LI><A href='?src=\ref[vote];vote=[md]'>[disp]</A>"
|
|
||||||
|
|
||||||
text += "[votes[md]>0?" - [votes[md]] vote\s":null]<BR>"
|
|
||||||
|
|
||||||
text += "</UL>"
|
|
||||||
|
|
||||||
text +="<p>Current winner: <B>[vote.calcwin()]</B><BR>"
|
|
||||||
|
|
||||||
text += footer
|
|
||||||
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
|
|
||||||
else // voting to restart
|
|
||||||
|
|
||||||
text += "Restart the world?<BR><UL>"
|
|
||||||
|
|
||||||
var/list/VL = list("default","restart")
|
|
||||||
|
|
||||||
for(var/md in VL)
|
|
||||||
var/disp = (md=="default"? "No":"Yes")
|
|
||||||
|
|
||||||
if(src.client.vote == md)
|
|
||||||
text += "<LI><B>[disp]</B>"
|
|
||||||
else
|
|
||||||
text += "<LI><A href='?src=\ref[vote];vote=[md]'>[disp]</A>"
|
|
||||||
|
|
||||||
text += "[votes[md]>0?" - [votes[md]] vote\s":null]<BR>"
|
|
||||||
|
|
||||||
text += "</UL>"
|
|
||||||
|
|
||||||
text +="<p>Current winner: <B>[vote.calcwin()]</B><BR>"
|
|
||||||
|
|
||||||
text += footer
|
|
||||||
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
|
|
||||||
|
|
||||||
else //no vote in progress
|
|
||||||
|
|
||||||
if(shuttlecoming == 1)
|
|
||||||
usr << "\blue Cannot start Vote - Shuttle has been called."
|
|
||||||
return
|
|
||||||
|
|
||||||
if(!config.allow_vote_restart && !config.allow_vote_mode)
|
|
||||||
text += "<P>Player voting is disabled.</BODY></HTML>"
|
|
||||||
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
usr.client.showvote = 0
|
|
||||||
return
|
|
||||||
|
|
||||||
if(!vote.canvote()) // not time to vote yet
|
|
||||||
if(config.allow_vote_restart) text+="Voting to restart is enabled.<BR>"
|
|
||||||
if(config.allow_vote_mode) text+="Voting to change mode is enabled.<BR>"
|
|
||||||
|
|
||||||
text+="<BR><P>Next vote can begin in [vote.nextwait()]."
|
|
||||||
text+=footer
|
|
||||||
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
|
|
||||||
else // voting can begin
|
|
||||||
if(config.allow_vote_restart)
|
|
||||||
text += "<A href='?src=\ref[vote];vmode=1'>Begin restart vote.</A><BR>"
|
|
||||||
if(config.allow_vote_mode)
|
|
||||||
text += "<A href='?src=\ref[vote];vmode=2'>Begin change mode vote.</A><BR>"
|
|
||||||
|
|
||||||
text += footer
|
|
||||||
usr << browse(text, "window=vote")
|
|
||||||
|
|
||||||
spawn(20)
|
|
||||||
if(usr.client && usr.client.showvote)
|
|
||||||
usr.vote()
|
|
||||||
else
|
|
||||||
usr << browse(null, "window=vote")
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
/datum/vote/Topic(href, href_list)
|
|
||||||
..()
|
|
||||||
//world << "[usr] has activated the vote Topic"
|
|
||||||
|
|
||||||
if(href_list["voter"])
|
|
||||||
world << "[usr.ckey] has attempted to bypass the voting system." //ckey is easy key
|
|
||||||
return
|
|
||||||
|
|
||||||
if(href_list["vclose"])
|
|
||||||
|
|
||||||
if(usr)
|
|
||||||
usr << browse(null, "window=vote")
|
|
||||||
usr.client.showvote = 0
|
|
||||||
return
|
|
||||||
|
|
||||||
if(href_list["vmode"])
|
|
||||||
if(vote.voting)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(!vote.canvote() ) // double check even though this shouldn't happen
|
|
||||||
return
|
|
||||||
|
|
||||||
vote.mode = text2num(href_list["vmode"])-1 // hack to yield 0=restart, 1=changemode
|
|
||||||
if(!ticker && vote.mode == 1)
|
|
||||||
if(going)
|
|
||||||
world << "<B>The game start has been delayed.</B>"
|
|
||||||
going = 0
|
|
||||||
vote.voting = 1 // now voting
|
|
||||||
vote.votetime = world.timeofday + config.vote_period*10 // when the vote will end
|
|
||||||
|
|
||||||
spawn(config.vote_period*10)
|
|
||||||
vote.endvote()
|
|
||||||
|
|
||||||
world << "\red<B>*** A vote to [vote.mode?"change game mode":"restart"] has been initiated by [usr.key].</B>"
|
|
||||||
world << "\red You have [vote.timetext(config.vote_period)] to vote."
|
|
||||||
|
|
||||||
log_vote("Voting to [vote.mode ? "change mode" : "restart round"] started by [usr.name]/[usr.key]")
|
|
||||||
|
|
||||||
for(var/mob/CM in player_list)
|
|
||||||
if(CM.client)
|
|
||||||
if( config.vote_no_default || (config.vote_no_dead && CM.stat == 2) )
|
|
||||||
CM.client.vote = "none"
|
|
||||||
else
|
|
||||||
CM.client.vote = "default"
|
|
||||||
|
|
||||||
if(usr) usr.vote()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
if(href_list["vote"] && vote.voting)
|
|
||||||
if(usr)
|
|
||||||
usr.client.vote = href_list["vote"]
|
|
||||||
|
|
||||||
//world << "Setting client [usr.key]'s vote to: [href_list["vote"]]."
|
|
||||||
|
|
||||||
usr.vote()
|
|
||||||
return
|
|
||||||
@@ -111,7 +111,6 @@ var/list/alldirs = list(NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAS
|
|||||||
|
|
||||||
var/datum/station_state/start_state = null
|
var/datum/station_state/start_state = null
|
||||||
var/datum/configuration/config = null
|
var/datum/configuration/config = null
|
||||||
var/datum/vote/vote = null
|
|
||||||
var/datum/sun/sun = null
|
var/datum/sun/sun = null
|
||||||
|
|
||||||
var/list/combatlog = list()
|
var/list/combatlog = list()
|
||||||
|
|||||||
@@ -1437,14 +1437,6 @@ var/global/BSACooldown = 0
|
|||||||
return create_mob(usr)
|
return create_mob(usr)
|
||||||
else
|
else
|
||||||
alert("You are not a high enough administrator! Sorry!!!!")
|
alert("You are not a high enough administrator! Sorry!!!!")
|
||||||
if (href_list["vmode"])
|
|
||||||
vmode()
|
|
||||||
|
|
||||||
if (href_list["votekill"])
|
|
||||||
votekill()
|
|
||||||
|
|
||||||
if (href_list["voteres"])
|
|
||||||
voteres()
|
|
||||||
|
|
||||||
if (href_list["prom_demot"])
|
if (href_list["prom_demot"])
|
||||||
if ((src.rank in list("Trial Admin", "Badmin", "Game Admin", "Game Master" )))
|
if ((src.rank in list("Trial Admin", "Badmin", "Game Admin", "Game Master" )))
|
||||||
@@ -2973,135 +2965,12 @@ var/global/BSACooldown = 0
|
|||||||
usr << browse(dat, "window=secrets")
|
usr << browse(dat, "window=secrets")
|
||||||
return
|
return
|
||||||
|
|
||||||
/obj/admins/proc/Voting()
|
|
||||||
|
|
||||||
var/dat
|
|
||||||
var/lvl = 0
|
|
||||||
switch(src.rank)
|
|
||||||
if("Moderator")
|
|
||||||
lvl = 1
|
|
||||||
if("Temporary Admin")
|
|
||||||
lvl = 2
|
|
||||||
if("Admin Candidate")
|
|
||||||
lvl = 3
|
|
||||||
if("Trial Admin")
|
|
||||||
lvl = 4
|
|
||||||
if("Badmin")
|
|
||||||
lvl = 5
|
|
||||||
if("Game Admin")
|
|
||||||
lvl = 6
|
|
||||||
if("Game Master")
|
|
||||||
lvl = 7
|
|
||||||
|
|
||||||
|
|
||||||
dat += "<center><B>Voting</B></center><hr>\n"
|
|
||||||
|
|
||||||
if(lvl > 0)
|
|
||||||
// if(lvl >= 2 )
|
|
||||||
dat += {"
|
|
||||||
<A href='?src=\ref[src];votekill=1'>Abort Vote</A><br>
|
|
||||||
<A href='?src=\ref[src];vmode=1'>Start Vote</A><br>
|
|
||||||
<A href='?src=\ref[src];voteres=1'>Toggle Voting</A><br>
|
|
||||||
"}
|
|
||||||
|
|
||||||
// if(lvl >= 3 )
|
|
||||||
// if(lvl >= 5)
|
|
||||||
// if(lvl == 6 )
|
|
||||||
|
|
||||||
usr << browse(dat, "window=admin2;size=210x160")
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////admins2.dm merge
|
/////////////////////////////////////////////////////////////////////////////////////////////////admins2.dm merge
|
||||||
//i.e. buttons/verbs
|
//i.e. buttons/verbs
|
||||||
|
|
||||||
|
|
||||||
/obj/admins/proc/vmode()
|
|
||||||
set category = "Server"
|
|
||||||
set name = "Start Vote"
|
|
||||||
set desc="Starts vote"
|
|
||||||
if (!usr.client.holder)
|
|
||||||
return
|
|
||||||
var/confirm = alert("What vote would you like to start?", "Vote", "Restart", "Change Game Mode", "Cancel")
|
|
||||||
if(confirm == "Cancel")
|
|
||||||
return
|
|
||||||
if(confirm == "Restart")
|
|
||||||
vote.mode = 0
|
|
||||||
// hack to yield 0=restart, 1=changemode
|
|
||||||
if(confirm == "Change Game Mode")
|
|
||||||
vote.mode = 1
|
|
||||||
if(!ticker)
|
|
||||||
if(going)
|
|
||||||
world << "<B>The game start has been delayed.</B>"
|
|
||||||
going = 0
|
|
||||||
vote.voting = 1
|
|
||||||
// now voting
|
|
||||||
vote.votetime = world.timeofday + config.vote_period*10
|
|
||||||
// when the vote will end
|
|
||||||
spawn(config.vote_period*10)
|
|
||||||
vote.endvote()
|
|
||||||
world << "\red<B>*** A vote to [vote.mode?"change game mode":"restart"] has been initiated by Admin [usr.key].</B>"
|
|
||||||
world << "\red You have [vote.timetext(config.vote_period)] to vote."
|
|
||||||
|
|
||||||
log_admin("Voting to [vote.mode?"change mode":"restart round"] forced by admin [key_name(usr)]")
|
|
||||||
|
|
||||||
for(var/mob/CM in player_list)
|
|
||||||
if(config.vote_no_default || (config.vote_no_dead && CM.stat == 2))
|
|
||||||
CM.client.vote = "none"
|
|
||||||
else
|
|
||||||
CM.client.vote = "default"
|
|
||||||
|
|
||||||
for(var/mob/CM in player_list)
|
|
||||||
if(config.vote_no_default || (config.vote_no_dead && CM.stat == 2))
|
|
||||||
CM.client.vote = "none"
|
|
||||||
else
|
|
||||||
CM.client.vote = "default"
|
|
||||||
feedback_add_details("admin_verb","SV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
||||||
|
|
||||||
/obj/admins/proc/votekill()
|
|
||||||
set category = "Server"
|
|
||||||
set name = "Abort Vote"
|
|
||||||
set desc="Aborts a vote"
|
|
||||||
if(vote.voting == 0)
|
|
||||||
alert("No votes in progress")
|
|
||||||
return
|
|
||||||
world << "\red <b>*** Voting aborted by [usr.client.stealth ? "Admin Candidate" : usr.key].</b>"
|
|
||||||
|
|
||||||
log_admin("Voting aborted by [key_name(usr)]")
|
|
||||||
|
|
||||||
vote.voting = 0
|
|
||||||
vote.nextvotetime = world.timeofday + 10*config.vote_delay
|
|
||||||
|
|
||||||
for(var/mob/M in player_list)
|
|
||||||
// clear vote window from all clients
|
|
||||||
M << browse(null, "window=vote")
|
|
||||||
M.client.showvote = 0
|
|
||||||
feedback_add_details("admin_verb","AV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
||||||
|
|
||||||
/obj/admins/proc/voteres()
|
|
||||||
set category = "Server"
|
|
||||||
set name = "Toggle Voting"
|
|
||||||
set desc="Toggles Votes"
|
|
||||||
var/confirm = alert("What vote would you like to toggle?", "Vote", "Restart [config.allow_vote_restart ? "Off" : "On"]", "Change Game Mode [config.allow_vote_mode ? "Off" : "On"]", "Cancel")
|
|
||||||
if(confirm == "Cancel")
|
|
||||||
return
|
|
||||||
if(confirm == "Restart [config.allow_vote_restart ? "Off" : "On"]")
|
|
||||||
config.allow_vote_restart = !config.allow_vote_restart
|
|
||||||
world << "<b>Player restart voting toggled to [config.allow_vote_restart ? "On" : "Off"]</b>."
|
|
||||||
log_admin("Restart voting toggled to [config.allow_vote_restart ? "On" : "Off"] by [key_name(usr)].")
|
|
||||||
|
|
||||||
if(config.allow_vote_restart)
|
|
||||||
vote.nextvotetime = world.timeofday
|
|
||||||
if(confirm == "Change Game Mode [config.allow_vote_mode ? "Off" : "On"]")
|
|
||||||
config.allow_vote_mode = !config.allow_vote_mode
|
|
||||||
world << "<b>Player mode voting toggled to [config.allow_vote_mode ? "On" : "Off"]</b>."
|
|
||||||
log_admin("Mode voting toggled to [config.allow_vote_mode ? "On" : "Off"] by [key_name(usr)].")
|
|
||||||
|
|
||||||
if(config.allow_vote_mode)
|
|
||||||
vote.nextvotetime = world.timeofday
|
|
||||||
feedback_add_details("admin_verb","TV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
||||||
|
|
||||||
/obj/admins/proc/restart()
|
/obj/admins/proc/restart()
|
||||||
set category = "Server"
|
set category = "Server"
|
||||||
set name = "Restart"
|
set name = "Restart"
|
||||||
|
|||||||
@@ -117,9 +117,6 @@
|
|||||||
verbs += /obj/admins/proc/toggleguests //Toggle guests entering
|
verbs += /obj/admins/proc/toggleguests //Toggle guests entering
|
||||||
verbs += /obj/admins/proc/toggleooc //toggle ooc
|
verbs += /obj/admins/proc/toggleooc //toggle ooc
|
||||||
verbs += /obj/admins/proc/toggleoocdead //toggle ooc for dead/unc
|
verbs += /obj/admins/proc/toggleoocdead //toggle ooc for dead/unc
|
||||||
verbs += /obj/admins/proc/voteres //toggle votes
|
|
||||||
verbs += /obj/admins/proc/vmode
|
|
||||||
verbs += /obj/admins/proc/votekill
|
|
||||||
verbs += /obj/admins/proc/show_player_panel
|
verbs += /obj/admins/proc/show_player_panel
|
||||||
verbs += /client/proc/deadchat //toggles deadchat
|
verbs += /client/proc/deadchat //toggles deadchat
|
||||||
//verbs += /client/proc/cmd_admin_mute --was never used (according to stats trackind) - use show player panel --erro
|
//verbs += /client/proc/cmd_admin_mute --was never used (according to stats trackind) - use show player panel --erro
|
||||||
@@ -136,7 +133,6 @@
|
|||||||
verbs += /client/proc/unban_panel
|
verbs += /client/proc/unban_panel
|
||||||
verbs += /client/proc/jobbans
|
verbs += /client/proc/jobbans
|
||||||
verbs += /client/proc/unjobban_panel
|
verbs += /client/proc/unjobban_panel
|
||||||
verbs += /client/proc/voting
|
|
||||||
verbs += /client/proc/hide_verbs
|
verbs += /client/proc/hide_verbs
|
||||||
verbs += /client/proc/general_report
|
verbs += /client/proc/general_report
|
||||||
verbs += /client/proc/air_report
|
verbs += /client/proc/air_report
|
||||||
@@ -290,8 +286,6 @@
|
|||||||
/client/proc/clear_admin_verbs()
|
/client/proc/clear_admin_verbs()
|
||||||
deadchat = 0
|
deadchat = 0
|
||||||
|
|
||||||
verbs -= /obj/admins/proc/vmode
|
|
||||||
verbs -= /obj/admins/proc/votekill
|
|
||||||
verbs -= /obj/admins/proc/announce
|
verbs -= /obj/admins/proc/announce
|
||||||
verbs -= /obj/admins/proc/startnow
|
verbs -= /obj/admins/proc/startnow
|
||||||
verbs -= /obj/admins/proc/toggleAI //Toggle the AI
|
verbs -= /obj/admins/proc/toggleAI //Toggle the AI
|
||||||
@@ -299,7 +293,6 @@
|
|||||||
verbs -= /obj/admins/proc/toggleguests //Toggle guests entering
|
verbs -= /obj/admins/proc/toggleguests //Toggle guests entering
|
||||||
verbs -= /obj/admins/proc/toggleooc //toggle ooc
|
verbs -= /obj/admins/proc/toggleooc //toggle ooc
|
||||||
verbs -= /obj/admins/proc/toggleoocdead //toggle ooc for dead/unc
|
verbs -= /obj/admins/proc/toggleoocdead //toggle ooc for dead/unc
|
||||||
verbs -= /obj/admins/proc/voteres //toggle votes
|
|
||||||
verbs -= /obj/admins/proc/delay //game start delay
|
verbs -= /obj/admins/proc/delay //game start delay
|
||||||
verbs -= /obj/admins/proc/immreboot //immediate reboot
|
verbs -= /obj/admins/proc/immreboot //immediate reboot
|
||||||
verbs -= /obj/admins/proc/restart //restart
|
verbs -= /obj/admins/proc/restart //restart
|
||||||
@@ -383,7 +376,6 @@
|
|||||||
verbs -= /client/proc/unban_panel
|
verbs -= /client/proc/unban_panel
|
||||||
verbs -= /client/proc/jobbans
|
verbs -= /client/proc/jobbans
|
||||||
verbs -= /client/proc/unjobban_panel
|
verbs -= /client/proc/unjobban_panel
|
||||||
verbs -= /client/proc/voting
|
|
||||||
verbs -= /client/proc/hide_verbs
|
verbs -= /client/proc/hide_verbs
|
||||||
verbs -= /client/proc/general_report
|
verbs -= /client/proc/general_report
|
||||||
verbs -= /client/proc/air_report
|
verbs -= /client/proc/air_report
|
||||||
@@ -546,13 +538,6 @@
|
|||||||
feedback_add_details("admin_verb","S") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
feedback_add_details("admin_verb","S") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||||
return
|
return
|
||||||
|
|
||||||
/client/proc/voting()
|
|
||||||
set name = "Voting"
|
|
||||||
set category = "Admin"
|
|
||||||
if (holder)
|
|
||||||
holder.Voting()
|
|
||||||
feedback_add_details("admin_verb","VO") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
|
||||||
|
|
||||||
/client/proc/colorooc()
|
/client/proc/colorooc()
|
||||||
set category = "Fun"
|
set category = "Fun"
|
||||||
set name = "OOC Text Color"
|
set name = "OOC Text Color"
|
||||||
|
|||||||
@@ -36,8 +36,6 @@
|
|||||||
var/team = null
|
var/team = null
|
||||||
var/be_alien = 0 //Check if that guy wants to be an alien
|
var/be_alien = 0 //Check if that guy wants to be an alien
|
||||||
var/be_pai = 1 //Consider client when searching for players to recruit as a pAI
|
var/be_pai = 1 //Consider client when searching for players to recruit as a pAI
|
||||||
var/vote = null
|
|
||||||
var/showvote = null
|
|
||||||
var/activeslot = 1 //Default active slot!
|
var/activeslot = 1 //Default active slot!
|
||||||
var/STFU_ghosts //80+ people rounds are fun to admin when text flies faster than airport security
|
var/STFU_ghosts //80+ people rounds are fun to admin when text flies faster than airport security
|
||||||
var/STFU_radio //80+ people rounds are fun to admin when text flies faster than airport security
|
var/STFU_radio //80+ people rounds are fun to admin when text flies faster than airport security
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
makepowernets()
|
makepowernets()
|
||||||
|
|
||||||
sun = new /datum/sun()
|
sun = new /datum/sun()
|
||||||
vote = new /datum/vote()
|
|
||||||
radio_controller = new /datum/controller/radio()
|
radio_controller = new /datum/controller/radio()
|
||||||
data_core = new /obj/effect/datacore()
|
data_core = new /obj/effect/datacore()
|
||||||
paiController = new /datum/paiController()
|
paiController = new /datum/paiController()
|
||||||
|
|||||||
@@ -86,11 +86,11 @@ ALLOW_METADATA
|
|||||||
## allow players to initate a mode-change start
|
## allow players to initate a mode-change start
|
||||||
#ALLOW_VOTE_MODE
|
#ALLOW_VOTE_MODE
|
||||||
|
|
||||||
## min delay (seconds) between voting sessions (default 10 minutes)
|
## min delay (deciseconds) between voting sessions (default 10 minutes)
|
||||||
VOTE_DELAY 600
|
VOTE_DELAY 6000
|
||||||
|
|
||||||
## time period (seconds) which voting session will last (default 1 minute)
|
## time period (deciseconds) which voting session will last (default 1 minute)
|
||||||
VOTE_PERIOD 60
|
VOTE_PERIOD 600
|
||||||
|
|
||||||
## prevents dead players from voting or starting votes
|
## prevents dead players from voting or starting votes
|
||||||
# NO_DEAD_VOTE
|
# NO_DEAD_VOTE
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
#include "code\controllers\master_controller.dm"
|
#include "code\controllers\master_controller.dm"
|
||||||
#include "code\controllers\shuttle_controller.dm"
|
#include "code\controllers\shuttle_controller.dm"
|
||||||
#include "code\controllers\verbs.dm"
|
#include "code\controllers\verbs.dm"
|
||||||
|
#include "code\controllers\voting.dm"
|
||||||
#include "code\datums\ai_laws.dm"
|
#include "code\datums\ai_laws.dm"
|
||||||
#include "code\datums\computerfiles.dm"
|
#include "code\datums\computerfiles.dm"
|
||||||
#include "code\datums\datacore.dm"
|
#include "code\datums\datacore.dm"
|
||||||
@@ -64,7 +65,6 @@
|
|||||||
#include "code\datums\spell.dm"
|
#include "code\datums\spell.dm"
|
||||||
#include "code\datums\sun.dm"
|
#include "code\datums\sun.dm"
|
||||||
#include "code\datums\supplypacks.dm"
|
#include "code\datums\supplypacks.dm"
|
||||||
#include "code\datums\vote.dm"
|
|
||||||
#include "code\datums\diseases\alien_embryo.dm"
|
#include "code\datums\diseases\alien_embryo.dm"
|
||||||
#include "code\datums\diseases\appendicitis.dm"
|
#include "code\datums\diseases\appendicitis.dm"
|
||||||
#include "code\datums\diseases\beesease.dm"
|
#include "code\datums\diseases\beesease.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user