From 273a9e24801c4d0c276e033a9c1619445b792d21 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Sat, 28 Feb 2015 17:19:38 +1030 Subject: [PATCH] Should stop plants spreading through diagonal windows. --- .../hydroponics/spreading/spreading_growth.dm | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/code/modules/hydroponics/spreading/spreading_growth.dm b/code/modules/hydroponics/spreading/spreading_growth.dm index 0729b2b3437..64ef1b55c6e 100644 --- a/code/modules/hydroponics/spreading/spreading_growth.dm +++ b/code/modules/hydroponics/spreading/spreading_growth.dm @@ -1,9 +1,17 @@ #define NEIGHBOR_REFRESH_TIME 100 +/obj/effect/plant/proc/get_cardinal_neighbors() + var/list/cardinal_neighbors = list() + for(var/check_dir in cardinal) + var/turf/simulated/T = get_step(get_turf(src), check_dir) + if(istype(T)) + cardinal_neighbors |= T + return cardinal_neighbors + /obj/effect/plant/proc/update_neighbors() // Update our list of valid neighboring turfs. neighbors = list() - for(var/turf/simulated/floor/floor in range(1,src)) + for(var/turf/simulated/floor in get_cardinal_neighbors()) if(get_dist(parent, floor) > spread_distance) continue if((locate(/obj/effect/plant) in floor.contents) || (locate(/obj/effect/dead_plant) in floor.contents) ) @@ -80,10 +88,12 @@ // Kill off our plant. if(plant) plant.die() // This turf is clear now, let our buddies know. - var/turf/T = get_turf(src) - for(var/obj/effect/plant/neighbor in range(1,src)) - neighbor.neighbors |= T - plant_controller.add_plant(neighbor) + for(var/turf/simulated/check_turf in get_cardinal_neighbors()) + if(!istype(check_turf)) + continue + for(var/obj/effect/plant/neighbor in check_turf.contents) + neighbor.neighbors |= check_turf + plant_controller.add_plant(neighbor) spawn(1) if(src) del(src) #undef NEIGHBOR_REFRESH_TIME \ No newline at end of file