From 94f8d29ca233e9db8e32c1213ccd5a9e2c40db76 Mon Sep 17 00:00:00 2001 From: "Ossa88 (SYNAPSE)" Date: Thu, 9 Apr 2026 14:14:46 -0700 Subject: [PATCH] inital --- code/modules/mining/ore_veins.dm | 44 ++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/code/modules/mining/ore_veins.dm b/code/modules/mining/ore_veins.dm index cc3b4ba57d1..f5eb4fe3823 100644 --- a/code/modules/mining/ore_veins.dm +++ b/code/modules/mining/ore_veins.dm @@ -142,6 +142,8 @@ GLOBAL_LIST_EMPTY(ore_veins) return var/turf/open/spawning_tile = pick_tile() + if(!spawning_tile) // PENTEST EDIT - No valid tile found, skip this spawn + continue // PENTEST EDUT var/obj/effect/drill_spawner/bug_breach = new /obj/effect/drill_spawner(spawning_tile) active_spawners += bug_breach @@ -153,16 +155,38 @@ GLOBAL_LIST_EMPTY(ore_veins) if(!length(peel)) peel = turf_peel(spawn_distance_max, spawn_distance_min, src, TRUE) var/turf/open/spawning_tile - if(length(peel)) - spawning_tile = pick(peel) - else - spawning_tile = pick(circleviewturfs(loc, spawn_distance_max)) - if(istype(spawning_tile, /turf/closed)) - return pick_tile(peel) - for(var/obj/object in spawning_tile.contents) - if(object.density || istype(object, /obj/effect/drill_spawner)) - return pick_tile(peel) - return spawning_tile + + // PENTEST EDIT START - Try up to 50 times to find a valid turf to prevent infinite recursion + var/attempts = 0 + while(attempts < 50) + attempts++ + + if(length(peel)) + spawning_tile = pick(peel) + peel -= spawning_tile // Remove from list to avoid picking same invalid turf again + else + // Fallback to full circle if peel is exhausted + var/list/circle_turfs = circleviewturfs(loc, spawn_distance_max) + if(!length(circle_turfs)) + return null // No turfs available at all + spawning_tile = pick(circle_turfs) + + // Check if turf is valid + if(istype(spawning_tile, /turf/closed)) + continue // Try next turf + + var/is_blocked = FALSE + for(var/obj/object in spawning_tile.contents) + if(object.density || istype(object, /obj/effect/drill_spawner)) + is_blocked = TRUE + break + + if(!is_blocked) + return spawning_tile // Found a valid turf! + + // If we couldn't find a valid turf after 50 attempts, return null + return null + // PENTEST EDIT END /obj/structure/vein/proc/increment_wave_tally() if(!our_drill || !our_drill.active)