mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
Fixes map votes not refreshing the amount of possible choices (#89404)
## About The Pull Request Closes #89235 ## Changelog 🆑 fix: Fixed map votes not refreshing the amount of possible choices /🆑 --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
This commit is contained in:
committed by
Roxy
co-authored by
LemonInTheDark
parent
94ad1a7cb7
commit
629ec38e4e
@@ -155,19 +155,18 @@
|
||||
///Get active players who are playing in the round
|
||||
/proc/get_active_player_count(alive_check = FALSE, afk_check = FALSE, human_check = FALSE)
|
||||
var/active_players = 0
|
||||
for(var/i = 1; i <= GLOB.player_list.len; i++)
|
||||
var/mob/player_mob = GLOB.player_list[i]
|
||||
for(var/mob/player_mob as anything in GLOB.player_list)
|
||||
if(!player_mob?.client)
|
||||
continue
|
||||
if(alive_check && player_mob.stat)
|
||||
if(alive_check && player_mob.stat == DEAD)
|
||||
continue
|
||||
else if(afk_check && player_mob.client.is_afk())
|
||||
if(afk_check && player_mob.client.is_afk())
|
||||
continue
|
||||
else if(human_check && !ishuman(player_mob))
|
||||
if(human_check && !ishuman(player_mob))
|
||||
continue
|
||||
else if(isnewplayer(player_mob)) // exclude people in the lobby
|
||||
if(isnewplayer(player_mob)) // exclude people in the lobby
|
||||
continue
|
||||
else if(isobserver(player_mob)) // Ghosts are fine if they were playing once (didn't start as observers)
|
||||
if(isobserver(player_mob)) // Ghosts are fine if they were playing once (didn't start as observers)
|
||||
var/mob/dead/observer/ghost_player = player_mob
|
||||
if(ghost_player.started_as_observer) // Exclude people who started as observers
|
||||
continue
|
||||
|
||||
@@ -19,6 +19,9 @@ SUBSYSTEM_DEF(map_vote)
|
||||
/// Stores the previous map vote cache, used when a map vote is reverted.
|
||||
var/list/previous_cache
|
||||
|
||||
/// Stores the last amount of potential players to compare next time we're called
|
||||
var/player_cache = -1
|
||||
|
||||
/// Stores a formatted html string of the tally counts
|
||||
var/tally_printout = span_red("Loading...")
|
||||
|
||||
@@ -104,29 +107,28 @@ SUBSYSTEM_DEF(map_vote)
|
||||
|
||||
/// Returns a list of all map options that are invalid for the current population.
|
||||
/datum/controller/subsystem/map_vote/proc/get_valid_map_vote_choices()
|
||||
var/list/valid_maps = list()
|
||||
|
||||
// Fill in our default choices with all of the maps in our map config, if they are votable and not blocked.
|
||||
var/list/maps = shuffle(global.config.maplist)
|
||||
for(var/map in maps)
|
||||
var/datum/map_config/possible_config = config.maplist[map]
|
||||
if(!possible_config.votable || (possible_config.map_name in SSpersistence.blocked_maps))
|
||||
continue
|
||||
valid_maps += possible_config.map_name
|
||||
|
||||
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 = length(GLOB.clients)
|
||||
|
||||
for(var/map in valid_maps)
|
||||
var/datum/map_config/possible_config = config.maplist[map]
|
||||
if(possible_config.config_min_users > 0 && filter_threshold < possible_config.config_min_users)
|
||||
valid_maps -= map
|
||||
if(filter_threshold == player_cache)
|
||||
return
|
||||
|
||||
else if(possible_config.config_max_users > 0 && filter_threshold > possible_config.config_max_users)
|
||||
valid_maps -= map
|
||||
player_cache = filter_threshold
|
||||
var/list/valid_maps = list()
|
||||
// Fill in our default choices with all of the maps in our map config, if they are votable and not blocked.
|
||||
var/list/maps = shuffle(global.config.maplist)
|
||||
for(var/map in maps)
|
||||
var/datum/map_config/possible_config = config.maplist[map]
|
||||
if(!possible_config.votable || (possible_config.map_name in SSpersistence.blocked_maps))
|
||||
continue
|
||||
if(possible_config.config_min_users > 0 && filter_threshold < possible_config.config_min_users)
|
||||
continue
|
||||
if(possible_config.config_max_users > 0 && filter_threshold > possible_config.config_max_users)
|
||||
continue
|
||||
valid_maps += possible_config.map_name
|
||||
|
||||
return valid_maps
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
count_method = VOTE_COUNT_METHOD_SINGLE
|
||||
winner_method = VOTE_WINNER_METHOD_NONE
|
||||
display_statistics = FALSE
|
||||
|
||||
/datum/vote/map_vote/New()
|
||||
. = ..()
|
||||
default_choices = SSmap_vote.get_valid_map_vote_choices()
|
||||
@@ -39,11 +38,14 @@
|
||||
if(. != VOTE_AVAILABLE)
|
||||
return .
|
||||
|
||||
if(SSmap_vote.next_map_config)
|
||||
return "The next map has already been selected."
|
||||
|
||||
default_choices = SSmap_vote.get_valid_map_vote_choices()
|
||||
var/num_choices = length(default_choices)
|
||||
if(num_choices <= 1)
|
||||
return "There [num_choices == 1 ? "is only one map" : "are no maps"] to choose from."
|
||||
if(SSmap_vote.next_map_config)
|
||||
return "The next map has already been selected."
|
||||
|
||||
return VOTE_AVAILABLE
|
||||
|
||||
/datum/vote/map_vote/get_result_text(list/all_winners, real_winner, list/non_voters)
|
||||
|
||||
@@ -120,5 +120,5 @@
|
||||
var/list/adm = get_admin_counts()
|
||||
var/list/allmins = adm["total"]
|
||||
var/status = "Admins: [allmins.len] (Active: [english_list(adm["present"])] AFK: [english_list(adm["afk"])] Stealth: [english_list(adm["stealth"])] Skipped: [english_list(adm["noflags"])]). "
|
||||
status += "Players: [GLOB.clients.len] (Active: [get_active_player_count(0,1,0)]). Round has [SSticker.HasRoundStarted() ? "" : "not "]started."
|
||||
status += "Players: [GLOB.clients.len] (Active: [get_active_player_count(FALSE, TRUE, FALSE)]). Round has [SSticker.HasRoundStarted() ? "" : "not "]started."
|
||||
return new /datum/tgs_message_content(status)
|
||||
|
||||
Reference in New Issue
Block a user