Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mapvote): maked it start earlier, move allowed maps to config #11002

Merged
merged 4 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions code/controllers/evacuation/evacuation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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("<span class='notice'>Map has been changed to: <b>[next_map.name]</b></span>")
fdel("data/use_map")
text2file("[next_map.type]", "data/use_map")
1 change: 1 addition & 0 deletions code/controllers/evacuation/evacuation_shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 0 additions & 14 deletions code/controllers/subsystems/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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("<span class='notice'>Map has been changed to: <b>[next_map.name]</b></span>")
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
Expand Down
53 changes: 29 additions & 24 deletions code/controllers/subsystems/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,18 @@ 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()
voting_action.name = "Vote: [current_vote.override_question || current_vote.name]"
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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions code/datums/configuration/mapping_section.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions code/datums/vote/map.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions config/example/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions maps/~mapsystem/maps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down