mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 04:27:35 +01:00
Fixed and cleaned up ZAS. Added some better sanity to explosion locations.
ZAS procs are now more standardized, needs more comments though. Connections between zones now self-manage themselves, adjusting things if/when the turfs they are on change zones. (The check for this is very efficient and fast, but a bit hard to read codewise) Zone share percent set to 4. Seems to work well.
This commit is contained in:
+219
-22
@@ -8,6 +8,9 @@ connection
|
||||
turf //The turfs involved in the connection.
|
||||
A
|
||||
B
|
||||
zone
|
||||
zone_A
|
||||
zone_B
|
||||
indirect = 0 //If the connection is purely indirect, the zones should not join.
|
||||
last_updated //The tick at which this was last updated.
|
||||
no_zone_count = 0
|
||||
@@ -17,9 +20,11 @@ connection
|
||||
if(A.zone)
|
||||
if(!A.zone.connections) A.zone.connections = new()
|
||||
A.zone.connections += src
|
||||
zone_A = A.zone
|
||||
if(B.zone)
|
||||
if(!B.zone.connections) B.zone.connections = new()
|
||||
B.zone.connections += src
|
||||
zone_B = B.zone
|
||||
if(A.zone && B.zone)
|
||||
if(!A.zone.connected_zones)
|
||||
A.zone.connected_zones = list()
|
||||
@@ -41,27 +46,90 @@ connection
|
||||
world.log << "Attempted to create connection object for non-zone tiles: [T] -> [O]"
|
||||
Del()
|
||||
if(A.zone && A.zone.connections)
|
||||
A.zone.connections -= src
|
||||
A.zone.connections.Remove(src)
|
||||
if(!A.zone.connections.len)
|
||||
del A.zone.connections
|
||||
if(B.zone && B.zone.connections)
|
||||
B.zone.connections -= src
|
||||
B.zone.connections.Remove(src)
|
||||
if(!A.zone.connections.len)
|
||||
del B.zone.connections
|
||||
if(zone_A && zone_A.connections)
|
||||
zone_A.connections.Remove(src)
|
||||
if(!zone_A.connections.len)
|
||||
del zone_A.connections
|
||||
if(zone_B && zone_B.connections)
|
||||
zone_B.connections.Remove(src)
|
||||
if(!zone_B.connections.len)
|
||||
del zone_B.connections
|
||||
|
||||
if(A.zone && B.zone)
|
||||
|
||||
if(B.zone in A.zone.connected_zones)
|
||||
if(A.zone.connected_zones[B.zone] > 1)
|
||||
A.zone.connected_zones[B.zone]--
|
||||
else
|
||||
A.zone.connected_zones -= B.zone
|
||||
|
||||
if(A.zone in B.zone.connected_zones)
|
||||
if(B.zone.connected_zones[A.zone] > 1)
|
||||
B.zone.connected_zones[A.zone]--
|
||||
else
|
||||
B.zone.connected_zones -= A.zone
|
||||
if(A.zone.connected_zones && !A.zone.connected_zones.len)
|
||||
A.zone.connected_zones = null
|
||||
if(B.zone.connected_zones && !B.zone.connected_zones.len)
|
||||
B.zone.connected_zones = null
|
||||
if(A.zone)
|
||||
if(B.zone)
|
||||
if(B.zone in A.zone.connected_zones)
|
||||
if(A.zone.connected_zones[B.zone] > 1)
|
||||
A.zone.connected_zones[B.zone]--
|
||||
else
|
||||
A.zone.connected_zones -= B.zone
|
||||
if(A.zone.connected_zones && !A.zone.connected_zones.len)
|
||||
A.zone.connected_zones = null
|
||||
if( zone_B && (!B.zone && zone_B != B.zone) )
|
||||
if(zone_B in A.zone.connected_zones)
|
||||
if(A.zone.connected_zones[zone_B] > 1)
|
||||
A.zone.connected_zones[zone_B]--
|
||||
else
|
||||
A.zone.connected_zones -= zone_B
|
||||
if(A.zone.connected_zones && !A.zone.connected_zones.len)
|
||||
A.zone.connected_zones = null
|
||||
if(zone_A && (!A.zone || zone_A != A.zone))
|
||||
if(B.zone)
|
||||
if(B.zone in zone_A.connected_zones)
|
||||
if(zone_A.connected_zones[B.zone] > 1)
|
||||
zone_A.connected_zones[B.zone]--
|
||||
else
|
||||
zone_A.connected_zones -= B.zone
|
||||
if(zone_A.connected_zones && !zone_A.connected_zones.len)
|
||||
zone_A.connected_zones = null
|
||||
if( zone_B && (!B.zone && zone_B != B.zone) )
|
||||
if(zone_B in zone_A.connected_zones)
|
||||
if(zone_A.connected_zones[zone_B] > 1)
|
||||
zone_A.connected_zones[zone_B]--
|
||||
else
|
||||
zone_A.connected_zones -= zone_B
|
||||
if(zone_A.connected_zones && !zone_A.connected_zones.len)
|
||||
zone_A.connected_zones = null
|
||||
if(B.zone)
|
||||
if(A.zone)
|
||||
if(A.zone in B.zone.connected_zones)
|
||||
if(B.zone.connected_zones[A.zone] > 1)
|
||||
B.zone.connected_zones[A.zone]--
|
||||
else
|
||||
B.zone.connected_zones -= A.zone
|
||||
if(B.zone.connected_zones && !B.zone.connected_zones.len)
|
||||
B.zone.connected_zones = null
|
||||
if( zone_A && (!A.zone && zone_A != A.zone) )
|
||||
if(zone_A in B.zone.connected_zones)
|
||||
if(B.zone.connected_zones[zone_A] > 1)
|
||||
B.zone.connected_zones[zone_A]--
|
||||
else
|
||||
B.zone.connected_zones -= zone_A
|
||||
if(B.zone.connected_zones && !B.zone.connected_zones.len)
|
||||
B.zone.connected_zones = null
|
||||
if(zone_B && (!B.zone || zone_B != B.zone))
|
||||
if(A.zone)
|
||||
if(A.zone in zone_B.connected_zones)
|
||||
if(zone_B.connected_zones[A.zone] > 1)
|
||||
zone_B.connected_zones[A.zone]--
|
||||
else
|
||||
zone_B.connected_zones -= A.zone
|
||||
if(zone_B.connected_zones && !zone_B.connected_zones.len)
|
||||
zone_B.connected_zones = null
|
||||
if( zone_A && (!A.zone && zone_A != A.zone) )
|
||||
if(zone_A in zone_B.connected_zones)
|
||||
if(zone_B.connected_zones[zone_A] > 1)
|
||||
zone_B.connected_zones[zone_A]--
|
||||
else
|
||||
zone_B.connected_zones -= zone_A
|
||||
if(zone_B.connected_zones && !zone_B.connected_zones.len)
|
||||
zone_B.connected_zones = null
|
||||
. = ..()
|
||||
|
||||
proc/Cleanup()
|
||||
@@ -71,8 +139,137 @@ connection
|
||||
if(A.zone == B.zone)
|
||||
//world.log << "Connection removed: Zones now merged."
|
||||
del src
|
||||
if((A.zone && A.zone != zone_A) || (B.zone && B.zone != zone_B))
|
||||
Sanitize()
|
||||
if(!A.zone || !B.zone)
|
||||
no_zone_count++
|
||||
if(no_zone_count >= 5)
|
||||
//world.log << "Connection removed: [A] or [B] missing a zone."
|
||||
del src
|
||||
if(no_zone_count >= 5)
|
||||
//world.log << "Connection removed: [A] or [B] missing a zone."
|
||||
del src
|
||||
return 0
|
||||
return 1
|
||||
|
||||
proc/Sanitize()
|
||||
//If the zones change on connected turfs, update it.
|
||||
if(A.zone && A.zone != zone_A && B.zone && B.zone != zone_B)
|
||||
if(!A.zone || !B.zone)
|
||||
del src
|
||||
|
||||
if(zone_A)
|
||||
if(zone_A.connections)
|
||||
zone_A.connections.Remove(src)
|
||||
if(!zone_A.connections.len)
|
||||
del zone_A.connections
|
||||
|
||||
if(zone_A.connected_zones)
|
||||
if(zone_A.connected_zones[zone_B] > 1)
|
||||
zone_A.connected_zones[zone_B]--
|
||||
else
|
||||
zone_A.connected_zones.Remove(zone_B)
|
||||
if(zone_A.connected_zones && !zone_A.connected_zones.len)
|
||||
zone_A.connected_zones = null
|
||||
|
||||
if(zone_B)
|
||||
if(zone_B.connections)
|
||||
zone_B.connections.Remove(src)
|
||||
if(!zone_B.connections.len)
|
||||
del zone_B.connections
|
||||
|
||||
if(zone_B.connected_zones)
|
||||
if(zone_B.connected_zones[zone_A] > 1)
|
||||
zone_B.connected_zones[zone_A]--
|
||||
else
|
||||
zone_B.connected_zones.Remove(zone_A)
|
||||
if(zone_B.connected_zones && !zone_B.connected_zones.len)
|
||||
zone_B.connected_zones = null
|
||||
|
||||
if(!A.zone.connections)
|
||||
A.zone.connections = list()
|
||||
A.zone.connections |= src
|
||||
if(!B.zone.connections)
|
||||
B.zone.connections = list()
|
||||
B.zone.connections |= src
|
||||
|
||||
if(!A.zone.connected_zones)
|
||||
A.zone.connected_zones = list()
|
||||
if(!(B.zone in A.zone.connected_zones))
|
||||
A.zone.connected_zones += B.zone
|
||||
A.zone.connected_zones[B.zone] = 1
|
||||
else
|
||||
A.zone.connected_zones[B.zone]++
|
||||
|
||||
if(!B.zone.connected_zones)
|
||||
B.zone.connected_zones = list()
|
||||
if(!(A.zone in B.zone.connected_zones))
|
||||
B.zone.connected_zones += A.zone
|
||||
B.zone.connected_zones[A.zone] = 1
|
||||
else
|
||||
B.zone.connected_zones[A.zone]++
|
||||
|
||||
zone_B = B.zone
|
||||
|
||||
zone_A = A.zone
|
||||
|
||||
else if(A.zone && A.zone != zone_A)
|
||||
if(zone_A)
|
||||
|
||||
if(zone_A.connections)
|
||||
zone_A.connections.Remove(src)
|
||||
if(!zone_A.connections.len)
|
||||
del zone_A.connections
|
||||
if(!A.zone.connections)
|
||||
A.zone.connections = list()
|
||||
A.zone.connections |= src
|
||||
|
||||
if(zone_A.connected_zones)
|
||||
if(zone_A.connected_zones[zone_B] > 1)
|
||||
zone_A.connected_zones[zone_B]--
|
||||
else
|
||||
zone_A.connected_zones.Remove(zone_B)
|
||||
if(zone_A.connected_zones && !zone_A.connected_zones.len)
|
||||
zone_A.connected_zones = null
|
||||
|
||||
if(!A.zone.connected_zones)
|
||||
A.zone.connected_zones = list()
|
||||
if(!(zone_B in A.zone.connected_zones))
|
||||
A.zone.connected_zones += zone_B
|
||||
A.zone.connected_zones[zone_B] = 1
|
||||
else
|
||||
A.zone.connected_zones[zone_B]++
|
||||
|
||||
zone_A = A.zone
|
||||
|
||||
else
|
||||
del src
|
||||
|
||||
else if(B.zone && B.zone != zone_B)
|
||||
if(zone_B)
|
||||
|
||||
if(zone_B.connections)
|
||||
zone_B.connections.Remove(src)
|
||||
if(!zone_B.connections.len)
|
||||
del zone_B.connections
|
||||
if(!B.zone.connections)
|
||||
B.zone.connections = list()
|
||||
B.zone.connections |= src
|
||||
|
||||
if(zone_B.connected_zones)
|
||||
if(zone_B.connected_zones[zone_A] > 1)
|
||||
zone_B.connected_zones[zone_A]--
|
||||
else
|
||||
zone_B.connected_zones.Remove(zone_A)
|
||||
if(zone_B.connected_zones && !zone_B.connected_zones.len)
|
||||
zone_B.connected_zones = null
|
||||
|
||||
if(!B.zone.connected_zones)
|
||||
B.zone.connected_zones = list()
|
||||
if(!(zone_A in B.zone.connected_zones))
|
||||
B.zone.connected_zones += zone_A
|
||||
B.zone.connected_zones[zone_A] = 1
|
||||
else
|
||||
B.zone.connected_zones[zone_A]++
|
||||
|
||||
zone_B = B.zone
|
||||
|
||||
else
|
||||
del src
|
||||
@@ -53,7 +53,7 @@ datum
|
||||
//FOR THE LOVE OF GOD PLEASE USE THIS PROC
|
||||
//Call it with negative numbers to remove gases.
|
||||
|
||||
proc/adjustGases(o2 = 0, co2 = 0, n2 = 0, tx = 0, list/datum/gas/traces = list())
|
||||
proc/adjust(o2 = 0, co2 = 0, n2 = 0, tx = 0, list/datum/gas/traces = list())
|
||||
//Purpose: Adjusting the gases within a airmix
|
||||
//Called by: Nothing, yet!
|
||||
//Inputs: The values of the gases to adjust
|
||||
|
||||
+11
-10
@@ -178,17 +178,18 @@ turf
|
||||
|
||||
if(zone)
|
||||
for(var/direction in cardinal)
|
||||
if(air_check_directions&direction)
|
||||
|
||||
var/turf/simulated/T = get_step(src,direction)
|
||||
if(T)
|
||||
ZConnect(src,T)
|
||||
else
|
||||
var/turf/simulated/T = get_step(src,direction)
|
||||
if(T)
|
||||
ZDisconnect(src,T)
|
||||
var/turf/simulated/T = get_step(src,direction)
|
||||
if(istype(T))
|
||||
if(CanPass(null, src, 1.5, 0))
|
||||
if(CanPass(null, src, 0, 0))
|
||||
ZConnect(src,T)
|
||||
else
|
||||
ZDisconnect(src,T)
|
||||
else
|
||||
zone.rebuild = 1
|
||||
if(T.zone)
|
||||
T.zone.rebuild = 1
|
||||
else
|
||||
|
||||
for(var/direction in cardinal)
|
||||
if(air_check_directions&direction)
|
||||
var/turf/simulated/T = get_step(src,direction)
|
||||
|
||||
+159
-149
@@ -1,31 +1,32 @@
|
||||
zone
|
||||
proc
|
||||
AddTurf(turf/T)
|
||||
//Adds the turf to contents, increases the size of the zone, and sets the zone var.
|
||||
if(T in contents) return
|
||||
contents += T
|
||||
air.group_multiplier++
|
||||
T.zone = src
|
||||
RemoveTurf(turf/T)
|
||||
//Same, but in reverse.
|
||||
if(!(T in contents)) return
|
||||
contents -= T
|
||||
air.group_multiplier--
|
||||
T.zone = null
|
||||
/zone
|
||||
proc/AddTurf(turf/T)
|
||||
//Adds the turf to contents, increases the size of the zone, and sets the zone var.
|
||||
if(T in contents)
|
||||
return
|
||||
contents += T
|
||||
air.group_multiplier++
|
||||
T.zone = src
|
||||
proc/RemoveTurf(turf/T)
|
||||
//Same, but in reverse.
|
||||
if(!(T in contents))
|
||||
return
|
||||
contents -= T
|
||||
air.group_multiplier--
|
||||
T.zone = null
|
||||
|
||||
AddSpace(turf/space/S)
|
||||
//Adds a space tile to the list, and creates the list if null.
|
||||
if(istype(S,/turf/space))
|
||||
if(!space_tiles) space_tiles = list()
|
||||
space_tiles += S
|
||||
proc/AddSpace(turf/space/S)
|
||||
//Adds a space tile to the list, and creates the list if null.
|
||||
if(istype(S,/turf/space))
|
||||
if(!space_tiles) space_tiles = list()
|
||||
space_tiles += S
|
||||
|
||||
RemoveSpace(turf/space/S)
|
||||
//Removes a space tile from the list, and deletes the list if length is 0.
|
||||
if(space_tiles)
|
||||
space_tiles -= S
|
||||
if(!space_tiles.len) space_tiles = null
|
||||
proc/RemoveSpace(turf/space/S)
|
||||
//Removes a space tile from the list, and deletes the list if length is 0.
|
||||
if(space_tiles)
|
||||
space_tiles -= S
|
||||
if(!space_tiles.len) space_tiles = null
|
||||
|
||||
turf/proc/HasDoor(turf/O)
|
||||
/turf/proc/HasDoor(turf/O)
|
||||
//Checks for the presence of doors, used for zone spreading and connection.
|
||||
//A positive numerical argument checks only for closed doors.
|
||||
//Another turf as an argument checks for windoors between here and there.
|
||||
@@ -38,158 +39,167 @@ turf/proc/HasDoor(turf/O)
|
||||
else
|
||||
return 1
|
||||
|
||||
turf/proc/find_zone()
|
||||
/turf/proc/find_zone()
|
||||
//Allows newly generated turfs to join up with a nearby zone.
|
||||
if(world.time < 10) return
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(!T || !T.zone || !T.ZCanPass(src)) continue
|
||||
if(!zone)
|
||||
zone = T.zone
|
||||
zone.AddTurf(src)
|
||||
else if(T.zone != zone)
|
||||
ZConnect(src,T)
|
||||
if(density)
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(!T || !T.zone || !T.ZCanPass(src))
|
||||
continue
|
||||
T.zone.rebuild = 1
|
||||
|
||||
turf/proc/check_connections()
|
||||
else
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(!T || !T.zone || !T.ZCanPass(src))
|
||||
continue
|
||||
if(!zone)
|
||||
zone = T.zone
|
||||
zone.AddTurf(src)
|
||||
else if(T.zone != zone)
|
||||
ZConnect(src,T)
|
||||
|
||||
/turf/proc/check_connections()
|
||||
//Checks for new connections that can be made.
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(!T || !T.zone || !T.CanPass(0,src,0,0)) continue
|
||||
if(!T || !T.zone || !T.CanPass(0,src,0,0))
|
||||
continue
|
||||
if(T.zone != zone)
|
||||
ZConnect(src,T)
|
||||
|
||||
turf/proc/check_for_space()
|
||||
/turf/proc/check_for_space()
|
||||
//Checks for space around the turf.
|
||||
for(var/d in cardinal)
|
||||
var/turf/T = get_step(src,d)
|
||||
if(istype(T,/turf/space) && T.CanPass(0,src,0,0))
|
||||
zone.AddSpace(T)
|
||||
|
||||
proc
|
||||
ZMerge(zone/A,zone/B)
|
||||
//Merges two zones so that they are one.
|
||||
var
|
||||
a_size = A.air.group_multiplier
|
||||
b_size = B.air.group_multiplier
|
||||
c_size = a_size + b_size
|
||||
new_contents = A.contents + B.contents
|
||||
proc/ZMerge(zone/A,zone/B)
|
||||
//Merges two zones so that they are one.
|
||||
var
|
||||
a_size = A.air.group_multiplier
|
||||
b_size = B.air.group_multiplier
|
||||
c_size = a_size + b_size
|
||||
new_contents = A.contents + B.contents
|
||||
|
||||
//Set air multipliers to one so air represents gas per tile.
|
||||
A.air.group_multiplier = 1
|
||||
B.air.group_multiplier = 1
|
||||
//Set air multipliers to one so air represents gas per tile.
|
||||
A.air.group_multiplier = 1
|
||||
B.air.group_multiplier = 1
|
||||
|
||||
//Remove some air proportional to the size of this zone.
|
||||
A.air.remove_ratio(a_size/c_size)
|
||||
B.air.remove_ratio(b_size/c_size)
|
||||
//Remove some air proportional to the size of this zone.
|
||||
A.air.remove_ratio(a_size/c_size)
|
||||
B.air.remove_ratio(b_size/c_size)
|
||||
|
||||
//Merge the gases and set the multiplier to the sum of the old ones.
|
||||
A.air.merge(B.air)
|
||||
A.air.group_multiplier = c_size
|
||||
//Merge the gases and set the multiplier to the sum of the old ones.
|
||||
A.air.merge(B.air)
|
||||
A.air.group_multiplier = c_size
|
||||
|
||||
//Check for connections to merge into the new zone.
|
||||
for(var/connection/C in B.connections)
|
||||
if((C.A in new_contents) && (C.B in new_contents))
|
||||
del C
|
||||
continue
|
||||
if(!A.connections) A.connections = list()
|
||||
A.connections += C
|
||||
//Check for connections to merge into the new zone.
|
||||
for(var/connection/C in B.connections)
|
||||
if((C.A in new_contents) && (C.B in new_contents))
|
||||
del C
|
||||
continue
|
||||
if(!A.connections) A.connections = list()
|
||||
A.connections += C
|
||||
|
||||
//Add space tiles.
|
||||
A.space_tiles += B.space_tiles
|
||||
//Add space tiles.
|
||||
A.space_tiles += B.space_tiles
|
||||
|
||||
//Add contents.
|
||||
A.contents = new_contents
|
||||
//Add contents.
|
||||
A.contents = new_contents
|
||||
|
||||
//Set all the zone vars.
|
||||
for(var/turf/T in B.contents)
|
||||
T.zone = A
|
||||
//Set all the zone vars.
|
||||
for(var/turf/T in B.contents)
|
||||
T.zone = A
|
||||
|
||||
del B
|
||||
del B
|
||||
|
||||
ZConnect(turf/A,turf/B)
|
||||
//Connects two zones by forming a connection object representing turfs A and B.
|
||||
proc/ZConnect(turf/A,turf/B)
|
||||
//Connects two zones by forming a connection object representing turfs A and B.
|
||||
|
||||
//Make sure that if it's space, it gets added to space_tiles instead.
|
||||
if(istype(B,/turf/space))
|
||||
if(A.zone)
|
||||
A.zone.AddSpace(B)
|
||||
return
|
||||
if(istype(A,/turf/space))
|
||||
if(B.zone)
|
||||
B.zone.AddSpace(A)
|
||||
//Make sure that if it's space, it gets added to space_tiles instead.
|
||||
if(istype(B,/turf/space))
|
||||
if(A.zone)
|
||||
A.zone.AddSpace(B)
|
||||
return
|
||||
if(istype(A,/turf/space))
|
||||
if(B.zone)
|
||||
B.zone.AddSpace(A)
|
||||
return
|
||||
|
||||
//Make some preliminary checks to see if the connection is valid.
|
||||
if(!A.zone || !B.zone) return
|
||||
if(A.zone == B.zone) return
|
||||
if(!A.CanPass(0,B,0,0)) return
|
||||
|
||||
//Ensure the connection isn't already made.
|
||||
for(var/connection/C in A.zone.connections)
|
||||
if((C.A == A && C.B == B) || (C.A == B && C.B == A))
|
||||
return
|
||||
|
||||
//Make some preliminary checks to see if the connection is valid.
|
||||
if(!A.zone || !B.zone) return
|
||||
if(A.zone == B.zone) return
|
||||
if(!A.CanPass(0,B,0,0)) return
|
||||
var/connection/C = new(A,B)
|
||||
|
||||
//Ensure the connection isn't already made.
|
||||
for(var/connection/C in A.zone.connections)
|
||||
if((C.A == A && C.B == B) || (C.A == B && C.B == A))
|
||||
return
|
||||
//Ensure zones separated by doors do not merge.
|
||||
if(A.HasDoor(B) || B.HasDoor(A)) C.indirect = 1
|
||||
|
||||
var/connection/C = new(A,B)
|
||||
proc/ZDisconnect(turf/A,turf/B)
|
||||
//Removes a zone connection. Can split zones in the case of a permanent barrier.
|
||||
|
||||
//Ensure zones separated by doors do not merge.
|
||||
if(A.HasDoor(B) || B.HasDoor(A)) C.indirect = 1
|
||||
|
||||
ZDisconnect(turf/A,turf/B)
|
||||
//Removes a zone connection. Can split zones in the case of a permanent barrier.
|
||||
|
||||
//If one of them doesn't have a zone, it might be space, so check for that.
|
||||
if(A.zone && B.zone)
|
||||
//If the two zones are different, just remove a connection.
|
||||
if(A.zone != B.zone)
|
||||
for(var/connection/C in A.zone.connections)
|
||||
if((C.A == A && C.B == B) || (C.A == B && C.B == A))
|
||||
del C
|
||||
//If they're the same, split the zone at this line.
|
||||
else
|
||||
//Preliminary checks to prevent stupidity.
|
||||
if(A == B) return
|
||||
if(A.CanPass(0,B,0,0)) return
|
||||
if(A.HasDoor(B) || B.HasDoor(A)) return
|
||||
|
||||
//Do a test fill. If turf B is still in the floodfill, then the zone isn't really split.
|
||||
var/zone/oldzone = A.zone
|
||||
var/list/test = FloodFill(A)
|
||||
if(B in test) return
|
||||
|
||||
else
|
||||
var/zone/Z = new(test,oldzone.air) //Create a new zone based on the old air and the test fill.
|
||||
|
||||
//Add connections from the old zone.
|
||||
for(var/connection/C in oldzone.connections)
|
||||
if((A in Z.contents) || (B in Z.contents))
|
||||
if(!Z.connections) Z.connections = list()
|
||||
Z.connections += C
|
||||
|
||||
//Check for space.
|
||||
for(var/turf/T in test)
|
||||
T.check_for_space()
|
||||
|
||||
//Make a new, identical air mixture for the other zone.
|
||||
var/datum/gas_mixture/Y_Air = new
|
||||
Y_Air.copy_from(oldzone.air)
|
||||
|
||||
var/zone/Y = new(B,Y_Air) //Make a new zone starting at B and using Y_Air.
|
||||
|
||||
//Add relevant connections from old zone.
|
||||
for(var/connection/C in oldzone.connections)
|
||||
if((A in Y.contents) || (B in Y.contents))
|
||||
if(!Y.connections) Y.connections = list()
|
||||
Y.connections += C
|
||||
|
||||
//Add the remaining space tiles to this zone.
|
||||
for(var/turf/space/T in oldzone.space_tiles)
|
||||
if(!(T in Z.space_tiles))
|
||||
Y.AddSpace(T)
|
||||
|
||||
oldzone.air = null
|
||||
del oldzone
|
||||
//If one of them doesn't have a zone, it might be space, so check for that.
|
||||
if(A.zone && B.zone)
|
||||
//If the two zones are different, just remove a connection.
|
||||
if(A.zone != B.zone)
|
||||
for(var/connection/C in A.zone.connections)
|
||||
if((C.A == A && C.B == B) || (C.A == B && C.B == A))
|
||||
del C
|
||||
//If they're the same, split the zone at this line.
|
||||
else
|
||||
if(istype(A,/turf/space) && B.zone)
|
||||
B.zone.RemoveSpace(A)
|
||||
else if(istype(B,/turf/space) && A.zone)
|
||||
A.zone.RemoveSpace(B)
|
||||
//Preliminary checks to prevent stupidity.
|
||||
if(A == B) return
|
||||
if(A.CanPass(0,B,0,0)) return
|
||||
if(A.HasDoor(B) || B.HasDoor(A)) return
|
||||
|
||||
//Do a test fill. If turf B is still in the floodfill, then the zone isn't really split.
|
||||
var/zone/oldzone = A.zone
|
||||
var/list/test = FloodFill(A)
|
||||
if(B in test) return
|
||||
|
||||
else
|
||||
var/zone/Z = new(test,oldzone.air) //Create a new zone based on the old air and the test fill.
|
||||
|
||||
//Add connections from the old zone.
|
||||
for(var/connection/C in oldzone.connections)
|
||||
if((A in Z.contents) || (B in Z.contents))
|
||||
if(!Z.connections) Z.connections = list()
|
||||
Z.connections += C
|
||||
|
||||
//Check for space.
|
||||
for(var/turf/T in test)
|
||||
T.check_for_space()
|
||||
|
||||
//Make a new, identical air mixture for the other zone.
|
||||
var/datum/gas_mixture/Y_Air = new
|
||||
Y_Air.copy_from(oldzone.air)
|
||||
|
||||
var/zone/Y = new(B,Y_Air) //Make a new zone starting at B and using Y_Air.
|
||||
|
||||
//Add relevant connections from old zone.
|
||||
for(var/connection/C in oldzone.connections)
|
||||
if((A in Y.contents) || (B in Y.contents))
|
||||
if(!Y.connections) Y.connections = list()
|
||||
Y.connections += C
|
||||
|
||||
//Add the remaining space tiles to this zone.
|
||||
for(var/turf/space/T in oldzone.space_tiles)
|
||||
if(!(T in Z.space_tiles))
|
||||
Y.AddSpace(T)
|
||||
|
||||
oldzone.air = null
|
||||
del oldzone
|
||||
else
|
||||
if(istype(A,/turf/space) && B.zone)
|
||||
B.zone.RemoveSpace(A)
|
||||
else if(istype(B,/turf/space) && A.zone)
|
||||
A.zone.RemoveSpace(B)
|
||||
+110
-110
@@ -1,117 +1,118 @@
|
||||
#define QUANTIZE(variable) (round(variable,0.0001))
|
||||
var/explosion_halt = 0
|
||||
var/zone_share_percent = 1
|
||||
zone
|
||||
proc/process()
|
||||
//Does rebuilding stuff. Not sure if used.
|
||||
if(rebuild)
|
||||
//Deletes zone if empty.
|
||||
if(!contents.len)
|
||||
del src
|
||||
return 0
|
||||
var/zone_share_percent = 4
|
||||
zone/proc/process()
|
||||
//Does rebuilding stuff. Not sure if used.
|
||||
if(rebuild)
|
||||
//Deletes zone if empty.
|
||||
if(!contents.len)
|
||||
del src
|
||||
return 0
|
||||
|
||||
//Choose a random turf and regenerate the zone from it.
|
||||
var
|
||||
turf/sample = pick(contents)
|
||||
list/new_contents = FloodFill(sample)
|
||||
problem = 0
|
||||
//Choose a random turf and regenerate the zone from it.
|
||||
var
|
||||
turf/sample = pick(contents)
|
||||
list/new_contents = FloodFill(sample)
|
||||
problem = 0
|
||||
|
||||
//If something isn't carried over, there was a complication.
|
||||
for(var/turf/T in contents)
|
||||
if(!(T in new_contents))
|
||||
problem = 1
|
||||
//If something isn't carried over, there was a complication.
|
||||
for(var/turf/T in contents)
|
||||
if(!(T in new_contents))
|
||||
problem = 1
|
||||
|
||||
if(problem)
|
||||
//Build some new zones for stuff that wasn't included.
|
||||
var/list/rebuild_turfs = list()
|
||||
for(var/turf/T in contents - new_contents)
|
||||
contents -= T
|
||||
rebuild_turfs += T
|
||||
T.zone = null
|
||||
for(var/turf/T in rebuild_turfs)
|
||||
if(!T.zone)
|
||||
var/zone/Z = new/zone(T)
|
||||
Z.air.copy_from(air)
|
||||
rebuild = 0
|
||||
if(problem)
|
||||
//Build some new zones for stuff that wasn't included.
|
||||
var/list/rebuild_turfs = list()
|
||||
for(var/turf/T in contents - new_contents)
|
||||
contents -= T
|
||||
rebuild_turfs += T
|
||||
T.zone = null
|
||||
for(var/turf/T in rebuild_turfs)
|
||||
if(!T.zone)
|
||||
var/zone/Z = new/zone(T)
|
||||
Z.air.copy_from(air)
|
||||
|
||||
//Sometimes explosions will cause the air to be deleted for some reason.
|
||||
if(!air)
|
||||
air = new()
|
||||
air.adjustGases(MOLES_O2STANDARD, 0, MOLES_N2STANDARD, 0, list())
|
||||
world.log << "Air object lost in zone. Regenerating."
|
||||
rebuild = 0
|
||||
|
||||
//Counting up space.
|
||||
var/total_space = 0
|
||||
//Sometimes explosions will cause the air to be deleted for some reason.
|
||||
if(!air)
|
||||
air = new()
|
||||
air.adjust(MOLES_O2STANDARD, 0, MOLES_N2STANDARD, 0, list())
|
||||
world.log << "Air object lost in zone. Regenerating."
|
||||
|
||||
if(space_tiles)
|
||||
for(var/T in space_tiles)
|
||||
if(!istype(T,/turf/space)) space_tiles -= T
|
||||
total_space++
|
||||
//Counting up space.
|
||||
var/total_space = 0
|
||||
|
||||
//Add checks to ensure that we're not sucking air out of an empty room.
|
||||
if(total_space && air.total_moles > 0.1 && air.temperature > TCMB+0.5)
|
||||
//If there is space, air should flow out of the zone.
|
||||
//if(abs(air.pressure) > vsc.airflow_lightest_pressure)
|
||||
// AirflowSpace(src)
|
||||
ShareSpace(air,total_space*(zone_share_percent/100))
|
||||
if(space_tiles)
|
||||
for(var/T in space_tiles)
|
||||
if(!istype(T,/turf/space))
|
||||
space_tiles -= T
|
||||
continue
|
||||
total_space++
|
||||
|
||||
//React the air here.
|
||||
//air.react(null,0)
|
||||
//Add checks to ensure that we're not sucking air out of an empty room.
|
||||
if(total_space && air.total_moles > 0.1 && air.temperature > TCMB+0.5)
|
||||
//If there is space, air should flow out of the zone.
|
||||
//if(abs(air.pressure) > vsc.airflow_lightest_pressure)
|
||||
// AirflowSpace(src)
|
||||
ShareSpace(air,total_space*(zone_share_percent/100))
|
||||
|
||||
//Check the graphic.
|
||||
//React the air here.
|
||||
//air.react(null,0)
|
||||
|
||||
air.graphic = 0
|
||||
if(air.toxins > MOLES_PLASMA_VISIBLE)
|
||||
air.graphic = 1
|
||||
else if(air.trace_gases.len)
|
||||
var/datum/gas/sleeping_agent = locate(/datum/gas/sleeping_agent) in air.trace_gases
|
||||
if(sleeping_agent && (sleeping_agent.moles > 1))
|
||||
air.graphic = 2
|
||||
else
|
||||
air.graphic = 0
|
||||
//Check the graphic.
|
||||
|
||||
//Only run through the individual turfs if there's reason to.
|
||||
if(air.graphic != air.graphic_archived || air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
|
||||
air.graphic = 0
|
||||
if(air.toxins > MOLES_PLASMA_VISIBLE)
|
||||
air.graphic = 1
|
||||
else if(air.trace_gases.len)
|
||||
var/datum/gas/sleeping_agent = locate(/datum/gas/sleeping_agent) in air.trace_gases
|
||||
if(sleeping_agent && (sleeping_agent.moles > 1))
|
||||
air.graphic = 2
|
||||
|
||||
for(var/turf/simulated/S in contents)
|
||||
//Update overlays.
|
||||
if(air.graphic != air.graphic_archived)
|
||||
if(S.HasDoor(1))
|
||||
S.update_visuals()
|
||||
else
|
||||
S.update_visuals(air)
|
||||
//Only run through the individual turfs if there's reason to.
|
||||
if(air.graphic != air.graphic_archived || air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
|
||||
|
||||
//Expose stuff to extreme heat.
|
||||
if(air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
|
||||
for(var/atom/movable/item in S)
|
||||
item.temperature_expose(air, air.temperature, CELL_VOLUME)
|
||||
S.temperature_expose(air, air.temperature, CELL_VOLUME)
|
||||
for(var/turf/simulated/S in contents)
|
||||
//Update overlays.
|
||||
if(air.graphic != air.graphic_archived)
|
||||
if(S.HasDoor(1))
|
||||
S.update_visuals()
|
||||
else
|
||||
S.update_visuals(air)
|
||||
|
||||
//Archive graphic so we can know if it's different.
|
||||
air.graphic_archived = air.graphic
|
||||
//Expose stuff to extreme heat.
|
||||
if(air.temperature > FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
|
||||
for(var/atom/movable/item in S)
|
||||
item.temperature_expose(air, air.temperature, CELL_VOLUME)
|
||||
S.temperature_expose(air, air.temperature, CELL_VOLUME)
|
||||
|
||||
//Ensure temperature does not reach absolute zero.
|
||||
air.temperature = max(TCMB,air.temperature)
|
||||
//Archive graphic so we can know if it's different.
|
||||
air.graphic_archived = air.graphic
|
||||
|
||||
//Handle connections to other zones.
|
||||
if(length(connections))
|
||||
for(var/connection/C in connections)
|
||||
//Check if the connection is valid first.
|
||||
C.Cleanup()
|
||||
//Do merging if conditions are met. Specifically, if there's a non-door connection
|
||||
//to somewhere with space, the zones are merged regardless of equilibrium, to speed
|
||||
//up spacing in areas with double-plated windows.
|
||||
if(C && !C.indirect && C.A.zone && C.B.zone)
|
||||
if(C.A.zone.air.compare(C.B.zone.air) || total_space)
|
||||
ZMerge(C.A.zone,C.B.zone)
|
||||
//Ensure temperature does not reach absolute zero.
|
||||
air.temperature = max(TCMB,air.temperature)
|
||||
|
||||
//Share some
|
||||
for(var/zone/Z in connected_zones)
|
||||
//Ensure we're not doing pointless calculations on equilibrium zones.
|
||||
if(abs(air.total_moles - Z.air.total_moles) > 0.1 || abs(air.temperature - Z.air.temperature) > 0.1)
|
||||
//if(abs(Z.air.pressure - air.pressure) > vsc.airflow_lightest_pressure)
|
||||
// Airflow(src,Z)
|
||||
ShareRatio(air,Z.air,connected_zones[Z]*(zone_share_percent/100))
|
||||
//Handle connections to other zones.
|
||||
if(length(connections))
|
||||
for(var/connection/C in connections)
|
||||
//Check if the connection is valid first.
|
||||
if(!C.Cleanup())
|
||||
continue
|
||||
//Do merging if conditions are met. Specifically, if there's a non-door connection
|
||||
//to somewhere with space, the zones are merged regardless of equilibrium, to speed
|
||||
//up spacing in areas with double-plated windows.
|
||||
if(C && !C.indirect && C.A.zone && C.B.zone)
|
||||
if(C.A.zone.air.compare(C.B.zone.air) || total_space)
|
||||
ZMerge(C.A.zone,C.B.zone)
|
||||
|
||||
//Share some
|
||||
for(var/zone/Z in connected_zones)
|
||||
//Ensure we're not doing pointless calculations on equilibrium zones.
|
||||
if(abs(air.total_moles - Z.air.total_moles) > 0.1 || abs(air.temperature - Z.air.temperature) > 0.1)
|
||||
//if(abs(Z.air.pressure - air.pressure) > vsc.airflow_lightest_pressure)
|
||||
// Airflow(src,Z)
|
||||
ShareRatio(air,Z.air,connected_zones[Z]*(zone_share_percent/100))
|
||||
|
||||
proc/ShareRatio(datum/gas_mixture/A, datum/gas_mixture/B, ratio)
|
||||
//Shares a specific ratio of gas between mixtures using simple weighted averages.
|
||||
@@ -215,19 +216,18 @@ proc/ShareSpace(datum/gas_mixture/A, ratio)
|
||||
return 1
|
||||
|
||||
|
||||
zone/proc
|
||||
connected_zones()
|
||||
//A legacy proc for getting connected zones.
|
||||
. = list()
|
||||
for(var/connection/C in connections)
|
||||
var/zone/Z
|
||||
if(C.A.zone == src)
|
||||
Z = C.B.zone
|
||||
else
|
||||
Z = C.A.zone
|
||||
zone/proc/connected_zones()
|
||||
//A legacy proc for getting connected zones.
|
||||
. = list()
|
||||
for(var/connection/C in connections)
|
||||
var/zone/Z
|
||||
if(C.A.zone == src)
|
||||
Z = C.B.zone
|
||||
else
|
||||
Z = C.A.zone
|
||||
|
||||
if(Z in .)
|
||||
.[Z]++
|
||||
else
|
||||
. += Z
|
||||
.[Z] = 1
|
||||
if(Z in .)
|
||||
.[Z]++
|
||||
else
|
||||
. += Z
|
||||
.[Z] = 1
|
||||
Reference in New Issue
Block a user