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

Tweak Game Mode Start Handling #5506

Merged
merged 3 commits into from
Jan 28, 2024
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
22 changes: 21 additions & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,27 @@ SUBSYSTEM_DEF(ticker)

CHECK_TICK
if(!mode.can_start(bypass_checks))
to_chat(world, "Reverting to pre-game lobby.")
to_chat(world, "Requirements to start [GLOB.master_mode] not met. Reverting to pre-game lobby.")
// Make only one more attempt
if(world.time - 2 * wait > CONFIG_GET(number/lobby_countdown) SECONDS)
flash_clients()
delay_start = TRUE
var/active_admins = 0
for(var/client/admin_client in GLOB.admins)
if(!admin_client.is_afk() && check_client_rights(admin_client, R_SERVER, FALSE))
active_admins = TRUE
break
if(active_admins)
to_chat(world, SPAN_CENTERBOLD("The game start has been delayed."))
message_admins(SPAN_ADMINNOTICE("Alert: Insufficent players ready to start [GLOB.master_mode].\nEither change mode and map or start round and bypass checks."))
else
var/fallback_mode = CONFIG_GET(string/gamemode_default)
SSticker.save_mode(fallback_mode)
GLOB.master_mode = fallback_mode
to_chat(world, SPAN_BOLDNOTICE("Notice: The Gamemode for next round has been set to [fallback_mode]"))
handle_map_reboot()
else
to_chat(world, "Attempting again...")
QDEL_NULL(mode)
GLOB.RoleAuthority.reset_roles()
return FALSE
Expand Down
14 changes: 8 additions & 6 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,14 @@ SUBSYSTEM_DEF(vote)
question = "Gamemode vote"
randomize_entries = TRUE
for(var/mode_type in config.gamemode_cache)
var/datum/game_mode/M = mode_type
if(initial(M.config_tag))
var/vote_cycle_met = !initial(M.vote_cycle) || (text2num(SSperf_logging?.round?.id) % initial(M.vote_cycle) == 0)
var/min_players_met = length(GLOB.clients) >= M.required_players
if(initial(M.votable) && vote_cycle_met && min_players_met)
choices += initial(M.config_tag)
var/datum/game_mode/cur_mode = mode_type
if(initial(cur_mode.config_tag))
cur_mode = new mode_type
var/vote_cycle_met = !initial(cur_mode.vote_cycle) || (text2num(SSperf_logging?.round?.id) % initial(cur_mode.vote_cycle) == 0)
var/min_players_met = length(GLOB.clients) >= cur_mode.required_players
if(initial(cur_mode.votable) && vote_cycle_met && min_players_met)
choices += initial(cur_mode.config_tag)
qdel(cur_mode)
if("groundmap")
question = "Ground map vote"
vote_sound = 'sound/voice/start_your_voting.ogg'
Expand Down
8 changes: 4 additions & 4 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ Additional game mode variables.

//If we are selecting xenomorphs, we NEED them to play the round. This is the expected behavior.
//If this is an optional behavior, just override this proc or make an override here.
/datum/game_mode/proc/initialize_starting_xenomorph_list(list/hives = list(XENO_HIVE_NORMAL), force_xenos = FALSE)
/datum/game_mode/proc/initialize_starting_xenomorph_list(list/hives = list(XENO_HIVE_NORMAL), bypass_checks = FALSE)
var/list/datum/mind/possible_xenomorphs = get_players_for_role(JOB_XENOMORPH)
var/list/datum/mind/possible_queens = get_players_for_role(JOB_XENOMORPH_QUEEN)
if(possible_xenomorphs.len < xeno_required_num) //We don't have enough aliens, we don't consider people rolling for only Queen.
if(possible_xenomorphs.len < xeno_required_num && !bypass_checks) //We don't have enough aliens, we don't consider people rolling for only Queen.
to_world("<h2 style=\"color:red\">Not enough players have chosen to be a xenomorph in their character setup. <b>Aborting</b>.</h2>")
return

