Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports SSvote refactor + new vote UI from TG #2667

Merged
merged 16 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading