Files
SmArtKar 739bd4b76a Fixes runtimes caused by persistent scars trying to save bodyswapped people's scars (#94504)
## About The Pull Request

Original slot index is preserved upon mind transferring between bodies,
but original character isn't, so this could runtime if you bodyswapped,
lived until roundend and had persistent scars on.

## Changelog
🆑
fix: Fixed runtimes caused by persistent scars trying to save
bodyswapped people's scars
/🆑
2025-12-16 21:54:04 -05:00

18 lines
723 B
Plaintext

///Saves all scars for everyone's original characters
/datum/controller/subsystem/persistence/proc/save_scars()
for(var/i in GLOB.joined_player_list)
var/mob/living/carbon/human/ending_human = get_mob_by_ckey(i)
if(!istype(ending_human) || !ending_human.mind?.original_character_slot_index || !ending_human.client?.prefs.read_preference(/datum/preference/toggle/persistent_scars))
continue
var/mob/living/carbon/human/original_human = ending_human.mind.original_character?.resolve()
if(!original_human)
continue
if(original_human.stat == DEAD || !original_human.all_scars || original_human != ending_human)
original_human.save_persistent_scars(TRUE)
else
original_human.save_persistent_scars()