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.
This commit is contained in:
Ryll Ryll
2020-12-31 17:13:14 -08:00
committed by GitHub
parent e606126dd5
commit a8d77b57d7
3 changed files with 2 additions and 7 deletions
+1 -2
View File
@@ -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