From 2ad7eeafd83ea6ad8688173ef10d45e5c0ea9ed1 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Mon, 28 Aug 2023 23:04:14 +0100 Subject: [PATCH] Remote Access Updates remote surrender --- code/__DEFINES/ARES.dm | 4 + code/game/machinery/ARES/ARES.dm | 44 ------ code/game/machinery/ARES/ARES_procs.dm | 161 ++++++++++++-------- code/game/machinery/ARES/ARES_records.dm | 14 ++ maps/map_files/USS_Almayer/USS_Almayer.dmm | 9 +- tgui/packages/tgui/interfaces/WorkingJoe.js | 124 ++++++--------- 6 files changed, 163 insertions(+), 193 deletions(-) diff --git a/code/__DEFINES/ARES.dm b/code/__DEFINES/ARES.dm index ec84a6ab5992..6b90aa0f02bb 100644 --- a/code/__DEFINES/ARES.dm +++ b/code/__DEFINES/ARES.dm @@ -53,6 +53,10 @@ #define TICKET_REJECTED "rejected" /// Completed by WJs #define TICKET_COMPLETED "completed" +/// Granted Access Ticket +#define TICKET_GRANTED "granted" +/// Granted Access Ticket +#define TICKET_REVOKED "revoked" /// Checks for if buttons can be used, these may yet be removed and internalised to the UI programming #define TICKET_OPEN "OPEN" diff --git a/code/game/machinery/ARES/ARES.dm b/code/game/machinery/ARES/ARES.dm index 08e9e0a39498..dc9e168f4705 100644 --- a/code/game/machinery/ARES/ARES.dm +++ b/code/game/machinery/ARES/ARES.dm @@ -205,11 +205,6 @@ var/list/login_list = list() - /// If this is used to create AI Core access tickets - var/ticket_console = FALSE - var/ticket_authenticated = FALSE - var/obj/item/card/id/target_id - /obj/structure/machinery/computer/working_joe/proc/link_systems(datum/ares_link/new_link = GLOB.ares_link, override) if(link && !override) return FALSE @@ -233,42 +228,3 @@ /obj/structure/machinery/computer/working_joe/Destroy() delink() return ..() - -/obj/structure/machinery/computer/working_joe/verb/eject_id() - set category = "Object" - set name = "Eject ID Card" - set src in oview(1) - - if(!usr || usr.stat || usr.lying) - return FALSE - - if(target_id) - target_id.loc = get_turf(src) - if(!usr.get_active_hand() && istype(usr,/mob/living/carbon/human)) - usr.put_in_hands(target_id) - else - to_chat(usr, "You remove [target_id] from [src].") - target_id = null - - else - to_chat(usr, "There is nothing to remove from the console.") - return - -/obj/structure/machinery/computer/working_joe/attackby(obj/object, mob/user) - if(istype(object, /obj/item/card/id)) - if(!ticket_console) - to_chat(user, SPAN_WARNING("This console doesn't have an ID port!")) - return FALSE - if(!operable()) - to_chat(user, SPAN_NOTICE("You try to insert [object] but [src] remains silent.")) - return FALSE - if(!target_id) - if(user.drop_held_item()) - object.forceMove(src) - target_id = object - return TRUE - else - to_chat(user, "ID modification slot is full. Please remove existing card first.") - return FALSE - else - ..() diff --git a/code/game/machinery/ARES/ARES_procs.dm b/code/game/machinery/ARES/ARES_procs.dm index 682f25ec7202..9a2e0582e79d 100644 --- a/code/game/machinery/ARES/ARES_procs.dm +++ b/code/game/machinery/ARES/ARES_procs.dm @@ -32,6 +32,8 @@ GLOBAL_LIST_INIT(maintenance_categories, list( /// Working Joe stuff var/list/tickets_maintenance = list() var/list/tickets_access = list() + var/list/waiting_ids = list() + var/list/active_ids = list() /datum/ares_link/Destroy() for(var/obj/structure/machinery/ares/link in linked_systems) @@ -650,7 +652,6 @@ GLOBAL_LIST_INIT(maintenance_categories, list( /obj/structure/machinery/computer/working_joe/ui_data(mob/user) var/list/data = list() - data["ticket_console"] = ticket_console data["current_menu"] = current_menu data["last_page"] = last_menu @@ -668,8 +669,6 @@ GLOBAL_LIST_INIT(maintenance_categories, list( data["apollo_log"] = list() data["apollo_log"] += link.apollo_log - data["authenticated"] = ticket_authenticated - var/list/logged_maintenance = list() for(var/datum/ares_ticket/maintenance/maint_ticket as anything in link.tickets_maintenance) if(!istype(maint_ticket)) @@ -698,7 +697,7 @@ GLOBAL_LIST_INIT(maintenance_categories, list( for(var/datum/ares_ticket/access/access_ticket as anything in link.tickets_access) var/lock_status = TICKET_OPEN switch(access_ticket.ticket_status) - if(TICKET_REJECTED, TICKET_CANCELLED, TICKET_COMPLETED) + if(TICKET_REJECTED, TICKET_CANCELLED, TICKET_REVOKED) lock_status = TICKET_CLOSED var/list/current_ticket = list() @@ -718,19 +717,6 @@ GLOBAL_LIST_INIT(maintenance_categories, list( requesting_access += access_ticket.ticket_name data["access_tickets"] = logged_access - data["can_update_id"] = "No" - - if(!target_id) - data["id_tooltip"] = "Target ID card is missing!" - else if(!(target_id.registered_name in requesting_access) && !(ACCESS_MARINE_AI_TEMP in target_id.access)) - data["id_tooltip"] = "No existing access ticket for '[target_id.registered_name]'" - else - data["can_update_id"] = "Yes" - if(ACCESS_MARINE_AI_TEMP in target_id.access) - data["id_tooltip"] = "Revoke core access." - else - data["id_tooltip"] = "Grant core access." - return data /obj/structure/machinery/computer/working_joe/ui_static_data(mob/user) @@ -895,6 +881,23 @@ GLOBAL_LIST_INIT(maintenance_categories, list( return TRUE if("new_access") + var/obj/item/card/id/idcard = operator.get_active_hand() + var/has_id = FALSE + if(istype(idcard)) + has_id = TRUE + else if(operator.wear_id) + idcard = operator.wear_id + if(istype(idcard)) + has_id = TRUE + if(!has_id) + to_chat(operator, SPAN_WARNING("You require an ID card to request an access ticket!")) + playsound(src, 'sound/machines/buzz-two.ogg', 15, 1) + return FALSE + if(idcard.registered_name != last_login) + to_chat(operator, SPAN_WARNING("This ID card does not match the active login!")) + playsound(src, 'sound/machines/buzz-two.ogg', 15, 1) + return FALSE + var/ticket_holder var/priority_report = FALSE var/is_self = tgui_alert(operator, "Is this request for yourself?", "Ticket Holder", list("Yes", "No")) @@ -916,63 +919,93 @@ GLOBAL_LIST_INIT(maintenance_categories, list( var/confirm = alert(operator, "Please confirm the submission of your access ticket request. \n\n Priority: [priority_report ? "Yes" : "No"] \n Holder: '[ticket_holder]' \n Details: '[details]' \n\n Is this correct?", "Confirmation", "Yes", "No") if(confirm != "Yes" || !link) return FALSE - var/datum/ares_ticket/access/access_ticket = new(last_login, ticket_holder, details, priority_report) + var/datum/ares_ticket/access/access_ticket = new(last_login, ticket_holder, details, priority_report, idcard.registered_gid) + link.waiting_ids += idcard link.tickets_access += access_ticket if(priority_report) ares_apollo_talk("Priority Access Request: [ticket_holder] - ID [access_ticket.ticket_id]. Seek and resolve.") log_game("ARES: Access Ticket '\ref[access_ticket]' created by [key_name(operator)] as [last_login] with Holder '[ticket_holder]' and Details of '[details]'.") return TRUE - if("eject_id") - playsound = FALSE - eject_id() - if("apply_access") - playsound = FALSE - if(!target_id) - return FALSE - var/announce_text = "[last_login] revoked core access from [target_id.registered_name]'s ID card." - if(ACCESS_MARINE_AI_TEMP in target_id.access) - target_id.access -= ACCESS_MARINE_AI_TEMP - target_id.modification_log += "Temporary AI access revoked by [key_name(operator)]" - to_chat(operator, SPAN_NOTICE("Access revoked from [target_id.registered_name].")) - else - target_id.access += ACCESS_MARINE_AI_TEMP - target_id.modification_log += "Temporary AI access granted by [key_name(operator)]" - announce_text = "[last_login] granted core access to [target_id.registered_name]'s ID card." - to_chat(operator, SPAN_NOTICE("Access granted to [target_id.registered_name].")) - ares_apollo_talk(announce_text) - playsound(src, 'sound/machines/chime.ogg', 15, 1) - if("return_access") playsound = FALSE - var/obj/item/card/id/idcard = operator.get_active_hand() - var/real_id = TRUE - if(!istype(idcard)) - real_id = FALSE - if(operator.wear_id) - idcard = operator.wear_id - real_id = TRUE - if(!istype(idcard)) - real_id = FALSE - if(!real_id) - to_chat(operator, SPAN_WARNING("You require an ID card to return an access ticket!")) - playsound(src, 'sound/machines/buzz-two.ogg', 15, 1) - return FALSE - - if(!(ACCESS_MARINE_AI_TEMP in idcard.access)) - to_chat(operator, SPAN_WARNING("This ID card does not have an access ticket!")) - playsound(src, 'sound/machines/buzz-two.ogg', 15, 1) - return FALSE + var/datum/ares_ticket/access/access_ticket + for(var/datum/ares_ticket/access/possible_ticket in link.tickets_access) + if(possible_ticket.ticket_status != TICKET_GRANTED) + continue + if(possible_ticket.ticket_name != last_login) + continue + access_ticket = possible_ticket + break + + for(var/obj/item/card/id/identification in link.active_ids) + if(!istype(identification)) + continue + if(identification.registered_gid != access_ticket.user_id_num) + continue + + access_ticket.ticket_status = TICKET_REVOKED + identification.access -= ACCESS_MARINE_AI_TEMP + identification.modification_log += "Temporary AI Access self-returned by [key_name(operator)]." + + to_chat(operator, SPAN_NOTICE("Temporary Access Ticket surrendered.")) + playsound(src, 'sound/machines/chime.ogg', 15, 1) + ares_apollo_talk("[last_login] surrendered their access ticket.") + + authentication = get_ares_access(identification) + if(authentication) + login_list += "[last_login] at [worldtime2text()], Surrendered Temporary Access Ticket." + return TRUE - idcard.access -= ACCESS_MARINE_AI_TEMP - idcard.modification_log += "Temporary AI Access self-returned by [key_name(operator)]." - to_chat(operator, SPAN_NOTICE("Temporary Access Ticket surrendered.")) - playsound(src, 'sound/machines/chime.ogg', 15, 1) - ares_apollo_talk("[last_login] surrendered their access ticket.") - authentication = get_ares_access(idcard) + to_chat(operator, SPAN_WARNING("This ID card does not have an access ticket!")) + playsound(src, 'sound/machines/buzz-two.ogg', 15, 1) + return FALSE - if(authentication) - login_list += "[last_login] at [worldtime2text()], Surrendered Temporary Access Ticket." + if("auth_access") + playsound = FALSE + var/datum/ares_ticket/access/access_ticket = locate(params["ticket"]) + if(!access_ticket) + return FALSE + for(var/obj/item/card/id/identification in link.waiting_ids) + if(!istype(identification)) + continue + if(identification.registered_gid != access_ticket.user_id_num) + continue + identification.handle_ares_access(last_login, operator) + access_ticket.ticket_status = TICKET_GRANTED + playsound(src, 'sound/machines/chime.ogg', 15, 1) + return TRUE + for(var/obj/item/card/id/identification in link.active_ids) + if(!istype(identification)) + continue + if(identification.registered_gid != access_ticket.user_id_num) + continue + identification.handle_ares_access(last_login, operator) + access_ticket.ticket_status = TICKET_REVOKED + playsound(src, 'sound/machines/chime.ogg', 15, 1) + return TRUE + return FALSE if(playsound) playsound(src, "keyboard_alt", 15, 1) + +/obj/item/card/id/proc/handle_ares_access(logged_in, mob/user) + var/announce_text = "[logged_in] revoked core access from [registered_name]'s ID card." + var/operator = key_name(user) + var/datum/ares_link/link = GLOB.ares_link + if(logged_in == MAIN_AI_SYSTEM) + operator = "[user.ckey]/([MAIN_AI_SYSTEM])" + if(ACCESS_MARINE_AI_TEMP in access) + access -= ACCESS_MARINE_AI_TEMP + link.active_ids -= src + modification_log += "Temporary AI access revoked by [operator]" + to_chat(user, SPAN_NOTICE("Access revoked from [registered_name].")) + else + access += ACCESS_MARINE_AI_TEMP + modification_log += "Temporary AI access granted by [operator]" + announce_text = "[logged_in] granted core access to [registered_name]'s ID card." + to_chat(user, SPAN_NOTICE("Access granted to [registered_name].")) + link.waiting_ids -= src + link.active_ids += src + ares_apollo_talk(announce_text) + return TRUE diff --git a/code/game/machinery/ARES/ARES_records.dm b/code/game/machinery/ARES/ARES_records.dm index 4e2b479e71a2..65fc2b1aa762 100644 --- a/code/game/machinery/ARES/ARES_records.dm +++ b/code/game/machinery/ARES/ARES_records.dm @@ -107,3 +107,17 @@ /datum/ares_ticket/access ticket_type = ARES_RECORD_ACCESS + var/user_id_num + +/datum/ares_ticket/access/New(user, name, details, priority, global_id_num) + var/ref_holder = "\ref[src]" + var/pos = length(ref_holder) + var/new_id = "#[copytext("\ref[src]", pos - 4, pos)]" + + ticket_time = worldtime2text() + ticket_submitter = user + ticket_details = details + ticket_name = name + ticket_priority = priority + ticket_id = new_id + user_id_num = global_id_num diff --git a/maps/map_files/USS_Almayer/USS_Almayer.dmm b/maps/map_files/USS_Almayer/USS_Almayer.dmm index 85917c43a680..17c7c6c9b459 100644 --- a/maps/map_files/USS_Almayer/USS_Almayer.dmm +++ b/maps/map_files/USS_Almayer/USS_Almayer.dmm @@ -37163,8 +37163,7 @@ /obj/structure/machinery/computer/working_joe{ dir = 8; pixel_x = 17; - pixel_y = -6; - ticket_console = 1 + pixel_y = -6 }, /obj/item/storage/box/ids{ pixel_x = -4 @@ -54819,8 +54818,7 @@ }, /obj/structure/machinery/computer/working_joe{ dir = 8; - pixel_x = 17; - ticket_console = 1 + pixel_x = 17 }, /obj/structure/sign/safety/laser{ pixel_y = 24 @@ -72955,8 +72953,7 @@ }, /obj/structure/machinery/computer/working_joe{ dir = 4; - pixel_x = -17; - ticket_console = 1 + pixel_x = -17 }, /turf/open/floor/almayer/no_build{ icon_state = "ai_floors" diff --git a/tgui/packages/tgui/interfaces/WorkingJoe.js b/tgui/packages/tgui/interfaces/WorkingJoe.js index eba8c56ace91..9bdadaa47c5b 100644 --- a/tgui/packages/tgui/interfaces/WorkingJoe.js +++ b/tgui/packages/tgui/interfaces/WorkingJoe.js @@ -63,14 +63,8 @@ const Login = (props, context) => { const MainMenu = (props, context) => { const { data, act } = useBackend(context); - const { - logged_in, - access_text, - last_page, - current_menu, - access_level, - ticket_console, - } = data; + const { logged_in, access_text, last_page, current_menu, access_level } = + data; let can_request_access = 'Yes'; if (access_level === 3) { can_request_access = 'No'; @@ -198,20 +192,18 @@ const MainMenu = (props, context) => {

Task Management

- {!!ticket_console && ( - -