From 07bc9de1df79528ff902ac4f0d410563b9bcecce Mon Sep 17 00:00:00 2001 From: Lucy Date: Sun, 19 Jan 2025 20:07:58 -0500 Subject: [PATCH] Fix latejoin cyborgs sometimes ending up in walls and such --- code/modules/jobs/job_types/cyborg.dm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/code/modules/jobs/job_types/cyborg.dm b/code/modules/jobs/job_types/cyborg.dm index 57a550f52c1f..2688c13566cb 100644 --- a/code/modules/jobs/job_types/cyborg.dm +++ b/code/modules/jobs/job_types/cyborg.dm @@ -36,11 +36,15 @@ /datum/job/cyborg/proc/get_random_open_turf_in_area() var/list/turfs = get_area_turfs(/area/station/ai_monitored/turret_protected/ai_upload) - var/turf/open/target_turf = null - while(!target_turf) - var/turf/turf = pick(turfs) - if(!turf.density) - target_turf = turf + var/turf/open/target_turf + while(length(turfs)) + var/turf/turf = pick_n_take(turfs) + if(!isfloorturf(turf) || turf.is_blocked_turf(exclude_mobs = TRUE)) + continue + target_turf = turf + break + if(!target_turf) + CRASH("Failed to find eligible spawn turf for a cyborg!") return target_turf /datum/job/cyborg/after_spawn(mob/living/spawned, client/player_client)