Expand Down Expand Up @@ -325,11 +325,11 @@ Additional game mode variables.
Our list is empty. This can happen if we had someone ready as alien and predator, and predators are picked first.
So they may have been removed from the list, oh well.
*/
if(LAZYLEN(xenomorphs) < xeno_required_num && LAZYLEN(picked_queens) != LAZYLEN(hives))
if(LAZYLEN(xenomorphs) < xeno_required_num && LAZYLEN(picked_queens) != LAZYLEN(hives) && !bypass_checks)
to_world("<h2 style=\"color:red\">Could not find any candidates after initial alien list pass. <b>Aborting</b>.</h2>")
return

return 1
return TRUE

// Helper proc to set some constants
/proc/setup_new_xeno(datum/mind/new_xeno)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/colonialmarines/colonialmarines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
////////////////////////////////////////////////////////////////////////////////////////

/* Pre-pre-startup */
/datum/game_mode/colonialmarines/can_start()
/datum/game_mode/colonialmarines/can_start(bypass_checks = FALSE)
initialize_special_clamps()
return TRUE

Expand Down
6 changes: 3 additions & 3 deletions code/game/gamemodes/colonialmarines/xenovsxeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
votable = FALSE // broken

/* Pre-pre-startup */
/datum/game_mode/xenovs/can_start()
/datum/game_mode/xenovs/can_start(bypass_checks = FALSE)
for(var/hivename in SSmapping.configs[GROUND_MAP].xvx_hives)
if(GLOB.readied_players > SSmapping.configs[GROUND_MAP].xvx_hives[hivename])
hives += hivename
xeno_starting_num = GLOB.readied_players
if(!initialize_starting_xenomorph_list(hives, TRUE))
if(!initialize_starting_xenomorph_list(hives, bypass_checks))
hives.Cut()
return
return FALSE
return TRUE

/datum/game_mode/xenovs/announce()
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/extended/infection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
if(transform_survivor(survivor) == 1)
survivors -= survivor

/datum/game_mode/infection/can_start()
/datum/game_mode/infection/can_start(bypass_checks = FALSE)
initialize_starting_survivor_list()
return 1
return TRUE

//We don't actually need survivors to play, so long as aliens are present.
/datum/game_mode/infection/proc/initialize_starting_survivor_list()
Expand Down
23 changes: 12 additions & 11 deletions code/game/gamemodes/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ GLOBAL_VAR_INIT(cas_tracking_id_increment, 0) //this var used to assign unique t

///can_start()
///Checks to see if the game can be setup and ran with the current number of players or whatnot.
/datum/game_mode/proc/can_start()
var/playerC = 0
/datum/game_mode/proc/can_start(bypass_checks = FALSE)
if(bypass_checks)
return TRUE
var/players = 0
for(var/mob/new_player/player in GLOB.new_player_list)
if((player.client)&&(player.ready))
playerC++

if(GLOB.master_mode=="secret")
if(playerC >= required_players_secret)
return 1
if(player.client && player.ready)
players++
if(GLOB.master_mode == "secret")
if(players >= required_players_secret)
return TRUE
else
if(playerC >= required_players)
return 1
return 0
if(players >= required_players)
return TRUE
return FALSE


///pre_setup()
Expand Down
6 changes: 4 additions & 2 deletions code/modules/admin/tabs/round_tab.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@
set name = "Start Round"
set desc = "Start the round RIGHT NOW"
set category = "Server.Round"
if (alert("Are you sure you want to start the round early?",,"Yes","No") != "Yes")
return
var/response = tgui_alert(usr, "Are you sure you want to start the round early?", "Force Start Round", list("Yes", "Bypass Checks", "No"), 30 SECONDS)
if (response != "Yes" && response != "Bypass Checks")
return FALSE
SSticker.bypass_checks = response == "Bypass Checks"
if (SSticker.current_state == GAME_STATE_STARTUP)
message_admins("Game is setting up and will launch as soon as it is ready.")
message_admins(SPAN_ADMINNOTICE("[usr.key] has started the process to start the game when loading is finished."))
Expand Down
Loading