diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 2813c64425f..6e5ca9e91ba 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1562,12 +1562,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) if(areas) . |= T.loc -/proc/turf_clear(turf/T) - for(var/atom/A in T) - if(A.simulated) - return FALSE - return TRUE - /proc/screen_loc2turf(scr_loc, turf/origin) var/tX = splittext(scr_loc, ",") var/tY = splittext(tX[2], ":") diff --git a/code/modules/events/infestation.dm b/code/modules/events/infestation.dm index d3a9ff95745..ca3c31111b8 100644 --- a/code/modules/events/infestation.dm +++ b/code/modules/events/infestation.dm @@ -27,17 +27,27 @@ /datum/event/infestation/start() var/list/turf/simulated/floor/turfs = list() - spawn_area_type = pick(spawn_areas) - for(var/areapath in typesof(spawn_area_type)) - var/area/A = locate(areapath) - if(!A) - log_debug("Failed to locate area for infestation event!") - kill() - return - for(var/turf/simulated/floor/F in A.contents) - if(turf_clear(F)) - turfs += F + // shuffle in place so we don't have do that dance where we make a copy of + // the list, then pick and take, then do some conditional logic to make sure + // there's still areas to choose from, etc etc, it's a small list, it's cheap + shuffle_inplace(spawn_areas) + for(var/spawn_area in spawn_areas) + for(var/area_type in typesof(spawn_area)) + var/area/destination = locate(area_type) + if(!destination) + continue + for(var/turf/simulated/floor/F in destination.contents) + if(!is_blocked_turf(F)) + turfs += F + if(length(turfs)) + spawn_area_type = area_type + spawn_on_turfs(turfs) + return + log_debug("Failed to locate area for infestation event!") + kill() + +/datum/event/infestation/proc/spawn_on_turfs(list/turfs) var/list/spawn_types = list() var/max_number vermin = rand(0, 2)