From a8d77b57d7f3d3565a45dee473f9bd28347ebc9e Mon Sep 17 00:00:00 2001 From: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com> Date: Thu, 31 Dec 2020 20:13:14 -0500 Subject: [PATCH] wrinkling my brain (#55829) #54939 removed a part of individual logging code that used the length of the individual's logging list as part of the index for storing a given line of logging. The problem is, that number was important for avoiding collisions in the logging lists. Since the length of an atom's logging list can only ever increase by 1 every time a new line is logged, you were guaranteed to always have a unique index for each new line. Without the length in the index, if any logging event was triggered on the same atom multiple times in the same second (like if someone spoke once willingly and once by force from something like tourettes at the same time), two entries would be logged, but both of them would point to whichever one was processed last. This was most noticeable with wound logging, since the victim would log both the attack itself and the wound it caused at the same time in the same category (LOG_ATTACK), meaning that the wound log would just be turned into a copy of the attack entry, but I believe this is the cause behind most (if not all) of the issues logging has had with duplicating some events and losing others entirely. The fix is simple, just adding the length of the list to the end of the index. This still allows logs to be sorted by timestamp while ensuring that each log entry is unique. --- code/__HELPERS/_logging.dm | 4 ---- code/modules/mob/mob_helpers.dm | 2 +- code/modules/surgery/bodyparts/_bodyparts.dm | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index 18a12c1c6ce..c030807cc33 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -114,10 +114,6 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) if (CONFIG_GET(flag/log_attack)) WRITE_LOG(GLOB.world_attack_log, "ATTACK: [text]") -/proc/log_wounded(text) - if (CONFIG_GET(flag/log_attack)) - WRITE_LOG(GLOB.world_attack_log, "WOUND: [text]") - /proc/log_econ(text) if (CONFIG_GET(flag/log_econ)) WRITE_LOG(GLOB.world_econ_log, "MONEY: [text]") diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 3279b51d8d6..1ceafc17745 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -491,7 +491,7 @@ if(LOG_EMOTE) colored_message = "(EMOTE) [colored_message]" - var/list/timestamped_message = list("\[[time_stamp()]\] [key_name(src)] [loc_name(src)]" = colored_message) + var/list/timestamped_message = list("\[[time_stamp()]\] [key_name(src)] [loc_name(src)] (Event #[LAZYLEN(logging[smessage_type])])" = colored_message) logging[smessage_type] += timestamped_message diff --git a/code/modules/surgery/bodyparts/_bodyparts.dm b/code/modules/surgery/bodyparts/_bodyparts.dm index 04ae7558541..4d7d0f1f89e 100644 --- a/code/modules/surgery/bodyparts/_bodyparts.dm +++ b/code/modules/surgery/bodyparts/_bodyparts.dm @@ -422,11 +422,10 @@ var/datum/wound/new_wound if(replaced_wound) new_wound = replaced_wound.replace_wound(possible_wound) - log_wound(owner, new_wound, damage, wound_bonus, bare_wound_bonus, base_roll) // dismembering wounds are logged in the apply_wound() for loss wounds since they delete themselves immediately, these will be immediately returned else new_wound = new possible_wound new_wound.apply_wound(src) - log_wound(owner, new_wound, damage, wound_bonus, bare_wound_bonus, base_roll) + log_wound(owner, new_wound, damage, wound_bonus, bare_wound_bonus, base_roll) // dismembering wounds are logged in the apply_wound() for loss wounds since they delete themselves immediately, these will be immediately returned return new_wound // try forcing a specific wound, but only if there isn't already a wound of that severity or greater for that type on this bodypart