Fix up a number of ID checks

This commit is contained in:
Markolie
2016-10-23 15:18:42 +02:00
parent 570b9b7ec0
commit 79be3ca8cf
10 changed files with 238 additions and 235 deletions
@@ -66,16 +66,21 @@
if("main" in href_list)
state = STATE_DEFAULT
if("login" in href_list)
var/mob/M = usr
var/obj/item/I = M.get_active_hand()
if(!ishuman(usr))
to_chat(usr, "<span class='warning'>Access denied.</span>")
return
var/mob/living/carbon/human/H = usr
var/obj/item/I = H.get_active_hand()
if(I)
I = I.GetID()
if(istype(I,/obj/item/weapon/card/id) && check_access(I))
authenticated = 1
if(access_captain in I.GetAccess())
authenticated = 2
crew_announcement.announcer = GetNameAndAssignmentFromId(I)
var/obj/item/weapon/card/id = H.get_idcard(TRUE)
if(istype(id))
crew_announcement.announcer = GetNameAndAssignmentFromId(id)
if("logout" in href_list)
authenticated = 0
crew_announcement.announcer = ""
+17 -2
View File
@@ -709,12 +709,19 @@
if(!.) . = if_no_id //to prevent null-names making the mob unclickable
return
//gets ID card object from special clothes slot or null.
/mob/living/carbon/human/proc/get_idcard()
//gets ID card object from special clothes slot or, if applicable, hands as well
/mob/living/carbon/human/proc/get_idcard(var/check_hands = FALSE)
var/obj/item/weapon/card/id/id = wear_id
var/obj/item/device/pda/pda = wear_id
if(istype(pda) && pda.id)
id = pda.id
if(check_hands)
if(istype(get_active_hand(), /obj/item/weapon/card/id))
id = get_active_hand()
else if(istype(get_inactive_hand(), /obj/item/weapon/card/id))
id = get_inactive_hand()
if(istype(id))
return id
@@ -1977,6 +1984,12 @@
var/obj/item/weapon/card/id/id = wear_id
if(istype(id) && id.is_untrackable())
return 0
if(wear_pda)
var/obj/item/device/pda/pda = wear_pda
if(istype(pda))
var/obj/item/weapon/card/id/id = pda.id
if(istype(id) && id.is_untrackable())
return 0
if(istype(head, /obj/item/clothing/head))
var/obj/item/clothing/head/hat = head
if(hat.blockTracking)
@@ -1992,6 +2005,8 @@
if(wear_id)
. |= wear_id.GetAccess()
if(wear_pda)
. |= wear_pda.GetAccess()
if(istype(w_uniform, /obj/item/clothing/under))
var/obj/item/clothing/under/U = w_uniform
if(U.accessories)
+12 -26
View File
@@ -730,18 +730,18 @@ var/list/robot_verbs_default = list(
else
to_chat(user, "Unable to locate a radio.")
else if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) // trying to unlock the interface with an ID card
else if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda)) // trying to unlock the interface with an ID card
if(emagged)//still allow them to open the cover
to_chat(user, "The interface seems slightly damaged")
to_chat(user, "The interface seems slightly damaged.")
if(opened)
to_chat(user, "You must close the cover to swipe an ID card.")
else
if(allowed(usr))
if(allowed(W))
locked = !locked
to_chat(user, "You [ locked ? "lock" : "unlock"] [src]'s interface.")
update_icons()
else
to_chat(user, "\red Access denied.")
to_chat(user, "<span class='warning'>Access denied.</span>")
else if(istype(W, /obj/item/borg/upgrade/))
var/obj/item/borg/upgrade/U = W
@@ -957,29 +957,15 @@ var/list/robot_verbs_default = list(
user.visible_message("<span class='notice'>[user] pets [src]!</span>", \
"<span class='notice'>You pet [src]!</span>")
/mob/living/silicon/robot/proc/allowed(mob/M)
//check if it doesn't require any access at all
if(check_access(null))
/mob/living/silicon/robot/proc/allowed(obj/item/I)
var/obj/dummy = new /obj(null) // Create a dummy object to check access on as to avoid having to snowflake check_access on every mob
dummy.req_access = req_access
if(dummy.check_access(I))
qdel(dummy)
return 1
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
//if they are holding or wearing a card that has access, that works
if(check_access(H.get_active_hand()) || check_access(H.wear_id))
return 1
return 0
/mob/living/silicon/robot/proc/check_access(obj/item/weapon/card/id/I)
if(!istype(req_access, /list)) //something's very wrong
return 1
var/list/L = req_access
if(!L.len) //no requirements
return 1
if(!I || !istype(I, /obj/item/weapon/card/id) || !I.access) //not ID or no access
return 0
for(var/req in req_access)
if(req in I.access) //have one of the required accesses
return 1
qdel(dummy)
return 0
/mob/living/silicon/robot/update_icons()
@@ -3,6 +3,7 @@
desc = "This device is used to trigger station functions, which require more than one ID card to authenticate."
icon = 'icons/obj/monitors.dmi'
icon_state = "auth_off"
var/active = 0 //This gets set to 1 on all devices except the one where the initial request was made.
var/event = ""
var/screen = 1
@@ -14,25 +15,25 @@
var/mob/event_triggered_by
var/mob/event_confirmed_by
var/ert_reason = "Reason for ERT"
//1 = select event
//2 = authenticate
anchored = 1.0
anchored = 1
use_power = 1
idle_power_usage = 2
active_power_usage = 6
power_channel = ENVIRON
req_access = list(access_keycard_auth)
/obj/machinery/keycard_auth/attack_ai(mob/user as mob)
to_chat(user, "The station AI is not to interact with these devices.")
to_chat(user, "<span class='warning'>The station AI is not to interact with these devices.</span>")
return
/obj/machinery/keycard_auth/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
if(stat & (NOPOWER|BROKEN))
to_chat(user, "This device is not powered.")
return
if(istype(W,/obj/item/weapon/card/id))
var/obj/item/weapon/card/id/ID = W
if(access_keycard_auth in ID.access)
if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda))
if(check_access(W))
if(active == 1)
//This is not the device that made the initial request. It is the device confirming the request.
if(event_source)
@@ -44,6 +45,8 @@
return
event_triggered_by = usr
broadcast_request() //This is the device making the initial event request. It needs to broadcast to other devices
else
to_chat(user, "<span class='warning'>Access denied.</span>")
/obj/machinery/keycard_auth/power_change()
if(powered(ENVIRON))
@@ -51,16 +54,16 @@
icon_state = "auth_off"
else
stat |= NOPOWER
/obj/machinery/keycard_auth/attack_ghost(mob/user)
ui_interact(user)
/obj/machinery/keycard_auth/attack_hand(mob/user as mob)
if(!user.IsAdvancedToolUser())
return 0
if(..())
return 1
ui_interact(user)
/obj/machinery/keycard_auth/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(user.stat || stat & (NOPOWER|BROKEN))
to_chat(user, "This device is not powered.")
return
if(busy)
to_chat(user, "This device is busy.")
return
@@ -74,19 +77,18 @@
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "keycard_auth.tmpl", "Keycard Authentication Device UI", 520, 320)
ui = new(user, src, ui_key, "keycard_auth.tmpl", "Keycard Authentication Device UI", 540, 320)
ui.set_initial_data(data)
ui.open()
/obj/machinery/keycard_auth/Topic(href, href_list)
if(..())
return
return 1
if(busy)
to_chat(usr, "This device is busy.")
return
if(usr.stat || stat & (BROKEN|NOPOWER))
to_chat(usr, "This device is without power.")
return
if(href_list["triggerevent"])
event = href_list["triggerevent"]
screen = 2