diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index 7703b13018..7f5035347c 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -425,8 +425,7 @@
candidates -= M
/proc/pollGhostCandidates(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, ignore_category = null, flashwindow = TRUE)
- var/datum/element/ghost_role_eligibility/eligibility = SSdcs.GetElement(list(/datum/element/ghost_role_eligibility))
- var/list/candidates = eligibility.get_all_ghost_role_eligible()
+ var/list/candidates = get_all_ghost_role_eligible()
return pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time, ignore_category, flashwindow, candidates)
/proc/pollCandidates(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, ignore_category = null, flashwindow = TRUE, list/group = null)
@@ -581,4 +580,4 @@
var/area/A = C.area
if(GLOB.typecache_powerfailure_safe_areas[A.type])
continue
- C.energy_fail(rand(duration_min,duration_max))
\ No newline at end of file
+ C.energy_fail(rand(duration_min,duration_max))
diff --git a/code/datums/elements/ghost_role_eligibility.dm b/code/datums/elements/ghost_role_eligibility.dm
index 81fd593d5f..4e7884efe4 100644
--- a/code/datums/elements/ghost_role_eligibility.dm
+++ b/code/datums/elements/ghost_role_eligibility.dm
@@ -1,67 +1,48 @@
+GLOBAL_LIST_EMPTY(ghost_eligible_mobs)
+
+GLOBAL_LIST_EMPTY(client_ghost_timeouts)
+
/datum/element/ghost_role_eligibility
element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE
- id_arg_index = 3
- var/list/timeouts = list()
- var/list/mob/eligible_mobs = list()
+ id_arg_index = 2
var/penalizing = FALSE
var/free_ghost = FALSE
-/datum/element/ghost_role_eligibility/Attach(datum/target,penalize = FALSE,free_ghosting = FALSE, penalize_on_ghost = FALSE)
+/datum/element/ghost_role_eligibility/Attach(datum/target,free_ghosting = FALSE, penalize_on_ghost = FALSE)
. = ..()
if(!ismob(target))
return ELEMENT_INCOMPATIBLE
penalizing = penalize_on_ghost
free_ghost = free_ghosting
var/mob/M = target
- if(!(M in eligible_mobs))
- eligible_mobs += M
+ if(!(M in GLOB.ghost_eligible_mobs))
+ GLOB.ghost_eligible_mobs += M
RegisterSignal(M, COMSIG_MOB_GHOSTIZE, .proc/get_ghost_flags)
- if(penalize) //penalizing them from making a ghost role / midround antag comeback right away.
- var/penalty = CONFIG_GET(number/suicide_reenter_round_timer) MINUTES
- var/roundstart_quit_limit = CONFIG_GET(number/roundstart_suicide_time_limit) MINUTES
- if(world.time < roundstart_quit_limit) //add up the time difference to their antag rolling penalty if they quit before half a (ingame) hour even passed.
- penalty += roundstart_quit_limit - world.time
- if(penalty)
- penalty += world.realtime
- if(SSautotransfer.can_fire && SSautotransfer.maxvotes)
- var/maximumRoundEnd = SSautotransfer.starttime + SSautotransfer.voteinterval * SSautotransfer.maxvotes
- if(penalty - SSshuttle.realtimeofstart > maximumRoundEnd + SSshuttle.emergencyCallTime + SSshuttle.emergencyDockTime + SSshuttle.emergencyEscapeTime)
- penalty = CANT_REENTER_ROUND
- if(!(M.ckey in timeouts))
- timeouts += M.ckey
- timeouts[M.ckey] = 0
- else if(timeouts[M.ckey] == CANT_REENTER_ROUND)
- return
- timeouts[M.ckey] = max(timeouts[M.ckey],penalty)
/datum/element/ghost_role_eligibility/Detach(mob/M)
. = ..()
- if(M in eligible_mobs)
- eligible_mobs -= M
+ if(M in GLOB.ghost_eligible_mobs)
+ GLOB.ghost_eligible_mobs -= M
UnregisterSignal(M, COMSIG_MOB_GHOSTIZE)
-/datum/element/ghost_role_eligibility/proc/get_all_ghost_role_eligible(silent = FALSE)
+/proc/get_all_ghost_role_eligible(silent = FALSE)
var/list/candidates = list()
- for(var/m in eligible_mobs)
+ for(var/m in GLOB.ghost_eligible_mobs)
var/mob/M = m
if(M.can_reenter_round(TRUE))
candidates += M
return candidates
/mob/proc/can_reenter_round(silent = FALSE)
- var/datum/element/ghost_role_eligibility/eli = SSdcs.GetElement(list(/datum/element/ghost_role_eligibility))
- return eli.can_reenter_round(src,silent)
-
-/datum/element/ghost_role_eligibility/proc/can_reenter_round(var/mob/M,silent = FALSE)
- if(!(M in eligible_mobs))
+ if(!(src in GLOB.ghost_eligible_mobs))
return FALSE
- if(!(M.ckey in timeouts))
+ if(!(ckey in GLOB.client_ghost_timeouts))
return TRUE
- var/timeout = timeouts[M.ckey]
+ var/timeout = GLOB.client_ghost_timeouts[ckey]
if(timeout != CANT_REENTER_ROUND && timeout <= world.realtime)
return TRUE
- if(!silent && M.client)
- to_chat(M, "You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].")
+ if(!silent && client)
+ to_chat(src, "You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].")
return FALSE
/datum/element/ghost_role_eligibility/proc/get_ghost_flags()
diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm
index b746100f27..48e306b2b5 100644
--- a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm
+++ b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm
@@ -34,8 +34,7 @@
living_players = trim_list(mode.current_players[CURRENT_LIVING_PLAYERS])
living_antags = trim_list(mode.current_players[CURRENT_LIVING_ANTAGS])
list_observers = trim_list(mode.current_players[CURRENT_OBSERVERS])
- var/datum/element/ghost_role_eligibility/eligibility = SSdcs.GetElement(list(/datum/element/ghost_role_eligibility))
- ghost_eligible = trim_list(eligibility.get_all_ghost_role_eligible())
+ ghost_eligible = trim_list(get_all_ghost_role_eligible())
/datum/dynamic_ruleset/midround/proc/trim_list(list/L = list())
var/list/trimmed_list = L.Copy()
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index d86211f216..62c2dc900c 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -1732,9 +1732,8 @@
var/mob/M = locate(href_list["makeeligible"])
if(!ismob(M))
to_chat(usr, "this can only be used on instances of type /mob.")
- var/datum/element/ghost_role_eligibility/eli = SSdcs.GetElement(list(/datum/element/ghost_role_eligibility))
- if(M.ckey in eli.timeouts)
- eli.timeouts -= M.ckey
+ if(M.ckey in GLOB.client_ghost_timeouts)
+ GLOB.client_ghost_timeouts -= M.ckey
else if(href_list["sendtoprison"])
if(!check_rights(R_ADMIN))
diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm
index 3023b93856..b2d02d8fa2 100644
--- a/code/modules/mob/dead/observer/observer.dm
+++ b/code/modules/mob/dead/observer/observer.dm
@@ -276,7 +276,23 @@ Works together with spawning an observer, noted above.
if (!(client.prefs.chat_toggles & CHAT_OOC))
client.prefs.chat_toggles ^= CHAT_OOC
transfer_ckey(ghost, FALSE)
- ghost.AddElement(/datum/element/ghost_role_eligibility,penalize) // technically already run earlier, but this adds the penalty
+ if(penalize)
+ var/penalty = CONFIG_GET(number/suicide_reenter_round_timer) MINUTES
+ var/roundstart_quit_limit = CONFIG_GET(number/roundstart_suicide_time_limit) MINUTES
+ if(world.time < roundstart_quit_limit) //add up the time difference to their antag rolling penalty if they quit before half a (ingame) hour even passed.
+ penalty += roundstart_quit_limit - world.time
+ if(penalty)
+ penalty += world.realtime
+ if(SSautotransfer.can_fire && SSautotransfer.maxvotes)
+ var/maximumRoundEnd = SSautotransfer.starttime + SSautotransfer.voteinterval * SSautotransfer.maxvotes
+ if(penalty - SSshuttle.realtimeofstart > maximumRoundEnd + SSshuttle.emergencyCallTime + SSshuttle.emergencyDockTime + SSshuttle.emergencyEscapeTime)
+ penalty = CANT_REENTER_ROUND
+ if(!(ckey in GLOB.client_ghost_timeouts))
+ GLOB.client_ghost_timeouts += ckey
+ GLOB.client_ghost_timeouts[ckey] = 0
+ else if(GLOB.client_ghost_timeouts[ckey] == CANT_REENTER_ROUND)
+ return
+ GLOB.client_ghost_timeouts[ckey] = max(GLOB.client_ghost_timeouts[ckey],penalty)
// needs to be done AFTER the ckey transfer, too
return ghost