From c7d1c9d8e8bf343e2f802316f8267491d65ed1d7 Mon Sep 17 00:00:00 2001 From: keronshb Date: Wed, 7 Jul 2021 21:12:44 -0400 Subject: [PATCH] Ports Stripping log when dc'd --- code/__DEFINES/inventory.dm | 12 ++++++++ code/__HELPERS/_lists.dm | 2 ++ .../mob/living/carbon/human/human_defines.dm | 3 ++ code/modules/mob/living/carbon/human/login.dm | 30 +++++++++++++++++++ code/modules/mob/living/living.dm | 13 ++++++++ 5 files changed, 60 insertions(+) diff --git a/code/__DEFINES/inventory.dm b/code/__DEFINES/inventory.dm index 649e0a029b..7b727fcc5a 100644 --- a/code/__DEFINES/inventory.dm +++ b/code/__DEFINES/inventory.dm @@ -159,6 +159,18 @@ #define TINT_DARKENED 2 //Threshold of tint level to apply weld mask overlay #define TINT_BLIND 3 //Threshold of tint level to obscure vision fully +// defines for AFK theft +/// How many messages you can remember while logged out before you stop remembering new ones +#define AFK_THEFT_MAX_MESSAGES 10 +/// If someone logs back in and there are entries older than this, just tell them they can't remember who it was or when +#define AFK_THEFT_FORGET_DETAILS_TIME 5 MINUTES +/// The index of the entry in 'afk_thefts' with the person's visible name at the time +#define AFK_THEFT_NAME 1 +/// The index of the entry in 'afk_thefts' with the text +#define AFK_THEFT_MESSAGE 2 +/// The index of the entry in 'afk_thefts' with the time it happened +#define AFK_THEFT_TIME 3 + //Allowed equipment lists for security vests and hardsuits. GLOBAL_LIST_INIT(advanced_hardsuit_allowed, typecacheof(list( diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 7e2abebcf9..2d0601d839 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -19,6 +19,8 @@ #define LAZYACCESS(L, I) (L ? (isnum(I) ? (I > 0 && I <= length(L) ? L[I] : null) : L[I]) : null) #define LAZYSET(L, K, V) if(!L) { L = list(); } L[K] = V; #define LAZYLEN(L) length(L) +//Sets a list to null +#define LAZYNULL(L) L = null #define LAZYCLEARLIST(L) if(L) L.Cut() #define SANITIZE_LIST(L) ( islist(L) ? L : list() ) #define reverseList(L) reverseRange(L.Copy()) diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 6f1fe57df3..50d4402041 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -52,6 +52,9 @@ var/obj/item/l_store = null var/obj/item/s_store = null + /// When an braindead player has their equipment fiddled with, we log that info here for when they come back so they know who took their ID while they were DC'd for 30 seconds + var/list/afk_thefts + var/special_voice = "" // For changing our voice. Used by a symptom. var/bleedsuppress = 0 //for stopping bloodloss, eventually this will be limb-based like bleeding diff --git a/code/modules/mob/living/carbon/human/login.dm b/code/modules/mob/living/carbon/human/login.dm index a89921143a..ebf76eeafa 100644 --- a/code/modules/mob/living/carbon/human/login.dm +++ b/code/modules/mob/living/carbon/human/login.dm @@ -2,3 +2,33 @@ ..() if(dna?.species?.has_field_of_vision && CONFIG_GET(flag/use_field_of_vision)) LoadComponent(/datum/component/field_of_vision, field_of_vision_type) + + if(!LAZYLEN(afk_thefts)) + return + + var/list/print_msg = list() + print_msg += "*---------*" + print_msg += "As you snap back to consciousness, you recall people messing with your stuff..." + + afk_thefts = reverseRange(afk_thefts) + + for(var/list/iter_theft as anything in afk_thefts) + if(!islist(iter_theft) || LAZYLEN(iter_theft) != AFK_THEFT_TIME) + stack_trace("[src] ([ckey]) returned to their body and had a null/malformed afk_theft entry. Contents: [json_encode(iter_theft)]") + continue + + var/thief_name = iter_theft[AFK_THEFT_NAME] + var/theft_message = iter_theft[AFK_THEFT_MESSAGE] + var/time_since = world.time - iter_theft[AFK_THEFT_TIME] + + if(time_since > AFK_THEFT_FORGET_DETAILS_TIME) + print_msg += "\tSomeone [theft_message], but it was at least [DisplayTimeText(AFK_THEFT_FORGET_DETAILS_TIME)] ago." + else + print_msg += "\t[thief_name] [theft_message] roughly [DisplayTimeText(time_since, 10)] ago." + + if(LAZYLEN(afk_thefts) >= AFK_THEFT_MAX_MESSAGES) + print_msg += "There may have been more, but that's all you can remember..." + print_msg += "*---------*" + + to_chat(src, print_msg.Join("\n")) + LAZYNULL(afk_thefts) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index b0d340eed0..a3e6b28fd6 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -911,6 +911,12 @@ "[src] tries to remove your [what.name].", target = src, target_message = "You try to remove [who]'s [what.name].") what.add_fingerprint(src) + if(ishuman(who)) + var/mob/living/carbon/human/victim_human = who + if(victim_human.key && !victim_human.client) // AKA braindead + if(victim_human.stat <= SOFT_CRIT && LAZYLEN(victim_human.afk_thefts) <= AFK_THEFT_MAX_MESSAGES) + var/list/new_entry = list(list(src.name, "tried unequipping your [what]", world.time)) + LAZYADD(victim_human.afk_thefts, new_entry) else to_chat(src,"You try to remove [who]'s [what.name].") what.add_fingerprint(src) @@ -957,6 +963,13 @@ to_chat(src, "\The [what.name] doesn't fit in that place!") return + if(ishuman(who)) + var/mob/living/carbon/human/victim_human = who + if(victim_human.key && !victim_human.client) // AKA braindead + if(victim_human.stat <= SOFT_CRIT && LAZYLEN(victim_human.afk_thefts) <= AFK_THEFT_MAX_MESSAGES) + var/list/new_entry = list(list(src.name, "tried equipping you with [what]", world.time)) + LAZYADD(victim_human.afk_thefts, new_entry) + who.visible_message("[src] tries to put [what] on [who].", "[src] tries to put [what] on you.", target = src, target_message = "You try to put [what] on [who].")