From de68aa95719c94dde67867419140a354602ff72f Mon Sep 17 00:00:00 2001 From: oranges Date: Wed, 6 Jun 2018 21:09:59 +1200 Subject: [PATCH 1/2] Individual Logs now follow the client around automatically (#37790) The logging is now stored in the persistent client/player_details datum, that will survive an entire round The existing mob log is retained and a new admin verb is added to access it. It will only show logs for the mob in question, across all players who possibly spent time in that mob A new log type is added that tracks the mobs the player changes across into and the times they occured, to better help admins manage complex situations, this also appears in the mob log as a record of the players who entered/exited control of the mob --- code/__DEFINES/logging.dm | 5 +- code/_globalvars/logging.dm | 2 - code/modules/admin/admin.dm | 6 ++- code/modules/admin/topic.dm | 2 +- .../modules/admin/verbs/individual_logging.dm | 46 +++++++++++++------ code/modules/client/player_details.dm | 3 +- code/modules/mob/dead/observer/observer.dm | 1 - code/modules/mob/login.dm | 5 +- code/modules/mob/logout.dm | 3 +- code/modules/mob/mob.dm | 1 + code/modules/mob/mob_helpers.dm | 6 +++ code/modules/projectiles/projectile/magic.dm | 1 - 12 files changed, 55 insertions(+), 26 deletions(-) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index 6d7cf12789..197c315f78 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -20,4 +20,7 @@ #define INDIVIDUAL_SAY_LOG "Say log" #define INDIVIDUAL_EMOTE_LOG "Emote log" #define INDIVIDUAL_OOC_LOG "OOC log" -#define INDIVIDUAL_SHOW_ALL_LOG "All logs" \ No newline at end of file +#define INDIVIDUAL_OWNERSHIP_LOG "Ownership log" +#define INDIVIDUAL_SHOW_ALL_LOG "All logs" +#define LOGSRC_CLIENT "Client" +#define LOGSRC_MOB "Mob" diff --git a/code/_globalvars/logging.dm b/code/_globalvars/logging.dm index 545ffbcbef..e00e4775ac 100644 --- a/code/_globalvars/logging.dm +++ b/code/_globalvars/logging.dm @@ -41,6 +41,4 @@ GLOBAL_PROTECT(OOClog) GLOBAL_LIST_EMPTY(adminlog) GLOBAL_PROTECT(adminlog) -GLOBAL_LIST_EMPTY(individual_log_list) // Logs each mob individual logs, a global so it doesn't get lost on cloning/changing mobs - GLOBAL_LIST_EMPTY(active_turfs_startlist) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index d67bbfd6c5..7958e8e943 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -63,7 +63,11 @@ body += "PM - " body += "SM - " body += "FLW - " - body += "LOGS\]
" + //Default to client logs if available + var/source = LOGSRC_MOB + if(M.client) + source = LOGSRC_CLIENT + body += "LOGS\]
" body += "Mob type = [M.type]

" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index b4d92b1fbe..0eacdd5c5e 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1905,7 +1905,7 @@ to_chat(usr, "This can only be used on instances of type /mob.") return - show_individual_logging_panel(M, href_list["log_type"]) + show_individual_logging_panel(M, href_list["log_src"], href_list["log_type"]) else if(href_list["languagemenu"]) if(!check_rights(R_ADMIN)) return diff --git a/code/modules/admin/verbs/individual_logging.dm b/code/modules/admin/verbs/individual_logging.dm index 50b00da9a6..df151cfef9 100644 --- a/code/modules/admin/verbs/individual_logging.dm +++ b/code/modules/admin/verbs/individual_logging.dm @@ -1,32 +1,52 @@ -/proc/show_individual_logging_panel(mob/M, type = INDIVIDUAL_ATTACK_LOG) +/proc/show_individual_logging_panel(mob/M, source = LOGSRC_CLIENT, type = INDIVIDUAL_ATTACK_LOG) if(!M || !ismob(M)) return - var/dat = "
Attack log | " - dat += "Say log | " - dat += "Emote log | " - dat += "OOC log | " - dat += "Show all | " - dat += "Refresh
" + + //Add client links + var/dat = "" + if(M.client) + dat += "

Client

" + dat += "
Attack log | " + dat += "Say log | " + dat += "Emote log | " + dat += "OOC log | " + dat += "Show all | " + dat += "Refresh
" + else + dat += "

No client attached to mob

" + + dat += "
" + dat += "

Mob

" + //Add the links for the mob specific log + dat += "
Attack log | " + dat += "Say log | " + dat += "Emote log | " + dat += "OOC log | " + dat += "Show all | " + dat += "Refresh
" dat += "
" + var/log_source = M.logging; + if(source == LOGSRC_CLIENT && M.client) //if client doesn't exist just fall back to the mob log + log_source = M.client.player_details.logging //should exist, if it doesn't that's a bug, don't check for it not existing if(type == INDIVIDUAL_SHOW_ALL_LOG) - dat += "
Displaying all logs of [key_name(M)]


