mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Floodfill experimental improvement, lets hope it fixes crashes.
This commit is contained in:
@@ -8,49 +8,35 @@ proc/FloodFill(turf/start)
|
||||
list
|
||||
open = list(start)
|
||||
closed = list()
|
||||
doors = list()
|
||||
|
||||
while(open.len)
|
||||
for(var/turf/T in open)
|
||||
//Stop if there's a door, even if it's open. These are handled by indirect connection.
|
||||
if(!T.HasDoor())
|
||||
var/turf/T = pick(open)
|
||||
|
||||
for(var/d in cardinal)
|
||||
var/turf/O = get_step(T,d)
|
||||
//Simple pass check.
|
||||
if(istype(O) && !(O in open) && !(O in doors) && !(O in closed) && O.ZCanPass(T))
|
||||
open += O
|
||||
else
|
||||
doors |= T
|
||||
open -= T
|
||||
continue
|
||||
for(var/d in cardinal)
|
||||
var/turf/O = get_step(T,d)
|
||||
|
||||
open -= T
|
||||
closed += T
|
||||
if(istype(O) && !(O in open) && !(O in closed) && O.ZCanPass(T))
|
||||
|
||||
if(closed.len)
|
||||
for(var/turf/T in doors)
|
||||
var/force_connection = 1
|
||||
var/turf/simulated/O = get_step(T,NORTH)
|
||||
if(O in closed)
|
||||
closed += T
|
||||
continue
|
||||
else if(T.ZCanPass(O) && istype(O))
|
||||
force_connection = 0
|
||||
if(!T.HasDoor())
|
||||
open += O
|
||||
|
||||
O = get_step(T,WEST)
|
||||
if(O in closed)
|
||||
closed += T
|
||||
continue
|
||||
else if(force_connection && T.ZCanPass(O) && istype(O))
|
||||
force_connection = 0
|
||||
else
|
||||
if(d == SOUTH || d == EAST)
|
||||
//doors prefer connecting to zones to the north north or west
|
||||
closed += O
|
||||
|
||||
if(force_connection)
|
||||
O = get_step(T,SOUTH)
|
||||
if(O in closed)
|
||||
closed += T
|
||||
else if((!T.ZCanPass(O) || !istype(O)) && get_step(T,EAST) in closed)
|
||||
closed += T
|
||||
else
|
||||
//see if we need to force an attempted connection
|
||||
//(there are no potentially viable zones to the north/west of the door)
|
||||
var/turf/W = get_step(O, WEST)
|
||||
var/turf/N = get_step(O, NORTH)
|
||||
|
||||
if( (!istype(N) || !O.ZCanPass(N)) && (!istype(W) || !O.ZCanPass(W)) )
|
||||
//If it cannot connect either to the north or west, connect it!
|
||||
closed += O
|
||||
|
||||
open -= T
|
||||
closed += T
|
||||
|
||||
return closed
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ turf
|
||||
for(var/direction in cardinal)
|
||||
var/turf/simulated/floor/target = get_step(src,direction)
|
||||
if(istype(target))
|
||||
air_master.tiles_to_update.Add(target)
|
||||
air_master.tiles_to_update |= target
|
||||
|
||||
Del()
|
||||
if(active_hotspot)
|
||||
@@ -172,10 +172,9 @@ turf
|
||||
if(air_check_directions&direction) //I can connect air in this direction
|
||||
if(!CanPass(null, T, 0, 0)) //If either block air, we must look to see if the adjacent turfs need rebuilt.
|
||||
if(T.zone && !T.zone.rebuild)
|
||||
for(var/direction2 in cardinal - direction) //Check all other directions for air that might be connected.
|
||||
var/turf/simulated/NT = get_step(src, direction2)
|
||||
if(NT && NT.zone && NT.zone == T.zone && !NT.HasDoor())
|
||||
T.zone.rebuild = 1
|
||||
var/turf/simulated/NT = get_step(src, reverse_direction(direction))
|
||||
if(istype(NT) && NT.zone && NT.zone == T.zone)
|
||||
T.zone.rebuild = 1
|
||||
|
||||
else
|
||||
ZConnect(src,T)
|
||||
|
||||
Reference in New Issue
Block a user