From 4d31e6f2a7346d8f6342946e114283384784e0eb Mon Sep 17 00:00:00 2001 From: Timberpoes Date: Fri, 15 Jan 2021 01:33:33 +0000 Subject: [PATCH] ID Card access change logging, Part 2 (#56155) I've condensed the logging into a single define, to allow ID card logging to be easily tweaked and to clean up some messy copy-pasted code. There is no longer admin messaging for Head of Staff accesses, but it's all still logged as it was before. There is a new option for the Investigate verb. Which has the complete logging history for ID card changes that are currently tracked, all in one place. Which admins can ALSO access from Get Current Logs and Get Server Logs for past rounds via id_card_changes.html --- code/__DEFINES/access.dm | 10 +++++++-- code/__DEFINES/logging.dm | 1 + code/game/machinery/computer/card.dm | 8 +++---- code/modules/admin/admin_investigate.dm | 2 +- .../file_system/programs/card.dm | 22 ++++++++++--------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/code/__DEFINES/access.dm b/code/__DEFINES/access.dm index c4398add600..dbb8ed24d60 100644 --- a/code/__DEFINES/access.dm +++ b/code/__DEFINES/access.dm @@ -142,5 +142,11 @@ #define ACCESS_MECH_SCIENCE 303 #define ACCESS_MECH_ENGINE 304 -/// A list of access levels that, when added to an ID card, will warn admins. This is currently a list of access levels that can change other access levels. -#define ACCESS_ALERT_ADMINS list(ACCESS_CHANGE_IDS, ACCESS_HOP, ACCESS_HOS, ACCESS_RD, ACCESS_CMO, ACCESS_CE) +/// A list of access levels that, when added to an ID card, will warn admins. +#define ACCESS_ALERT_ADMINS list(ACCESS_CHANGE_IDS) + +/// Logging define for ID card access changes +#define LOG_ID_ACCESS_CHANGE(user, id_card, change_description) \ + log_game("[key_name(user)] [change_description] to an ID card [(id_card.registered_name) ? "belonging to [id_card.registered_name]." : "with no registered name."]"); \ + user.investigate_log("([key_name(user)]) [change_description] to an ID card [(id_card.registered_name) ? "belonging to [id_card.registered_name]." : "with no registered name."]", INVESTIGATE_ACCESSCHANGES); \ + user.log_message("[change_description] to an ID card [(id_card.registered_name) ? "belonging to [id_card.registered_name]." : "with no registered name."]", LOG_GAME); \ diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index 168e58bcddf..fb49d8259fd 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -17,6 +17,7 @@ #define INVESTIGATE_NANITES "nanites" #define INVESTIGATE_PRESENTS "presents" #define INVESTIGATE_HYPERTORUS "hypertorus" +#define INVESTIGATE_ACCESSCHANGES "id_card_changes" // Logging types for log_message() #define LOG_ATTACK (1 << 0) diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index 601903a8fa6..d9e0202e198 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -448,8 +448,8 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) inserted_modify_id.access += access_type if(access_type in ACCESS_ALERT_ADMINS) message_admins("[ADMIN_LOOKUPFLW(usr)] just added [get_access_desc(access_type)] to an ID card [ADMIN_VV(inserted_modify_id)] [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]") - log_game("[key_name(usr)] added [get_access_desc(access_type)] to an ID card [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]") - usr.log_message("added [get_access_desc(access_type)] to an ID card [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]", LOG_GAME) + LOG_ID_ACCESS_CHANGE(usr, inserted_modify_id, "added [get_access_desc(access_type)]") + playsound(src, "terminal_type", 50, FALSE) if ("assign") if (authenticated == 2) @@ -486,8 +486,8 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) if(logged_access in inserted_modify_id.access) message_admins("[ADMIN_LOOKUPFLW(usr)] assigned the job [jobdatum.title] to an ID card [ADMIN_VV(inserted_modify_id)] [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]") break - log_game("[key_name(usr)] assigned the job [jobdatum.title] to an ID card [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]") - usr.log_message("assigned the job [jobdatum.title] to an ID card [(inserted_modify_id.registered_name) ? "belonging to [inserted_modify_id.registered_name]." : "with no registered name."]", LOG_GAME) + LOG_ID_ACCESS_CHANGE(usr, inserted_modify_id, "assigned the job [jobdatum.title]") + if (inserted_modify_id) inserted_modify_id.assignment = t1 playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE) diff --git a/code/modules/admin/admin_investigate.dm b/code/modules/admin/admin_investigate.dm index 974f8a7f9f2..cc33538781f 100644 --- a/code/modules/admin/admin_investigate.dm +++ b/code/modules/admin/admin_investigate.dm @@ -10,7 +10,7 @@ if(!holder) return - var/list/investigates = list(INVESTIGATE_RESEARCH, INVESTIGATE_EXONET, INVESTIGATE_PORTAL, INVESTIGATE_SINGULO, INVESTIGATE_WIRES, INVESTIGATE_TELESCI, INVESTIGATE_GRAVITY, INVESTIGATE_RECORDS, INVESTIGATE_CARGO, INVESTIGATE_SUPERMATTER, INVESTIGATE_ATMOS, INVESTIGATE_EXPERIMENTOR, INVESTIGATE_BOTANY, INVESTIGATE_HALLUCINATIONS, INVESTIGATE_RADIATION, INVESTIGATE_NANITES, INVESTIGATE_PRESENTS, INVESTIGATE_HYPERTORUS) + var/list/investigates = list(INVESTIGATE_RESEARCH, INVESTIGATE_EXONET, INVESTIGATE_PORTAL, INVESTIGATE_SINGULO, INVESTIGATE_WIRES, INVESTIGATE_TELESCI, INVESTIGATE_GRAVITY, INVESTIGATE_RECORDS, INVESTIGATE_CARGO, INVESTIGATE_SUPERMATTER, INVESTIGATE_ATMOS, INVESTIGATE_EXPERIMENTOR, INVESTIGATE_BOTANY, INVESTIGATE_HALLUCINATIONS, INVESTIGATE_RADIATION, INVESTIGATE_NANITES, INVESTIGATE_PRESENTS, INVESTIGATE_HYPERTORUS, INVESTIGATE_ACCESSCHANGES) var/list/logs_present = list("notes, memos, watchlist") var/list/logs_missing = list("---") diff --git a/code/modules/modular_computers/file_system/programs/card.dm b/code/modules/modular_computers/file_system/programs/card.dm index 0045cb3d66f..4a11c471854 100644 --- a/code/modules/modular_computers/file_system/programs/card.dm +++ b/code/modules/modular_computers/file_system/programs/card.dm @@ -217,8 +217,7 @@ if(logged_access in new_access) message_admins("[ADMIN_LOOKUPFLW(user)] assigned the job [job.title] to an ID card [ADMIN_VV(target_id_card)] [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") break - log_game("[key_name(user)] assigned the job [job.title] to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") - user.log_message("assigned the job [job.title] to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]", LOG_GAME) + LOG_ID_ACCESS_CHANGE(usr, target_id_card, "assigned the job [job.title]") target_id_card.access -= get_all_centcom_access() + get_all_accesses() target_id_card.access |= new_access target_id_card.assignment = target @@ -236,8 +235,7 @@ target_id_card.access |= access_type if(access_type in ACCESS_ALERT_ADMINS) message_admins("[ADMIN_LOOKUPFLW(user)] just added [get_access_desc(access_type)] to an ID card [ADMIN_VV(target_id_card)] [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") - log_game("[key_name(user)] added [get_access_desc(access_type)] to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") - user.log_message("added [get_access_desc(access_type)] to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]", LOG_GAME) + LOG_ID_ACCESS_CHANGE(user, target_id_card, "added [get_access_desc(access_type)]") playsound(computer, "terminal_type", 50, FALSE) return TRUE if("PRG_grantall") @@ -245,9 +243,8 @@ return target_id_card.access |= (is_centcom ? get_all_centcom_access() : get_all_accesses()) - log_game("[key_name(user)] added All Access permissions to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") - user.log_message("added All Access permissions to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]", LOG_GAME) message_admins("[ADMIN_LOOKUPFLW(user)] just added All Access to an ID card [ADMIN_VV(target_id_card)] [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") + LOG_ID_ACCESS_CHANGE(user, target_id_card, "added All Access") playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE) return TRUE @@ -263,11 +260,16 @@ var/region = text2num(params["region"]) if(isnull(region)) return - target_id_card.access |= get_region_accesses(region) - log_game("[key_name(user)] added [get_region_accesses_name(region)] region access to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") - user.log_message("added [get_region_accesses_name(region)] region access to an ID card [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]", LOG_GAME) - message_admins("[ADMIN_LOOKUPFLW(user)] just added [get_region_accesses_name(region)] region access to an ID card [ADMIN_VV(target_id_card)] [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") + var/list/region_accesses = get_region_accesses(region) + target_id_card.access |= region_accesses + + for(var/logged_access in ACCESS_ALERT_ADMINS) + if(logged_access in region_accesses) + message_admins("[ADMIN_LOOKUPFLW(user)] just added [get_region_accesses_name(region)] region access to an ID card [ADMIN_VV(target_id_card)] [(target_id_card.registered_name) ? "belonging to [target_id_card.registered_name]." : "with no registered name."]") + + LOG_ID_ACCESS_CHANGE(user, target_id_card, "added [get_region_accesses_name(region)] region access") + playsound(computer, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE) return TRUE