Skip to content

Commit

Permalink
Fix map vote rigging and add a verb to force next map before the vote…
Browse files Browse the repository at this point in the history
… is even called.
  • Loading branch information
d3athrow committed Jan 17, 2024
1 parent 8b7f7df commit 5501cc3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ var/list/admin_verbs_fun = list(
/client/proc/view_all_rods,
/client/proc/add_centcomm_order,
/client/proc/apes,
/client/proc/force_next_map,
)
var/list/admin_verbs_spawn = list(
/datum/admins/proc/spawn_atom, // Allows us to spawn instances
Expand Down
28 changes: 28 additions & 0 deletions code/modules/admin/verbs/debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1513,3 +1513,31 @@ var/obj/blend_test = null
log_admin("[key_name(usr)] has edited the message of the day. The new text is as follows: [newmotd].")
feedback_add_details("admin_verb", "Edit MotD")
message_admins("[key_name(usr)] has edited the message of the day. Check the game log for the full text.")

/client/proc/force_next_map()
set category = "Server"
set name = "Force Next Map"
set desc = "Sets the next map and skips the map vote."

if(!check_rights(R_FUN))
return

var/list/all_maps = get_all_maps()
all_maps += "RESET"
to_chat(usr,"<span class='warning'>This needs to be done BEFORE a map vote is called otherwise use the vote rigging option!</div>")
var/rigged_choice = input(usr, "Pick a map.") as null|anything in all_maps
if(!rigged_choice)
return
if(rigged_choice == "RESET")
log_admin("[key_name(usr)] has reset the forced map.")
feedback_add_details("admin_verb", "Force Next Map")
message_admins("[key_name(usr)] has reset the forced map.")
vote.forced_map = null
return
log_admin("[key_name(usr)] has forced the next map. The new map is: [rigged_choice].")
feedback_add_details("admin_verb", "Force Next Map")
message_admins("[key_name(usr)] has forced the next map. The new map is: [rigged_choice].")

vote.forced_map = rigged_choice


16 changes: 13 additions & 3 deletions code/modules/html_interface/voting/voting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ var/global/datum/controller/vote/vote = new()
var/lock = FALSE
name = "datum"

var/forced_map = null

/datum/controller/vote/New()
. = ..()
src.voters = list()
Expand Down Expand Up @@ -249,7 +251,8 @@ var/global/datum/controller/vote/vote = new()
init_shift_change(null, 1)
if("map")
//logging
watchdog.map_path = map_paths[winner]
var/map_choice = forced_map ? forced_map : winner
watchdog.map_path = map_paths[map_choice]
log_game("Players voted and chose.... [watchdog.map_path]!")

if(restart)
Expand Down Expand Up @@ -371,7 +374,7 @@ var/global/datum/controller/vote/vote = new()
if(!choices.len)
to_chat(world, "<span class='danger'>Failed to initiate map vote, no maps found.</span>")
return 0
map_paths = maps
map_paths = get_all_maps()
var/msg = "A map vote was initiated with these options: [english_list(get_list_of_keys(maps))]."
send2maindiscord(msg)
send2mainirc(msg)
Expand Down Expand Up @@ -556,7 +559,13 @@ var/global/datum/controller/vote/vote = new()
to_chat(user, "<span class='notice'> You can't do that!")
if("map")
if(user.client.holder)
initiate_vote("map",user.client.key)
switch(alert("Notice: early map votes are not necessary to force the next map anymore","Map Vote?", "Continue","Cancel"))
if("Continue")
initiate_vote("map",user.client.key)
else
update()
user.vote()
return
else if(!length(admins) && !living_players)
initiate_vote("map",user.client.key)
else
Expand Down Expand Up @@ -603,6 +612,7 @@ var/global/datum/controller/vote/vote = new()
rigged_choice = input(usr,"Add a result.","Add a result","") as text|null
if(!rigged_choice)
return
if(!(rigged_choice in choices)) choices += rigged_choice
tally[rigged_choice] = ARBITRARILY_LARGE_NUMBER
message_admins("Admin [key_name_admin(usr)] rigged the vote for [rigged_choice].")
log_admin("Admin [key_name(usr)] rigged the vote for [rigged_choice].")
5 changes: 3 additions & 2 deletions code/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ var/auxtools_path
..()
return

if(vote.winner && vote.map_paths)
if((vote.winner || vote.forced_map) && vote.map_paths)
//get filename
var/filename = "vgstation13.dmb"
var/map_path = "maps/voting/" + vote.map_paths[vote.winner] + "/" + filename
var/map_to_choose = vote.forced_map ? vote.forced_map : vote.winner
var/map_path = "maps/voting/" + vote.map_paths[map_to_choose] + "/" + filename
if(fexists(map_path))
//copy file to main folder
if(!fcopy(map_path, filename))
Expand Down

0 comments on commit 5501cc3

Please sign in to comment.