From 2c95d1d28ca6e6390351a07dbb73bded6e64b0c8 Mon Sep 17 00:00:00 2001 From: Jerry <55355646+Jewelry-x@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:55:17 +0200 Subject: [PATCH] Fix rare runtime if there are no available organs to take (#87671) ## About The Pull Request This PR fixes a rare runtime error, regarding lost crew members, that occurs when there are no organs in the `organs_we_can_take` list, which causes an exception due to an attempt to `pick()` from an empty list. ## Why It's Good For The Game The less exceptions exists, the better. ## Changelog :cl: fix: fixed a rare runtime with lost crew having no organs /:cl: --------- Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> --- code/modules/lost_crew/damages/post_mortem.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/modules/lost_crew/damages/post_mortem.dm b/code/modules/lost_crew/damages/post_mortem.dm index 91f4ac8c60d..5eeaabc3302 100644 --- a/code/modules/lost_crew/damages/post_mortem.dm +++ b/code/modules/lost_crew/damages/post_mortem.dm @@ -13,6 +13,8 @@ var/organs_to_take = round(min_organs + (max_organs - min_organs) * severity) var/list/organs_we_can_take = body.organs - body.get_organ_slot(ORGAN_SLOT_BRAIN) + if (!length(organs_we_can_take)) + return for(var/i in 1 to organs_to_take) var/obj/organ = pick(organs_we_can_take) if(prob(organ_save_chance) && saved_movables) //if lucky, we can save the organ and have it be delivered with the body