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

Keycard authenticators now authenticate keycards #2721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 15 additions & 4 deletions code/modules/security_levels/keycard_authentication.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
var/datum/callback/ev
var/event = ""
var/obj/machinery/keycard_auth/event_source
///Triggering ID card relayed to auth devices to make sure two keycards are used.
var/obj/item/card/id/triggering_card
var/mob/triggerer = null
var/waiting = 0

Expand Down Expand Up @@ -65,34 +67,43 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
/obj/machinery/keycard_auth/ui_act(action, params)
if(..() || waiting || !allowed(usr))
return
var/obj/item/card/swipe_id = usr.get_idcard()
if(!swipe_id || !istype(swipe_id))
to_chat(usr, "<span class='warning'>No ID card detected.</span>")
return
switch(action)
if("red_alert")
if(!event_source)
sendEvent(KEYCARD_RED_ALERT)
sendEvent(KEYCARD_RED_ALERT, swipe_id)
. = TRUE
if("emergency_maint")
if(!event_source)
sendEvent(KEYCARD_EMERGENCY_MAINTENANCE_ACCESS)
sendEvent(KEYCARD_EMERGENCY_MAINTENANCE_ACCESS, swipe_id)
. = TRUE
if("auth_swipe")
if(event_source)
if(swipe_id == event_source.triggering_card)
to_chat(usr, "<span class='warning'>Invalid ID. Confirmation ID must not equal trigger ID.</span>")
return
event_source.trigger_event(usr)
event_source = null
. = TRUE
if("bsa_unlock")
if(!event_source)
sendEvent(KEYCARD_BSA_UNLOCK)
sendEvent(KEYCARD_BSA_UNLOCK, swipe_id)
. = TRUE

/obj/machinery/keycard_auth/proc/sendEvent(event_type)
/obj/machinery/keycard_auth/proc/sendEvent(event_type, obj/item/card/id/swipe_id)
triggerer = usr
triggering_card = swipe_id //Shouldn't need qdel registering due to very short time before this var resets.
event = event_type
waiting = 1
GLOB.keycard_events.fireEvent("triggerEvent", src)
addtimer(CALLBACK(src, PROC_REF(eventSent)), 20)

/obj/machinery/keycard_auth/proc/eventSent()
triggerer = null
triggering_card = null
event = ""
waiting = 0

Expand Down
Loading