From 07200a4a1cf644699ab48602c004b5b6373134ec Mon Sep 17 00:00:00 2001 From: Luc <89928798+lewcc@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:44:03 -0500 Subject: [PATCH] Fix a runtime with empty turf lists on hallucinations (#26285) --- code/modules/hallucinations/effects/moderate.dm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/modules/hallucinations/effects/moderate.dm b/code/modules/hallucinations/effects/moderate.dm index fcbf90c0574..1dde6a4097e 100644 --- a/code/modules/hallucinations/effects/moderate.dm +++ b/code/modules/hallucinations/effects/moderate.dm @@ -344,7 +344,10 @@ /obj/effect/hallucination/stunprodding/Initialize(mapload, mob/living/carbon/target) . = ..() - var/turf/T = pick(RANGE_TURFS(15, target)) + var/list/possible_turfs = RANGE_TURFS(15, target) + if(!length(possible_turfs)) + return INITIALIZE_HINT_QDEL + var/turf/T = pick(possible_turfs) target.playsound_local(T, 'sound/weapons/egloves.ogg', 25, TRUE) target.playsound_local(T, get_sfx("bodyfall"), 25, TRUE) target.playsound_local(T, "sparks", 50, TRUE) @@ -366,7 +369,10 @@ /obj/effect/hallucination/energy_sword/Initialize(mapload, mob/living/carbon/target) . = ..() - var/turf/T = pick(RANGE_TURFS(15, target)) + var/list/possible_turfs = RANGE_TURFS(15, target) + if(!length(possible_turfs)) + return INITIALIZE_HINT_QDEL + var/turf/T = pick(possible_turfs) forceMove(T) target.playsound_local(T, 'sound/weapons/saberon.ogg', 20, TRUE) @@ -398,7 +404,10 @@ /obj/effect/hallucination/gunfire/Initialize(mapload, mob/living/carbon/target) . = ..() - var/turf/T = pick(RANGE_TURFS(15, target)) + var/list/possible_turfs = RANGE_TURFS(15, target) + if(!length(possible_turfs)) + return INITIALIZE_HINT_QDEL + var/turf/T = pick(possible_turfs) forceMove(T) var/gun_sound = pick('sound/weapons/gunshots/gunshot_pistol.ogg', 'sound/weapons/gunshots/gunshot_strong.ogg')