Fix pre-round lobby map vote filter (#73820)

## About The Pull Request

Fixes https://github.com/tgstation/tgstation/issues/73816

## Changelog

🆑 LT3
fix: Map filter works properly in the pre-round lobby
fix: Map vote doesn't log 'not enough players' if the vote starts in the
pre-round lobby
/🆑

---------

Co-authored-by: tattle <66640614+dragomagol@users.noreply.github.com>
This commit is contained in:
lessthanthree
2023-03-10 12:49:24 +00:00
committed by GitHub
co-authored by tattle
parent 6264fc5656
commit 331bc183b5
2 changed files with 12 additions and 6 deletions
+3 -2
View File
@@ -531,10 +531,11 @@ GLOBAL_LIST_EMPTY(the_station_areas)
message_admins("Failed to set new map with next_map.json for [change_to.map_name]! Using default as backup!")
return
if (change_to.config_min_users > 0 && GLOB.clients.len < change_to.config_min_users)
var/filter_threshold = get_active_player_count(alive_check = FALSE, afk_check = TRUE, human_check = FALSE)
if (change_to.config_min_users > 0 && filter_threshold != 0 && filter_threshold < change_to.config_min_users)
message_admins("[change_to.map_name] was chosen for the next map, despite there being less current players than its set minimum population range!")
log_game("[change_to.map_name] was chosen for the next map, despite there being less current players than its set minimum population range!")
if (change_to.config_max_users > 0 && GLOB.clients.len > change_to.config_max_users)
if (change_to.config_max_users > 0 && filter_threshold > change_to.config_max_users)
message_admins("[change_to.map_name] was chosen for the next map, despite there being more current players than its set maximum population range!")
log_game("[change_to.map_name] was chosen for the next map, despite there being more current players than its set maximum population range!")
+9 -4
View File
@@ -67,21 +67,26 @@
message = initial(message)
return TRUE
/// Before we create a vote, remove all maps from our choices that are outside of our population range. Note that this can result in zero remaining choices for our vote, which is not ideal (but ultimately okay).
/// Before we create a vote, remove all maps from our choices that are outside of our population range.
/// Note that this can result in zero remaining choices for our vote, which is not ideal (but ultimately okay).
/// Argument should_key_choices is TRUE, pass as FALSE in a context where choices are already keyed in a list.
/datum/vote/map_vote/proc/check_population(should_key_choices = TRUE)
if(should_key_choices)
for(var/key in default_choices)
choices[key] = 0
var/active_players = get_active_player_count(alive_check = FALSE, afk_check = TRUE, human_check = FALSE)
var/filter_threshold = 0
if(SSticker.HasRoundStarted())
filter_threshold = get_active_player_count(alive_check = FALSE, afk_check = TRUE, human_check = FALSE)
else
filter_threshold = GLOB.clients.len
for(var/map in choices)
var/datum/map_config/possible_config = config.maplist[map]
if(possible_config.config_min_users > 0 && active_players < possible_config.config_min_users)
if(possible_config.config_min_users > 0 && filter_threshold < possible_config.config_min_users)
choices -= map
else if(possible_config.config_max_users > 0 && active_players > possible_config.config_max_users)
else if(possible_config.config_max_users > 0 && filter_threshold > possible_config.config_max_users)
choices -= map
return choices