Files
Bubberstation/code/datums/votes/map_vote.dm
LemonInTheDarkandGitHub b5f3b89d8a Fixes rotation breaking on one votable map (#96493)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Basically, if it's forced, we rely on create_vote to catch the "no
options" case.
This used to be the behavior, but it was removed in persistant tallies.
I have no idea why.
I've also cleaned up the quite dubious caching code to avoid the bugs I
was getting when testing locally.

## Why It's Good For The Game

S been causing forced icebox (15 pop min, meta can't replace it because
meta's the only one with 0 minpop) on the servers, that's silly.

Of note, it's possible this will still be an issue due to the stale map
system, but yaknow, one thing at a time, and that'll be louder so we
should find out pretty fast (fix would be defaulting to some marked
default map if only one can be rolled).

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and its effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
fix: End of round mapvotes will now properly default to the only option
if only one map is votable.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2026-06-14 22:27:28 +02:00

80 lines
2.8 KiB
Plaintext

/datum/vote/map_vote
name = "Map"
default_message = "Vote for next round's map!"
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()
default_choices = SSmap_vote.get_valid_map_vote_choices()
. = ..()
if(!.)
return FALSE
if(length(choices) == 1) // Only one choice, no need to vote. Let's just auto-rotate it to the only remaining map because it would just happen anyways.
var/datum/map_config/change_me_out = global.config.maplist[choices[1]]
finalize_vote(choices[1])// voted by not voting, very sad.
to_chat(world, span_boldannounce("The map vote has been skipped because there is only one map left to vote for. \
The map has been changed to [change_me_out.map_name]."))
return FALSE
if(length(choices) == 0)
to_chat(world, span_boldannounce("A map vote was called, but there are no maps to vote for! \
Players, complain to the admins. Admins, complain to the coders."))
return FALSE
return TRUE
/datum/vote/map_vote/toggle_votable()
CONFIG_SET(flag/allow_vote_map, !CONFIG_GET(flag/allow_vote_map))
/datum/vote/map_vote/is_config_enabled()
return CONFIG_GET(flag/allow_vote_map)
/datum/vote/map_vote/can_be_initiated(forced)
. = ..()
if(. != VOTE_AVAILABLE)
return .
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()
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."
return VOTE_AVAILABLE
/datum/vote/map_vote/get_result_text(list/all_winners, real_winner, list/non_voters)
return null
/datum/vote/map_vote/get_vote_result(list/non_voters)
// Even if we have default no vote off,
// if our default map is null for some reason, we shouldn't continue
if(CONFIG_GET(flag/default_no_vote) || isnull(global.config.defaultmap))
return ..()
for(var/non_voter_ckey in non_voters)
var/client/non_voter_client = non_voters[non_voter_ckey]
// Non-voters will have their preferred map voted for automatically.
var/their_preferred_map = non_voter_client?.prefs.read_preference(/datum/preference/choiced/preferred_map)
// If the non-voter's preferred map is null for some reason, we just use the default map.
var/voting_for = their_preferred_map || global.config.defaultmap.map_name
if(voting_for in choices)
choices[voting_for] += 1
return ..()
/datum/vote/map_vote/finalize_vote(winning_option)
SSmap_vote.finalize_map_vote(src)