Skip to content

Commit

Permalink
Ports SSvote refactor + new vote UI from TG (#2667)
Browse files Browse the repository at this point in the history
<!-- 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
See title, might possibly lead to more interesting things, might just be
something nice to have. Maybe both.

## Why It's Good For The Game
The voting subsystem was old and flawed, and this gives it a new coat of
paint

## Changelog

:cl: MrMelbert, san7890, lessthnthree, ZephyrTFA, MarkSuckerberg
admin: You can now create a custom approval-type vote
admin: You can now manually start a transfer vote in the vote menu
config: Removes the player mode voting setting as we don't use modes
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: 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. -->

---------

Signed-off-by: Mark Suckerberg <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
Co-authored-by: san7890 <[email protected]>
Co-authored-by: lessthanthree <[email protected]>
  • Loading branch information
4 people authored Feb 15, 2024
1 parent 78dbad2 commit 7af1f64
Show file tree
Hide file tree
Showing 16 changed files with 1,133 additions and 380 deletions.
2 changes: 1 addition & 1 deletion check_regex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ standards:

- exactly:
[
273,
271,
"non-bitwise << uses",
'(?<!\d)(?<!\d\s)(?<!<)<<(?!=|\s\d|\d|<|\/)',
]
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

#define ROUND_UP(x) (-round(-(x)))

/// Returns the number of digits in a number. Only works on whole numbers.
/// This is marginally faster than string interpolation -> length
#define DIGITS(x) (ROUND_UP(log(10, x)))

// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) (round((x) / (y)) * (y))

Expand Down
13 changes: 13 additions & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,16 @@
} \
A.flags_1 &= ~OVERLAY_QUEUED_1; \
}while(FALSE)

// Vote subsystem counting methods
/// First past the post. One selection per person, and the selection with the most votes wins.
#define VOTE_COUNT_METHOD_SINGLE 1
/// Approval voting. Any number of selections per person, and the selection with the most votes wins.
#define VOTE_COUNT_METHOD_MULTI 2

/// The choice with the most votes wins. Ties are broken by the first choice to reach that number of votes.
#define VOTE_WINNER_METHOD_SIMPLE "Simple"
/// The winning choice is selected randomly based on the number of votes each choice has.
#define VOTE_WINNER_METHOD_WEIGHTED_RANDOM "Weighted Random"
/// There is no winner for this vote.
#define VOTE_WINNER_METHOD_NONE "None"
4 changes: 2 additions & 2 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ block( \
viewing += M.client
flick_overlay(I, viewing, duration)

/proc/get_active_player_count(alive_check = 0, afk_check = 0, human_check = 0)
// Get active players who are playing in the round
///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/M = GLOB.player_list[i]
Expand Down
11 changes: 5 additions & 6 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@

/datum/config_entry/flag/allow_admin_asaycolor //Allows admins with relevant permissions to have a personalized asay color

/datum/config_entry/flag/allow_vote_restart // allow votes to restart
/datum/config_entry/flag/allow_vote_restart // allow player votes to restart

/datum/config_entry/flag/allow_vote_mode // allow votes to change mode
/datum/config_entry/flag/allow_vote_transfer // allow player votes to initiate a transfer

/datum/config_entry/flag/auth_only // server can only be used for authentication

Expand All @@ -120,7 +120,9 @@
integer = FALSE
min_val = 0

//WS Begin - Autotranfer vote
/// If disabled, no-voters will automatically have their votes added to certain vote options
/// (For eample: restart votes will default to "no restart", map votes will default to their preferred map / default map)
/datum/config_entry/flag/default_no_vote

/datum/config_entry/number/vote_autotransfer_initial //length of time before the first autotransfer vote is called (deciseconds, default 2 hours)
config_entry_value = 72000
Expand All @@ -132,9 +134,6 @@
integer = FALSE
min_val = 0

//WS End

/datum/config_entry/flag/default_no_vote // vote does not default to nochange/norestart

/datum/config_entry/flag/no_dead_vote // dead people can't vote

Expand Down
18 changes: 9 additions & 9 deletions code/controllers/subsystem/autotransfer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ SUBSYSTEM_DEF(autotransfer)
flags = SS_KEEP_TIMING | SS_BACKGROUND
wait = 1 MINUTES

var/starttime
var/targettime
COOLDOWN_DECLARE(next_vote)

/datum/controller/subsystem/autotransfer/Initialize(timeofday)
starttime = world.time
targettime = starttime + CONFIG_GET(number/vote_autotransfer_initial)
COOLDOWN_START(src, next_vote, CONFIG_GET(number/vote_autotransfer_initial))
return ..()

/datum/controller/subsystem/autotransfer/fire()
if (world.time > targettime)
SSvote.initiate_vote("transfer",null, FALSE) //WS Edit - Ghost Vote Rework
targettime = targettime + CONFIG_GET(number/vote_autotransfer_interval)
if(COOLDOWN_FINISHED(src, next_vote))
//Delay the vote if there's already a vote in progress
if(SSvote.current_vote)
COOLDOWN_START(src, next_vote, SSvote.current_vote.time_remaining + 10 SECONDS)
SSvote.initiate_vote(/datum/vote/transfer_vote, "The Server", forced = TRUE)
COOLDOWN_START(src, next_vote, CONFIG_GET(number/vote_autotransfer_interval))

/datum/controller/subsystem/autotransfer/Recover()
starttime = SSautotransfer.starttime
targettime = SSautotransfer.targettime
next_vote = SSautotransfer.next_vote
5 changes: 0 additions & 5 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ SUBSYSTEM_DEF(mapping)

#define INIT_ANNOUNCE(X) to_chat(world, "<span class='boldannounce'>[X]</span>"); log_world(X)

/datum/controller/subsystem/mapping/proc/mapvote()
SSvote.initiate_vote("map", "automatic map rotation", TRUE) //WS Edit - Ghost Voting Rework

/datum/controller/subsystem/mapping/proc/changemap(datum/map_template/map)

/datum/controller/subsystem/mapping/proc/preloadTemplates(path = "_maps/templates/") //see master controller setup
var/list/filelist = flist(path)
for(var/map in filelist)
Expand Down
Loading

0 comments on commit 7af1f64

Please sign in to comment.