diff --git a/code/controllers/evacuation/evacuation.dm b/code/controllers/evacuation/evacuation.dm index 756347d637c..c68f00a08ca 100644 --- a/code/controllers/evacuation/evacuation.dm +++ b/code/controllers/evacuation/evacuation.dm @@ -145,6 +145,7 @@ var/datum/evacuation_controller/evacuation_controller else SSannounce.play_announce(/datum/announce/shuttle_leaving_dock, "The Crew Transfer Shuttle has left the station. Estimate [round(get_eta()/60,1)] minute\s until the shuttle docks at [GLOB.using_map.dock_name].") + launch_map_vote() return 1 /datum/evacuation_controller/proc/finish_evacuation() @@ -186,3 +187,19 @@ var/datum/evacuation_controller/evacuation_controller /datum/evacuation_controller/proc/toggle_emergency_light(state) for(var/area/A in GLOB.hallway) A.set_lighting_mode(LIGHTMODE_EVACUATION, state) + +/datum/evacuation_controller/proc/launch_map_vote() + if(config.game.map_switching && GLOB.all_maps.len > 1) + if (config.game.auto_map_vote) + SSvote.initiate_vote(new /datum/vote/map/end_game, forced = TRUE) + else if (config.game.auto_map_switching) + // Select random map exclude the current + var/datum/map/current_map = GLOB.using_map + var/datum/map/next_map = current_map + + while (next_map.type == current_map.type) + next_map = GLOB.all_maps[pick(GLOB.all_maps)] + + to_world("Map has been changed to: [next_map.name]") + fdel("data/use_map") + text2file("[next_map.type]", "data/use_map") diff --git a/code/controllers/evacuation/evacuation_shuttle.dm b/code/controllers/evacuation/evacuation_shuttle.dm index f6c4b66f54e..97d83967d85 100644 --- a/code/controllers/evacuation/evacuation_shuttle.dm +++ b/code/controllers/evacuation/evacuation_shuttle.dm @@ -35,6 +35,7 @@ if(autopilot && shuttle.moving_status == SHUTTLE_IDLE) evac_arrival_time = world.time + (shuttle.move_time*10) + (shuttle.warmup_time*10) shuttle.launch(src) + launch_map_vote() // Announcements, state changes and such are handled by the shuttle itself to prevent desync. /datum/evacuation_controller/shuttle/finish_preparing_evac() diff --git a/code/controllers/subsystems/ticker.dm b/code/controllers/subsystems/ticker.dm index 8aa33d832d6..8b61ccc90e4 100644 --- a/code/controllers/subsystems/ticker.dm +++ b/code/controllers/subsystems/ticker.dm @@ -126,20 +126,6 @@ SUBSYSTEM_DEF(ticker) Master.SetRunLevel(RUNLEVEL_POSTGAME) end_game_state = END_GAME_READY_TO_END INVOKE_ASYNC(src, .proc/declare_completion) - if(config.game.map_switching && GLOB.all_maps.len > 1) - if (config.game.auto_map_vote) - SSvote.initiate_vote(/datum/vote/map/end_game, forced = 1) - else if (config.game.auto_map_switching) - // Select random map exclude the current - var/datum/map/current_map = GLOB.using_map - var/datum/map/next_map = current_map - - while (next_map.type == current_map.type) - next_map = GLOB.all_maps[pick(GLOB.all_maps)] - - to_world("Map has been changed to: [next_map.name]") - fdel("data/use_map") - text2file("[next_map.type]", "data/use_map") else if(mode_finished && (end_game_state <= END_GAME_NOT_OVER)) end_game_state = END_GAME_MODE_FINISH_DONE diff --git a/code/controllers/subsystems/vote.dm b/code/controllers/subsystems/vote.dm index 4d9958f9231..313d294c5c7 100644 --- a/code/controllers/subsystems/vote.dm +++ b/code/controllers/subsystems/vote.dm @@ -212,9 +212,11 @@ SUBSYSTEM_DEF(vote) You have [duration] seconds to vote.")))) // And now that it's going, give everyone a voter action - notify_ghosts("Vote: [current_vote.override_question || current_vote.name]", sound(current_vote.vote_sound), src, image('icons/hud/actions.dmi',"vote"), NOTIFY_VOTE, header = "Vote: [current_vote.override_question || current_vote.name]") + notify_ghosts("Vote: [current_vote.override_question || current_vote.name]", src, image('icons/hud/actions.dmi',"vote"), NOTIFY_VOTE, header = "Vote: [current_vote.override_question || current_vote.name]", flashwindow=FALSE) - for(var/mob/living/new_voter in GLOB.player_list) + for(var/mob/new_voter in GLOB.player_list) + sound_to(new_voter, sound(current_vote.vote_sound)) + winset(new_voter.client, "mainwindow", "flash=5") if(!isliving(new_voter)) continue var/datum/action/vote/voting_action = new() @@ -222,10 +224,6 @@ SUBSYSTEM_DEF(vote) voting_action.Grant(new_voter) generated_actions += voting_action - - sound_to(new_voter, sound(current_vote.vote_sound)) - winset(new_voter.client, "mainwindow", "flash=5") - return TRUE /datum/controller/subsystem/vote/tgui_state() @@ -264,30 +262,37 @@ SUBSYSTEM_DEF(vote) var/list/vote_data = list( "name" = vote_name, - "canBeInitiated" = vote.can_be_initiated(forced = is_lower_admin), + "canBeInitiated" = vote.can_be_initiated(user.client.mob, forced = is_lower_admin), "config" = vote.is_config_enabled(), "message" = vote.message, ) - if(vote == current_vote) - var/list/choices = list() - for(var/key in current_vote.choices) - choices += list(list( - "name" = key, - "votes" = current_vote.choices[key], - )) - - data["currentVote"] = list( - "name" = current_vote.name, - "question" = current_vote.override_question, - "timeRemaining" = current_vote.time_remaining, - "countMethod" = current_vote.count_method, - "choices" = choices, - "vote" = vote_data, - ) - all_vote_data += list(vote_data) + if(!isnull(current_vote)) + var/list/vote_data = list( + "name" = current_vote.name, + "canBeInitiated" = current_vote.can_be_initiated(user.client.mob, forced = is_lower_admin), + "config" = current_vote.is_config_enabled(), + "message" = current_vote.message, + ) + + var/list/choices = list() + for(var/key in current_vote.choices) + choices += list(list( + "name" = key, + "votes" = current_vote.choices[key], + )) + + data["currentVote"] = list( + "name" = current_vote.name, + "question" = current_vote.override_question, + "timeRemaining" = current_vote.time_remaining, + "countMethod" = current_vote.count_method, + "choices" = choices, + "vote" = vote_data, + ) + data["possibleVotes"] = all_vote_data return data diff --git a/code/datums/configuration/mapping_section.dm b/code/datums/configuration/mapping_section.dm index 1abed3d83b2..87619b1b825 100644 --- a/code/datums/configuration/mapping_section.dm +++ b/code/datums/configuration/mapping_section.dm @@ -4,11 +4,13 @@ var/preferable_engine = MAP_ENG_SINGULARITY var/preferable_biodome = MAP_BIO_FOREST var/preferable_bar = MAP_BAR_CLASSIC + var/list/allowed_maps = list() /datum/configuration_section/mapping/load_data(list/data) CONFIG_LOAD_STR(preferable_engine, data["preferable_engine"]) CONFIG_LOAD_STR(preferable_biodome, data["preferable_biodome"]) CONFIG_LOAD_STR(preferable_bar, data["preferable_bar"]) + CONFIG_LOAD_LIST(allowed_maps, data["allowed_maps"]) if(!(preferable_engine in list(MAP_ENG_RANDOM, MAP_ENG_SINGULARITY, MAP_ENG_MATTER))) preferable_engine = MAP_ENG_SINGULARITY diff --git a/code/datums/vote/map.dm b/code/datums/vote/map.dm index c1174de6917..8d4e83b35a5 100644 --- a/code/datums/vote/map.dm +++ b/code/datums/vote/map.dm @@ -27,13 +27,14 @@ /datum/vote/map/end_game name = "Round End Map Vote" +/datum/vote/map/end_game/is_accessible_vote() + return FALSE + /datum/vote/map/end_game/can_be_initiated(mob/by_who, forced) . = ..() if(!config.game.map_switching) return FALSE - if(GAME_STATE != RUNLEVEL_POSTGAME) - return FALSE - if(!forced) + if(!isnull(by_who)) return FALSE /datum/vote/map/end_game/finalize_vote() diff --git a/config/example/config.toml b/config/example/config.toml index b4f964f3361..7c981c00ae0 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -553,6 +553,9 @@ preferable_bar = "classic" ## Pick one from: "random", "forest", "winter", "beach", "concert" preferable_biodome = "forest" +[mapping.allowed_maps] +Example = false + [vote] ## Allow players to initiate a restart vote. allow_vote_restart = true diff --git a/maps/~mapsystem/maps.dm b/maps/~mapsystem/maps.dm index 661f6d480fe..76580a0b5a6 100644 --- a/maps/~mapsystem/maps.dm +++ b/maps/~mapsystem/maps.dm @@ -12,6 +12,9 @@ var/const/MAP_HAS_RANK = 2 //Rank system, also togglable M.setup_map() else M = new type + if(M.name in config.mapping.allowed_maps) + M.can_be_voted = config.mapping.allowed_maps[M.name] + if(!M.path) log_error("Map '[M]' does not have a defined path, not adding to map list!") else