From 79be3ca8cfd06a56739d7b36cc095283d64fc345 Mon Sep 17 00:00:00 2001 From: Markolie Date: Sun, 23 Oct 2016 15:18:42 +0200 Subject: [PATCH] Fix up a number of ID checks --- code/defines/procs/announce.dm | 26 +-- code/game/jobs/access.dm | 1 - .../game/machinery/computer/communications.dm | 63 ++++--- .../machinery/doors/airlock_electronics.dm | 171 +++++++++--------- .../objects/items/weapons/storage/lockbox.dm | 104 ++++++----- .../computer3/computers/communications.dm | 13 +- code/modules/mob/living/carbon/human/human.dm | 19 +- .../modules/mob/living/silicon/robot/robot.dm | 38 ++-- .../security_levels/keycard authentication.dm | 36 ++-- nano/templates/keycard_auth.tmpl | 2 +- 10 files changed, 238 insertions(+), 235 deletions(-) diff --git a/code/defines/procs/announce.dm b/code/defines/procs/announce.dm index c147bd9235c..62774ad61a7 100644 --- a/code/defines/procs/announce.dm +++ b/code/defines/procs/announce.dm @@ -60,7 +60,7 @@ Sound(message_sound) Log(message, message_title) -datum/announcement/proc/Message(message as text, message_title as text) +/datum/announcement/proc/Message(message as text, message_title as text) for(var/mob/M in player_list) if(!istype(M,/mob/new_player) && !isdeaf(M)) to_chat(M, "

[title]

") @@ -72,14 +72,14 @@ datum/announcement/proc/Message(message as text, message_title as text) to_chat(world, "[message_title]") to_chat(world, "[message]") -datum/announcement/priority/Message(message as text, message_title as text) +/datum/announcement/priority/Message(message as text, message_title as text) to_chat(world, "

[message_title]

") to_chat(world, "[message]") if(announcer) to_chat(world, " -[html_encode(announcer)]") to_chat(world, "
") -datum/announcement/priority/command/Message(message as text, message_title as text) +/datum/announcement/priority/command/Message(message as text, message_title as text) var/command command += "

[command_name()] Update

" if(message_title) @@ -91,7 +91,7 @@ datum/announcement/priority/command/Message(message as text, message_title as te if(!istype(M,/mob/new_player) && !isdeaf(M)) to_chat(M, command) -datum/announcement/priority/enemy/Message(message as text, message_title as text, from as text) +/datum/announcement/priority/enemy/Message(message as text, message_title as text, from as text) var/command command += "

[from]

" if(message_title) @@ -103,11 +103,11 @@ datum/announcement/priority/enemy/Message(message as text, message_title as text if(!istype(M,/mob/new_player) && !isdeaf(M)) to_chat(M, command) -datum/announcement/priority/security/Message(message as text, message_title as text) +/datum/announcement/priority/security/Message(message as text, message_title as text) to_chat(world, "[message_title]") to_chat(world, "[message]") -datum/announcement/proc/NewsCast(message as text, message_title as text) +/datum/announcement/proc/NewsCast(message as text, message_title as text) if(disable_newscasts) return if(!newscast) @@ -121,28 +121,28 @@ datum/announcement/proc/NewsCast(message as text, message_title as text) news.can_be_redacted = 0 announce_newscaster_news(news) -datum/announcement/proc/PlaySound(var/message_sound) +/datum/announcement/proc/PlaySound(var/message_sound) if(!message_sound) return for(var/mob/M in player_list) if(!istype(M,/mob/new_player) && !isdeaf(M)) M << message_sound -datum/announcement/proc/Sound(var/message_sound) +/datum/announcement/proc/Sound(var/message_sound) PlaySound(message_sound) -datum/announcement/priority/Sound(var/message_sound) +/datum/announcement/priority/Sound(var/message_sound) if(sound) world << sound -datum/announcement/priority/command/Sound(var/message_sound) +/datum/announcement/priority/command/Sound(var/message_sound) PlaySound(message_sound) -datum/announcement/proc/Log(message as text, message_title as text) +/datum/announcement/proc/Log(message as text, message_title as text) if(log) log_say("[key_name(usr)] has made \a [announcement_type]: [message_title] - [message] - [announcer]") message_admins("[key_name_admin(usr)] has made \a [announcement_type].", 1) - + /proc/GetNameAndAssignmentFromId(var/obj/item/weapon/card/id/I) // Format currently matches that of newscaster feeds: Registered Name (Assigned Rank) - return I.assignment ? "[I.registered_name] ([I.assignment])" : I.registered_name + return I.assignment ? "[I.registered_name] ([I.assignment])" : I.registered_name \ No newline at end of file diff --git a/code/game/jobs/access.dm b/code/game/jobs/access.dm index 8c139dabdbd..58d041b9442 100644 --- a/code/game/jobs/access.dm +++ b/code/game/jobs/access.dm @@ -129,7 +129,6 @@ var/const/access_trade_sol = 160 return 0 - /obj/item/proc/GetAccess() return list() diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index 7c77ca6099f..01608efedcb 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -1,9 +1,12 @@ - #define COMM_SCREEN_MAIN 1 #define COMM_SCREEN_STAT 2 #define COMM_SCREEN_MESSAGES 3 #define COMM_SCREEN_SECLEVEL 4 +#define COMM_AUTHENTICATION_NONE 0 +#define COMM_AUTHENTICATION_MIN 1 +#define COMM_AUTHENTICATION_MAX 2 + // The communications computer /obj/machinery/computer/communications name = "communications console" @@ -13,7 +16,7 @@ req_access = list(access_heads) circuit = /obj/item/weapon/circuitboard/communications var/prints_intercept = 1 - var/authenticated = 0 + var/authenticated = COMM_AUTHENTICATION_NONE var/list/messagetitle = list() var/list/messagetext = list() var/currmsg = 0 @@ -39,16 +42,16 @@ crew_announcement.newscast = 1 /obj/machinery/computer/communications/proc/is_authenticated(var/mob/user, var/message = 1) - if(authenticated == 2) - return 2 + if(authenticated == COMM_AUTHENTICATION_MAX) + return COMM_AUTHENTICATION_MAX else if(user.can_admin_interact()) - return 2 + return COMM_AUTHENTICATION_MAX else if(authenticated) - return 1 + return COMM_AUTHENTICATION_MIN else if(message) to_chat(user, "Access denied.") - return 0 + return COMM_AUTHENTICATION_NONE /obj/machinery/computer/communications/Topic(href, href_list) if(..(href, href_list)) @@ -62,23 +65,23 @@ if(!ishuman(usr)) to_chat(usr, "Access denied.") return - var/mob/living/carbon/human/M = usr - var/obj/item/card = M.get_active_hand() - var/obj/item/weapon/card/id/I = (card && card.GetID())||M.wear_id||M.wear_pda - if(istype(I, /obj/item/device/pda)) - var/obj/item/device/pda/pda = I - I = pda.id - if(I && istype(I)) - if(src.check_access(I)) - authenticated = 1 - if(access_captain in I.access) - authenticated = 2 - crew_announcement.announcer = GetNameAndAssignmentFromId(I) + + var/list/access = usr.get_access() + if(allowed(usr)) + authenticated = COMM_AUTHENTICATION_MIN + + if(access_captain in access) + authenticated = COMM_AUTHENTICATION_MAX + var/mob/living/carbon/human/H = usr + var/obj/item/weapon/card/id = H.get_idcard(TRUE) + if(istype(id)) + crew_announcement.announcer = GetNameAndAssignmentFromId(id) + nanomanager.update_uis(src) return if(href_list["logout"]) - authenticated = 0 + authenticated = COMM_AUTHENTICATION_NONE crew_announcement.announcer = "" setMenuState(usr,COMM_SCREEN_MAIN) nanomanager.update_uis(src) @@ -131,13 +134,13 @@ to_chat(usr, "You need to swipe your ID.") if("announce") - if(is_authenticated(usr) == 2) + if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX) if(message_cooldown) to_chat(usr, "Please allow at least one minute to pass between announcements.") nanomanager.update_uis(src) return var/input = input(usr, "Please write a message to announce to the station crew.", "Priority Announcement") - if(!input || message_cooldown || ..() || !(is_authenticated(usr) == 2)) + if(!input || message_cooldown || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)) nanomanager.update_uis(src) return crew_announcement.Announce(input) @@ -213,13 +216,13 @@ setMenuState(usr,COMM_SCREEN_STAT) if("nukerequest") - if(is_authenticated(usr) == 2) + if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX) if(centcomm_message_cooldown) to_chat(usr, "Arrays recycling. Please stand by.") nanomanager.update_uis(src) return var/input = stripped_input(usr, "Please enter the reason for requesting the nuclear self-destruct codes. Misuse of the nuclear request system will not be tolerated under any circumstances. Transmission does not guarantee a response.", "Self Destruct Code Request.","") as text|null - if(!input || ..() || !(is_authenticated(usr) == 2)) + if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)) nanomanager.update_uis(src) return Nuke_request(input, usr) @@ -232,13 +235,13 @@ setMenuState(usr,COMM_SCREEN_MAIN) if("MessageCentcomm") - if(is_authenticated(usr) == 2) + if(is_authenticated(usr) == COMM_AUTHENTICATION_MAX) if(centcomm_message_cooldown) to_chat(usr, "Arrays recycling. Please stand by.") nanomanager.update_uis(src) return var/input = stripped_input(usr, "Please choose a message to transmit to Centcomm via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "") as text|null - if(!input || ..() || !(is_authenticated(usr) == 2)) + if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)) nanomanager.update_uis(src) return Centcomm_announce(input, usr) @@ -251,13 +254,13 @@ // OMG SYNDICATE ...LETTERHEAD if("MessageSyndicate") - if((is_authenticated(usr) == 2) && (src.emagged)) + if((is_authenticated(usr) == COMM_AUTHENTICATION_MAX) && (src.emagged)) if(centcomm_message_cooldown) to_chat(usr, "Arrays recycling. Please stand by.") nanomanager.update_uis(src) return var/input = stripped_input(usr, "Please choose a message to transmit to \[ABNORMAL ROUTING CORDINATES\] via quantum entanglement. Please be aware that this process is very expensive, and abuse will lead to... termination. Transmission does not guarantee a response.", "To abort, send an empty message.", "") as text|null - if(!input || ..() || !(is_authenticated(usr) == 2)) + if(!input || ..() || !(is_authenticated(usr) == COMM_AUTHENTICATION_MAX)) nanomanager.update_uis(src) return Syndicate_announce(input, usr) @@ -518,7 +521,7 @@ return ..() shuttle_master.emergency.request(null, 0.3, null, "All communication consoles, boards, and AI's have been destroyed.") - log_game("All the AIs, comm consoles and boards are destroyed. Shuttle called.") - message_admins("All the AIs, comm consoles and boards are destroyed. Shuttle called.", 1) + log_game("All the AI's, communication consoles and boards are destroyed. Shuttle called.") + message_admins("All the AI's, communication consoles and boards are destroyed. Shuttle called.", 1) return ..() diff --git a/code/game/machinery/doors/airlock_electronics.dm b/code/game/machinery/doors/airlock_electronics.dm index 30e5cac609f..acad5a5a563 100644 --- a/code/game/machinery/doors/airlock_electronics.dm +++ b/code/game/machinery/doors/airlock_electronics.dm @@ -4,7 +4,7 @@ name = "airlock electronics" icon = 'icons/obj/doors/door_assembly.dmi' icon_state = "door_electronics" - w_class = 2 //It should be tiny! -Agouri + w_class = 2 materials = list(MAT_METAL=50, MAT_GLASS=50) req_access = list(access_engine) @@ -12,101 +12,96 @@ var/list/conf_access = null var/one_access = 0 //if set to 1, door would receive req_one_access instead of req_access var/last_configurator = null - var/locked = 1 + var/locked = TRUE + var/const/max_brain_damage = 60 // Maximum brain damage a mob can have until it can't use the electronics - attack_self(mob/user as mob) - if(!ishuman(user) && !istype(user,/mob/living/silicon/robot)) - return ..(user) +/obj/item/weapon/airlock_electronics/attack_self(mob/user) + if(!ishuman(user) && !isrobot(user)) + return ..() + if(ishuman(user)) var/mob/living/carbon/human/H = user - if(H.getBrainLoss() >= 60) + if(H.getBrainLoss() >= max_brain_damage) + to_chat(user, "You forget how to use \the [src].") return - var/t1 = text("Access control
\n") + var/t1 = text("Access control
\n") + if(last_configurator) + t1 += "Operator: [last_configurator]
" - if(last_configurator) - t1 += "Operator: [last_configurator]
" + if(locked) + t1 += "Swipe ID
" + else + t1 += "Block
" - if(locked) - t1 += "Swipe ID
" + t1 += "Access requirement is set to " + t1 += one_access ? "ONE
" : "ALL
" + + t1 += conf_access == null ? "All
" : "All
" + + t1 += "
" + + var/list/accesses = get_all_accesses() + for(var/acc in accesses) + var/aname = get_access_desc(acc) + + if(!conf_access || !conf_access.len || !(acc in conf_access)) + t1 += "[aname]
" + else if(one_access) + t1 += "[aname]
" + else + t1 += "[aname]
" + + t1 += "

