diff --git a/code/controllers/subsystem/map_vote.dm b/code/controllers/subsystem/map_vote.dm index 4229ee82737..6f0f3a501da 100644 --- a/code/controllers/subsystem/map_vote.dm +++ b/code/controllers/subsystem/map_vote.dm @@ -22,6 +22,9 @@ SUBSYSTEM_DEF(map_vote) /// Stores the last amount of potential players to compare next time we're called var/player_cache = -1 + /// Cached list of votable maps + var/list/votable_map_cache + /// Stores a formatted html string of the tally counts var/tally_printout = span_red("Loading...") @@ -113,8 +116,9 @@ SUBSYSTEM_DEF(map_vote) else filter_threshold = length(GLOB.clients) - if(filter_threshold == player_cache) - return null + // Cached because it's called off ui_data, I really don't think this is worth it but whatever + if(filter_threshold == player_cache && !isnull(votable_map_cache)) + return votable_map_cache.Copy() player_cache = filter_threshold var/list/valid_maps = list() @@ -130,6 +134,7 @@ SUBSYSTEM_DEF(map_vote) continue valid_maps += possible_config.map_name + votable_map_cache = valid_maps.Copy() return valid_maps /datum/controller/subsystem/map_vote/proc/filter_cache_to_valid_maps() diff --git a/code/datums/votes/map_vote.dm b/code/datums/votes/map_vote.dm index 08f792d291d..dd099919aeb 100644 --- a/code/datums/votes/map_vote.dm +++ b/code/datums/votes/map_vote.dm @@ -4,14 +4,13 @@ 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() /datum/vote/map_vote/create_vote() - var/list/new_choices = SSmap_vote.get_valid_map_vote_choices() - if (new_choices) - default_choices = new_choices + default_choices = SSmap_vote.get_valid_map_vote_choices() . = ..() if(!.) return FALSE @@ -43,10 +42,13 @@ if(SSmap_vote.next_map_config) return "The next map has already been selected." + // The below case will be caught in create_vote() if the vote is being forced + // This ensures proper map rotation if there aren't enough votable maps for whatever reason + if(forced) + return VOTE_AVAILABLE + var/list/new_choices = SSmap_vote.get_valid_map_vote_choices() - if (new_choices) - default_choices = new_choices - var/num_choices = length(default_choices) + var/num_choices = length(new_choices) if(num_choices <= 1) return "There [num_choices == 1 ? "is only one map" : "are no maps"] to choose from."