" - for(var/log_type in M.logging) + dat += "
Displaying all [source] logs of [key_name(M)]


" + for(var/log_type in log_source) dat += "
[log_type]

" - var/list/reversed = M.logging[log_type] + var/list/reversed = log_source[log_type] if(islist(reversed)) reversed = reverseRange(reversed.Copy()) for(var/entry in reversed) dat += "[entry]: [reversed[entry]]
" dat += "
" else - dat += "
[type] of [key_name(M)]

" - var/list/reversed = M.logging[type] + dat += "
[source] [type] of [key_name(M)]

" + var/list/reversed = log_source[type] if(reversed) reversed = reverseRange(reversed.Copy()) for(var/entry in reversed) dat += "[entry]: [reversed[entry]]
" - usr << browse(dat, "window=invidual_logging_[M];size=600x480") + usr << browse(dat, "window=invidual_logging_[key_name(M)];size=600x480") diff --git a/code/modules/client/player_details.dm b/code/modules/client/player_details.dm index a842607235..ecc113b89c 100644 --- a/code/modules/client/player_details.dm +++ b/code/modules/client/player_details.dm @@ -1,2 +1,3 @@ /datum/player_details - var/list/player_actions = list() \ No newline at end of file + var/list/player_actions = list() + var/list/logging = list(INDIVIDUAL_ATTACK_LOG, INDIVIDUAL_SAY_LOG, INDIVIDUAL_EMOTE_LOG, INDIVIDUAL_OOC_LOG) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index e11a4fc886..5715a1fe87 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -79,7 +79,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) var/mob/body = loc if(ismob(body)) T = get_turf(body) //Where is the body located? - logging = body.logging //preserve our logs by copying them to our ghost gender = body.gender if(body.mind && body.mind.name) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 6dd8b73a4b..80af604d99 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -48,7 +48,4 @@ for(var/datum/action/A in client.player_details.player_actions) A.Grant(src) - if(!GLOB.individual_log_list[ckey]) - GLOB.individual_log_list[ckey] = logging - else - logging = GLOB.individual_log_list[ckey] + log_message("Client [key_name(src)] has taken ownership of mob [src]", INDIVIDUAL_OWNERSHIP_LOG) diff --git a/code/modules/mob/logout.dm b/code/modules/mob/logout.dm index aadb7e6d58..fbd29e86a5 100644 --- a/code/modules/mob/logout.dm +++ b/code/modules/mob/logout.dm @@ -1,4 +1,5 @@ /mob/Logout() + log_message("[key_name(src)] is no longer owning mob [src]", INDIVIDUAL_OWNERSHIP_LOG) SStgui.on_logout(src) unset_machine() GLOB.player_list -= src @@ -8,4 +9,4 @@ if(loc) loc.on_log(FALSE) - return TRUE \ No newline at end of file + return TRUE diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index c9ec43c387..97823c9c71 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -785,6 +785,7 @@ //This will update a mob's name, real_name, mind.name, GLOB.data_core records, pda, id and traitor text //Calling this proc without an oldname will only update the mob and skip updating the pda, id and records ~Carn /mob/proc/fully_replace_character_name(oldname,newname) + log_message("[src] name changed from [oldname] to [newname]", INDIVIDUAL_OWNERSHIP_LOG) if(!newname) return 0 real_name = newname diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 8ef39f3b06..95d882cdbd 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -477,12 +477,18 @@ It's fairly easy to fix if dealing with single letters but not so much with comp if(!LAZYLEN(message) || !message_type) return + if(client) + if(!islist(client.player_details.logging[message_type])) + client.player_details.logging[message_type] = list() + if(!islist(logging[message_type])) logging[message_type] = list() var/list/timestamped_message = list("[LAZYLEN(logging[message_type]) + 1]\[[time_stamp()]\] [key_name(src)]" = message) logging[message_type] += timestamped_message + if(client) + client.player_details.logging[message_type] += timestamped_message /mob/proc/can_hear() . = TRUE diff --git a/code/modules/projectiles/projectile/magic.dm b/code/modules/projectiles/projectile/magic.dm index cf06f55e79..94d4d49ded 100644 --- a/code/modules/projectiles/projectile/magic.dm +++ b/code/modules/projectiles/projectile/magic.dm @@ -231,7 +231,6 @@ if(!new_mob) return new_mob.grant_language(/datum/language/common) - new_mob.logging = M.logging // Some forms can still wear some items for(var/obj/item/W in contents)