Close

\n" + + var/datum/browser/popup = new(user, "airlock_electronics", name, 400, 400) + popup.set_content(t1) + popup.open(0) + onclose(user, "airlock") + +/obj/item/weapon/airlock_electronics/Topic(href, href_list) + ..() + + if(usr.incapacitated() || (!ishuman(usr) && !isrobot(usr))) + return 1 + + if(href_list["close"]) + usr << browse(null, "window=airlock") + return + + if(href_list["login"]) + if(allowed(usr)) + locked = FALSE + last_configurator = usr.name + + if(locked) + return + + if(href_list["logout"]) + locked = TRUE + + if(href_list["one_access"]) + one_access = !one_access + + if(href_list["access"]) + toggle_access(href_list["access"]) + + attack_self(usr) + +/obj/item/weapon/airlock_electronics/proc/toggle_access(var/access) + if(access == "all") + conf_access = null + else + var/req = text2num(access) + + if(conf_access == null) + conf_access = list() + + if(!(req in conf_access)) + conf_access += req else - t1 += "Block
" - - t1 += "Access requirement is set to " - t1 += one_access ? "ONE
" : "ALL
" - - t1 += conf_access == null ? "All
" : "All
" - - t1 += "
" - - var/list/accesses = get_all_accesses() - for(var/acc in accesses) - var/aname = get_access_desc(acc) - - if(!conf_access || !conf_access.len || !(acc in conf_access)) - t1 += "[aname]
" - else if(one_access) - t1 += "[aname]
" - else - t1 += "[aname]
" - - t1 += "

