Minor fixes and clean up

This commit is contained in:
mochi
2020-06-29 01:52:18 +02:00
parent f547c4d497
commit f37f73ef80
5 changed files with 29 additions and 19 deletions

View File

@@ -1867,6 +1867,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
#undef DELTA_CALC #undef DELTA_CALC
// Should NEVER be used in a proc that has waitfor set to FALSE/0.
#define UNTIL(X) while(!(X)) stoplag() #define UNTIL(X) while(!(X)) stoplag()
/* /*

View File

@@ -66,9 +66,7 @@
var/timeout = timeout_override || alert.timeout var/timeout = timeout_override || alert.timeout
if(timeout) if(timeout)
spawn(timeout) addtimer(CALLBACK(alert, /obj/screen/alert/.proc/do_timeout, src, category), timeout)
if(alert.timeout && alerts[category] == alert && world.time >= alert.timeout)
clear_alert(category)
alert.timeout = world.time + timeout - world.tick_lag alert.timeout = world.time + timeout - world.tick_lag
return alert return alert
@@ -98,7 +96,6 @@
var/alerttooltipstyle = "" var/alerttooltipstyle = ""
var/override_alerts = FALSE //If it is overriding other alerts of the same type var/override_alerts = FALSE //If it is overriding other alerts of the same type
/obj/screen/alert/MouseEntered(location,control,params) /obj/screen/alert/MouseEntered(location,control,params)
openToolTip(usr, src, params, title = name, content = desc, theme = alerttooltipstyle) openToolTip(usr, src, params, title = name, content = desc, theme = alerttooltipstyle)
@@ -106,6 +103,12 @@
/obj/screen/alert/MouseExited() /obj/screen/alert/MouseExited()
closeToolTip(usr) closeToolTip(usr)
/obj/screen/alert/proc/do_timeout(mob/M, category)
if(!M || !M.alerts)
return
if(timeout && M.alerts[category] == src && world.time >= timeout)
M.clear_alert(category)
//Gas alerts //Gas alerts
/obj/screen/alert/not_enough_oxy /obj/screen/alert/not_enough_oxy
@@ -590,6 +593,8 @@ so as to remain in compliance with the most up-to-date laws."
I.plane = FLOAT_PLANE + 1 I.plane = FLOAT_PLANE + 1
overlays += I overlays += I
qdel(O)
/obj/screen/alert/notify_soulstone /obj/screen/alert/notify_soulstone
name = "Soul Stone" name = "Soul Stone"
desc = "Someone is trying to capture your soul in a soul stone. Click to allow it." desc = "Someone is trying to capture your soul in a soul stone. Click to allow it."

View File

@@ -14,26 +14,27 @@ SUBSYSTEM_DEF(ghost_spawns)
/datum/controller/subsystem/ghost_spawns/fire() /datum/controller/subsystem/ghost_spawns/fire()
if(!polls_active) if(!polls_active)
return return
if(!currently_polling) // if polls_active is TRUE then this shouldn't happen, but still..
currently_polling = list()
for(var/poll in currently_polling) for(var/poll in currently_polling)
var/datum/candidate_poll/P = poll var/datum/candidate_poll/P = poll
if(P.time_left() <= 0) if(P.time_left() <= 0)
polling_finished(P) polling_finished(P)
/datum/controller/subsystem/ghost_spawns/Initialize(start_timeofday)
currently_polling = list()
return ..()
// Use this proc (SSghost_spawns.poll_candidates) instead of /proc/pollCandidates to poll for candidates! // Use this proc (SSghost_spawns.poll_candidates) instead of /proc/pollCandidates to poll for candidates!
// Should NEVER be used in a proc that has waitfor set to FALSE/0 (due to #define UNTIL)
/datum/controller/subsystem/ghost_spawns/proc/poll_candidates(question = "Would you like to play a special role?", role, antag_age_check = FALSE, poll_time = 30 SECONDS, ignore_respawnability = FALSE, min_hours = 0, flash_window = TRUE, check_antaghud = TRUE, source) /datum/controller/subsystem/ghost_spawns/proc/poll_candidates(question = "Would you like to play a special role?", role, antag_age_check = FALSE, poll_time = 30 SECONDS, ignore_respawnability = FALSE, min_hours = 0, flash_window = TRUE, check_antaghud = TRUE, source)
log_debug("Polling candidates [role ? "for [get_roletext(role)]" : "\"[question]\""] for [poll_time / 10] seconds") log_debug("Polling candidates [role ? "for [get_roletext(role)]" : "\"[question]\""] for [poll_time / 10] seconds")
// Start firing
polls_active = TRUE polls_active = TRUE
total_polls++ total_polls++
var/datum/candidate_poll/P = new(role, question, poll_time) var/datum/candidate_poll/P = new(role, question, poll_time)
currently_polling += P LAZYADD(currently_polling, P)
// We're the poll closest to completion
if(!next_poll_to_finish || poll_time < next_poll_to_finish.time_left()) if(!next_poll_to_finish || poll_time < next_poll_to_finish.time_left())
next_poll_to_finish = P next_poll_to_finish = P
@@ -43,7 +44,7 @@ SUBSYSTEM_DEF(ghost_spawns)
if(!is_eligible(M)) if(!is_eligible(M))
continue continue
M << 'sound/misc/notice2.ogg' SEND_SOUND(M, 'sound/misc/notice2.ogg')
if(flash_window) if(flash_window)
window_flash(M.client) window_flash(M.client)
@@ -67,6 +68,7 @@ SUBSYSTEM_DEF(ghost_spawns)
A.show_time_left = TRUE A.show_time_left = TRUE
A.poll = alert_poll A.poll = alert_poll
// Sign up inheritance and stacking
var/inherited_sign_up = FALSE var/inherited_sign_up = FALSE
var/num_stack = 1 var/num_stack = 1
for(var/existing_poll in currently_polling) for(var/existing_poll in currently_polling)
@@ -138,13 +140,15 @@ SUBSYSTEM_DEF(ghost_spawns)
// Called when polling is finished for a /datum/candidate_poll // Called when polling is finished for a /datum/candidate_poll
/datum/controller/subsystem/ghost_spawns/proc/polling_finished(datum/candidate_poll/P) /datum/controller/subsystem/ghost_spawns/proc/polling_finished(datum/candidate_poll/P)
// Trim players who aren't eligible anymore // Trim players who aren't eligible anymore
var/len_pre_trim = P.signed_up.len var/len_pre_trim = length(P.signed_up)
P.trim_candidates() P.trim_candidates()
log_debug("Candidate poll [P.role ? "for [get_roletext(P.role)]" : "\"[P.question]\""] finished. [len_pre_trim] players signed up, [P.signed_up.len] after trimming") log_debug("Candidate poll [P.role ? "for [get_roletext(P.role)]" : "\"[P.question]\""] finished. [len_pre_trim] players signed up, [length(P.signed_up)] after trimming")
P.finished = TRUE P.finished = TRUE
currently_polling -= P currently_polling -= P
if(!currently_polling.len)
// Determine which is the next poll closest the completion or "disable" firing if there's none
if(!length(currently_polling))
polls_active = FALSE polls_active = FALSE
next_poll_to_finish = null next_poll_to_finish = null
else if(P == next_poll_to_finish) else if(P == next_poll_to_finish)
@@ -155,9 +159,9 @@ SUBSYSTEM_DEF(ghost_spawns)
next_poll_to_finish = P2 next_poll_to_finish = P2
/datum/controller/subsystem/ghost_spawns/stat_entry(msg) /datum/controller/subsystem/ghost_spawns/stat_entry(msg)
msg += "Active: [currently_polling.len] | Total: [total_polls]" msg += "Active: [length(currently_polling)] | Total: [total_polls]"
if(next_poll_to_finish) if(next_poll_to_finish)
msg += " | Next: [DisplayTimeText(next_poll_to_finish.time_left())] ([next_poll_to_finish.signed_up.len] candidates)" msg += " | Next: [DisplayTimeText(next_poll_to_finish.time_left())] ([length(next_poll_to_finish.signed_up)] candidates)"
..(msg) ..(msg)
// The datum that describes one instance of candidate polling // The datum that describes one instance of candidate polling
@@ -190,7 +194,7 @@ SUBSYSTEM_DEF(ghost_spawns)
if(time_left() <= 0) if(time_left() <= 0)
if(!silent) if(!silent)
to_chat(M, "<span class='danger'>Sorry, you were too late for the consideration!</span>") to_chat(M, "<span class='danger'>Sorry, you were too late for the consideration!</span>")
M << 'sound/machines/buzz-sigh.ogg' SEND_SOUND(M, 'sound/machines/buzz-sigh.ogg')
return return
signed_up += M signed_up += M

View File

@@ -423,7 +423,7 @@ proc/display_roundstart_logout_report()
/datum/game_mode/proc/replace_jobbanned_player(mob/living/M, role_type) /datum/game_mode/proc/replace_jobbanned_player(mob/living/M, role_type)
var/list/mob/dead/observer/candidates = SSghost_spawns.poll_candidates("Do you want to play as a [role_type]?", role_type, FALSE, 10 SECONDS) var/list/mob/dead/observer/candidates = SSghost_spawns.poll_candidates("Do you want to play as a [role_type]?", role_type, FALSE, 10 SECONDS)
var/mob/dead/observer/theghost = null var/mob/dead/observer/theghost = null
if(candidates.len) if(length(candidates))
theghost = pick(candidates) theghost = pick(candidates)
to_chat(M, "<span class='userdanger'>Your mob has been taken over by a ghost! Appeal your job ban if you want to avoid this in the future!</span>") to_chat(M, "<span class='userdanger'>Your mob has been taken over by a ghost! Appeal your job ban if you want to avoid this in the future!</span>")
message_admins("[key_name_admin(theghost)] has taken control of ([key_name_admin(M)]) to replace a jobbanned player.") message_admins("[key_name_admin(theghost)] has taken control of ([key_name_admin(M)]) to replace a jobbanned player.")

View File

@@ -13,13 +13,13 @@
return kill() return kill()
var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a blob infested mouse?", ROLE_BLOB, TRUE, source = /mob/living/simple_animal/mouse/blobinfected) var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a blob infested mouse?", ROLE_BLOB, TRUE, source = /mob/living/simple_animal/mouse/blobinfected)
if(!candidates.len) if(!length(candidates))
return kill() return kill()
var/list/vents = list() var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in GLOB.all_vent_pumps) for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in GLOB.all_vent_pumps)
if(is_station_level(temp_vent.loc.z) && !temp_vent.welded) if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
if(temp_vent.parent.other_atmosmch.len > 50) if(length(temp_vent.parent.other_atmosmch) > 50)
vents += temp_vent vents += temp_vent
var/obj/vent = pick(vents) var/obj/vent = pick(vents)