mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 16:18:01 +01:00
[MIRROR] Limit how often you can use the emergency shuttle console (#113)
* Limit how often you can use the emergency shuttle console (#52522) * Limit how often you can use the emergency shuttle console * Add QDELETED check * Limit how often you can use the emergency shuttle console Co-authored-by: Jared-Fogle <35135081+Jared-Fogle@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define ENGINES_START_TIME 100
|
||||
#define ENGINES_STARTED (SSshuttle.emergency.mode == SHUTTLE_IGNITING)
|
||||
#define IS_DOCKED (SSshuttle.emergency.mode == SHUTTLE_DOCKED || (ENGINES_STARTED))
|
||||
#define SHUTTLE_CONSOLE_ACTION_DELAY (5 SECONDS)
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle
|
||||
name = "emergency shuttle console"
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
var/auth_need = 3
|
||||
var/list/authorized = list()
|
||||
var/list/acted_recently = list()
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/attackby(obj/item/I, mob/user,params)
|
||||
if(istype(I, /obj/item/card/id))
|
||||
@@ -21,13 +23,12 @@
|
||||
return GLOB.human_adjacent_state
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/ui_interact(mob/user, datum/tgui/ui)
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "EmergencyShuttleConsole", name)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/ui_data()
|
||||
/obj/machinery/computer/emergency_shuttle/ui_data(user)
|
||||
var/list/data = list()
|
||||
|
||||
data["timer_str"] = SSshuttle.emergency.getTimerStr()
|
||||
@@ -45,7 +46,7 @@
|
||||
A += list(list("name" = name, "job" = job))
|
||||
data["authorizations"] = A
|
||||
|
||||
data["enabled"] = (IS_DOCKED && !ENGINES_STARTED)
|
||||
data["enabled"] = (IS_DOCKED && !ENGINES_STARTED) && !(user in acted_recently)
|
||||
data["emagged"] = obj_flags & EMAGGED ? 1 : 0
|
||||
return data
|
||||
|
||||
@@ -70,7 +71,11 @@
|
||||
to_chat(user, "<span class='warning'>The access level of your card is not high enough.</span>")
|
||||
return
|
||||
|
||||
if (user in acted_recently)
|
||||
return
|
||||
|
||||
var/old_len = authorized.len
|
||||
addtimer(CALLBACK(src, .proc/clear_recent_action, user), SHUTTLE_CONSOLE_ACTION_DELAY)
|
||||
|
||||
switch(action)
|
||||
if("authorize")
|
||||
@@ -95,6 +100,9 @@
|
||||
if(repeal)
|
||||
minor_announce("Early launch authorization revoked, [remaining] authorizations needed")
|
||||
|
||||
acted_recently += user
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/proc/authorize(mob/user, source)
|
||||
var/obj/item/card/id/ID = user.get_idcard(TRUE)
|
||||
|
||||
@@ -113,6 +121,11 @@
|
||||
. = TRUE
|
||||
process()
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/proc/clear_recent_action(mob/user)
|
||||
acted_recently -= user
|
||||
if (!QDELETED(user))
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/emergency_shuttle/process()
|
||||
// Launch check is in process in case auth_need changes for some reason
|
||||
// probably external.
|
||||
@@ -595,3 +608,4 @@
|
||||
#undef ENGINES_START_TIME
|
||||
#undef ENGINES_STARTED
|
||||
#undef IS_DOCKED
|
||||
#undef SHUTTLE_CONSOLE_ACTION_DELAY
|
||||
|
||||
Reference in New Issue
Block a user