Close

\n" - - var/datum/browser/popup = new(user, "airlock_electronics", name, 400, 400) - popup.set_content(t1) - popup.open(0) - onclose(user, "airlock") - - Topic(href, href_list) - ..() - if(usr.stat || usr.restrained() || (!ishuman(usr) && !istype(usr,/mob/living/silicon))) - return - if(href_list["close"]) - usr << browse(null, "window=airlock") - return - - if(href_list["login"]) - if(istype(usr,/mob/living/silicon)) - src.locked = 0 - src.last_configurator = usr.name - else - var/obj/item/I = usr.get_active_hand() - if(istype(I, /obj/item/device/pda)) - var/obj/item/device/pda/pda = I - I = pda.id - if(I && src.check_access(I)) - src.locked = 0 - src.last_configurator = I:registered_name - - if(locked) - return - - if(href_list["logout"]) - locked = 1 - - if(href_list["one_access"]) - one_access = !one_access - - if(href_list["access"]) - toggle_access(href_list["access"]) - - attack_self(usr) - - proc - toggle_access(var/acc) - if(acc == "all") + conf_access -= req + if(!conf_access.len) conf_access = null - else - var/req = text2num(acc) - - if(conf_access == null) - conf_access = list() - - if(!(req in conf_access)) - conf_access += req - else - conf_access -= req - if(!conf_access.len) - conf_access = null diff --git a/code/game/objects/items/weapons/storage/lockbox.dm b/code/game/objects/items/weapons/storage/lockbox.dm index 7cc71918905..448395df3e4 100644 --- a/code/game/objects/items/weapons/storage/lockbox.dm +++ b/code/game/objects/items/weapons/storage/lockbox.dm @@ -16,41 +16,41 @@ var/icon_closed = "lockbox" var/icon_broken = "lockbox+b" - - attackby(obj/item/weapon/W as obj, mob/user as mob, params) - if(istype(W, /obj/item/weapon/card/id)) - if(src.broken) - to_chat(user, "It appears to be broken.") - return - if(src.allowed(user)) - src.locked = !( src.locked ) - if(src.locked) - src.icon_state = src.icon_locked - to_chat(user, "You lock the [src.name]!") - return - else - src.icon_state = src.icon_closed - to_chat(user, "You unlock the [src.name]!") - origin_tech = null //wipe out any origin tech if it's unlocked in any way so you can't double-dip tech levels at R&D. - return - else - to_chat(user, "Access Denied") - else if((istype(W, /obj/item/weapon/card/emag) || istype(W, /obj/item/weapon/melee/energy/blade)) && !broken) - emag_act(user) +/obj/item/weapon/storage/lockbox/attackby(obj/item/weapon/W as obj, mob/user as mob, params) + if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda)) + if(broken) + to_chat(user, "It appears to be broken.") return - if(!locked) - ..() + if(check_access(W)) + locked = !locked + if(locked) + icon_state = icon_locked + to_chat(user, "You lock \the [src]!") + return + else + icon_state = icon_closed + to_chat(user, "You unlock \the [src]!") + origin_tech = null //wipe out any origin tech if it's unlocked in any way so you can't double-dip tech levels at R&D. + return else - to_chat(user, "It's locked!") + to_chat(user, "Access denied.") + return + else if((istype(W, /obj/item/weapon/card/emag) || (istype(W, /obj/item/weapon/melee/energy/blade)) && !broken)) + emag_act(user) return + if(!locked) + ..() + else + to_chat(user, "It's locked!") + return - show_to(mob/user as mob) - if(locked) - to_chat(user, "It's locked!") - else - ..() - return +/obj/item/weapon/storage/lockbox/show_to(mob/user as mob) + if(locked) + to_chat(user, "It's locked!") + else + ..() + return /obj/item/weapon/storage/lockbox/can_be_inserted(obj/item/W as obj, stop_messages = 0) if(!locked) @@ -64,7 +64,7 @@ broken = 1 locked = 0 desc = "It appears to be broken." - icon_state = src.icon_broken + icon_state = icon_broken to_chat(user, "You unlock \the [src].") origin_tech = null //wipe out any origin tech if it's unlocked in any way so you can't double-dip tech levels at R&D. return @@ -84,23 +84,21 @@ name = "Lockbox (Mindshield Implants)" req_access = list(access_security) - New() - ..() - new /obj/item/weapon/implantcase/loyalty(src) - new /obj/item/weapon/implantcase/loyalty(src) - new /obj/item/weapon/implantcase/loyalty(src) - new /obj/item/weapon/implanter/loyalty(src) - +/obj/item/weapon/storage/lockbox/loyalty/New() + ..() + new /obj/item/weapon/implantcase/loyalty(src) + new /obj/item/weapon/implantcase/loyalty(src) + new /obj/item/weapon/implantcase/loyalty(src) + new /obj/item/weapon/implanter/loyalty(src) /obj/item/weapon/storage/lockbox/clusterbang name = "lockbox (clusterbang)" desc = "You have a bad feeling about opening this." req_access = list(access_security) - New() - ..() - new /obj/item/weapon/grenade/clusterbuster(src) - +/obj/item/weapon/storage/lockbox/clusterbang/New() + ..() + new /obj/item/weapon/grenade/clusterbuster(src) /obj/item/weapon/storage/lockbox/medal name = "medal box" @@ -116,14 +114,14 @@ icon_closed = "medalbox" icon_broken = "medalbox+b" - New() - ..() - new /obj/item/clothing/accessory/medal/gold/heroism(src) - new /obj/item/clothing/accessory/medal/silver/security(src) - new /obj/item/clothing/accessory/medal/silver/valor(src) - new /obj/item/clothing/accessory/medal/nobel_science(src) - new /obj/item/clothing/accessory/medal/bronze_heart(src) - new /obj/item/clothing/accessory/medal/conduct(src) - new /obj/item/clothing/accessory/medal/conduct(src) - new /obj/item/clothing/accessory/medal/conduct(src) - new /obj/item/clothing/accessory/medal/gold/captain(src) +/obj/item/weapon/storage/lockbox/medal/New() + ..() + new /obj/item/clothing/accessory/medal/gold/heroism(src) + new /obj/item/clothing/accessory/medal/silver/security(src) + new /obj/item/clothing/accessory/medal/silver/valor(src) + new /obj/item/clothing/accessory/medal/nobel_science(src) + new /obj/item/clothing/accessory/medal/bronze_heart(src) + new /obj/item/clothing/accessory/medal/conduct(src) + new /obj/item/clothing/accessory/medal/conduct(src) + new /obj/item/clothing/accessory/medal/conduct(src) + new /obj/item/clothing/accessory/medal/gold/captain(src) diff --git a/code/modules/computer3/computers/communications.dm b/code/modules/computer3/computers/communications.dm index 726de710a1a..a4fad8a16cb 100644 --- a/code/modules/computer3/computers/communications.dm +++ b/code/modules/computer3/computers/communications.dm @@ -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, "Access denied.") + 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 = "" diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index ed48c229b89..c3eb5ece3a8 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -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) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 7e771b2f372..335ecbcd1f6 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -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, "Access denied.") 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("[user] pets [src]!", \ "You pet [src]!") -/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() diff --git a/code/modules/security_levels/keycard authentication.dm b/code/modules/security_levels/keycard authentication.dm index 188bf7597c2..8ff0ed6eb64 100644 --- a/code/modules/security_levels/keycard authentication.dm +++ b/code/modules/security_levels/keycard authentication.dm @@ -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, "The station AI is not to interact with these devices.") 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, "Access denied.") /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 diff --git a/nano/templates/keycard_auth.tmpl b/nano/templates/keycard_auth.tmpl index 7f8f24b80eb..af58b061a9f 100644 --- a/nano/templates/keycard_auth.tmpl +++ b/nano/templates/keycard_auth.tmpl @@ -29,7 +29,7 @@ Used In File(s): \code\modules\security_levels\keycard_authentication.dm {{/if}} -

Please swipe your card to authorize the following event

+

Please swipe your card to authorize the following event:

{{:data.event}}
{{:helper.link('Back', 'close', { 'reset' : 1 })}} {{/if}}