Adds more runtime checking and makes zones exploit the garbage collector to be destroyed, which is more resource efficient.

This commit is contained in:
SkyMarshal
2012-08-02 11:47:05 -07:00
parent e9937050aa
commit 4f7f3e5d7f
7 changed files with 57 additions and 32 deletions

View File

@@ -228,7 +228,6 @@
#define DEBUG
// END_PREFERENCES
// BEGIN_INCLUDE
#include "code\modules\mob\simple_animal\munchkin.dm"
#include "code\access_defines.dm"
#include "code\names.dm"
#include "code\setup.dm"
@@ -1081,6 +1080,7 @@
#include "code\modules\mob\simple_animal\corgi.dm"
#include "code\modules\mob\simple_animal\crab.dm"
#include "code\modules\mob\simple_animal\life.dm"
#include "code\modules\mob\simple_animal\munchkin.dm"
#include "code\modules\mob\simple_animal\parrot.dm"
#include "code\modules\mob\simple_animal\shade.dm"
#include "code\modules\mob\simple_animal\worm.dm"

View File

@@ -189,10 +189,8 @@ connection
return 0
return 1
proc/UpdateZones() //Changes connection data in the zones if it is required.
if(istype(A,/turf/space) || istype(B,/turf/space))
src.Cleanup()
return
proc/CheckPassSanity()
Cleanup()
if(A.ZAirPass(B))
var/door_pass = A.CanPass(null,B,1.5,1)
if(door_pass || A.CanPass(null,B,0,0))
@@ -237,11 +235,6 @@ connection
else //If I can no longer pass air, better delete
del src
proc/CheckPassSanity()
Cleanup()
UpdateZones()
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)

View File

@@ -31,20 +31,40 @@ zone
//Add this zone to the global list.
zones.Add(src)
//LEGACY, DO NOT USE.
Del()
//Ensuring the zone list doesn't get clogged with null values.
for(var/turf/simulated/T in contents)
if(T.zone && T.zone == src)
T.zone = null
air_master.tiles_to_update |= T
RemoveTurf(T)
air_master.tiles_to_reconsider_zones += T
for(var/zone/Z in connected_zones)
if(src in Z.connected_zones)
Z.connected_zones.Remove(src)
for(var/connection/C in connections)
del C
air_master.connections_to_check += C
zones.Remove(src)
air = null
. = ..()
//Handles deletion via garbage collection.
proc/SoftDelete()
zones.Remove(src)
air = null
//Ensuring the zone list doesn't get clogged with null values.
for(var/turf/simulated/T in contents)
RemoveTurf(T)
air_master.tiles_to_reconsider_zones += T
for(var/zone/Z in connected_zones)
if(src in Z.connected_zones)
Z.connected_zones.Remove(src)
for(var/connection/C in connections)
if(C.zone_A == src)
C.zone_A = null
if(C.zone_B == src)
C.zone_B = null
air_master.connections_to_check += C
proc/FloodFill(turf/start)
if(!istype(start))
return list()

View File

@@ -96,10 +96,11 @@ datum
var/list/obj/fire/active_hotspots = list()
//Special functions lists
var/list/turf/simulated/tiles_to_reconsider_zones = list()
//Geometry updates lists
var/list/turf/simulated/tiles_to_update = list()
var/list/connection/connections_checked = list()
var/list/connection/connections_to_check = list()
var/current_cycle = 0
var/update_delay = 5 //How long between check should it try to process atmos again.
@@ -174,15 +175,22 @@ datum
log_file << "\"\The [get_area(pick(z.contents))]\",[z.air.oxygen],[z.air.nitrogen],[z.air.carbon_dioxide],[z.air.toxins],[z.air.temperature],[z.air.group_multiplier * z.air.volume]"
next_stat_check = current_cycle + (rand(5,7)*60)
if(tiles_to_update.len > 0) //If there are tiles to update, do so.
if(tiles_to_update.len) //If there are tiles to update, do so.
for(var/turf/simulated/T in tiles_to_update)
var/output = T.update_air_properties()
if(. && T && !output)
. = 0 //If a runtime occured, make sure we can sense it.
tiles_to_update = list()
for(var/connection/C in connections_checked)
if(connections_to_check.len)
for(var/connection/C in connections_to_check)
C.CheckPassSanity()
connections_checked = list()
connections_to_check = list()
if(tiles_to_reconsider_zones.len)
for(var/turf/simulated/T in tiles_to_reconsider_zones)
if(!T.zone)
new /zone(T)
for(var/zone/Z in zones)
if(Z.last_update < current_cycle)

View File

@@ -195,8 +195,8 @@ turf
if("\ref[src]" in air_master.turfs_with_connections) //Check pass sanity of the connections.
for(var/connection/C in air_master.turfs_with_connections["\ref[src]"])
if(!(C in air_master.connections_checked))
air_master.connections_checked += C
if(!(C in air_master.connections_to_check))
air_master.connections_to_check += C
. = update_zone_properties() //Update self zone and adjacent zones.

View File

@@ -16,7 +16,8 @@
contents -= T
if(air)
air.group_multiplier--
T.zone = null
if(T.zone == src)
T.zone = null
proc/AddSpace(turf/space/S)
//Adds a space tile to the list, and creates the list if null.
@@ -104,7 +105,7 @@ proc/ZMerge(zone/A,zone/B)
for(var/connection/C in A.connections)
C.Cleanup()
del B
B.SoftDelete()
proc/ZConnect(turf/simulated/A,turf/simulated/B)
//Connects two zones by forming a connection object representing turfs A and B.

View File

@@ -1,15 +1,17 @@
#define QUANTIZE(variable) (round(variable,0.0001))
zone/proc/process()
. = 1
//Deletes zone if empty.
if(!contents.len)
del src
return SoftDelete()
//Does rebuilding stuff.
if(rebuild)
rebuild = 0
Rebuild() //Shoving this into a proc.
if(!contents.len) //If we got soft deleted.
return
//Sometimes explosions will cause the air to be deleted for some reason.
if(!air)
air = new()
@@ -84,13 +86,14 @@ zone/proc/process()
//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.return_pressure() - air.return_pressure()) > vsc.airflow_lightest_pressure)
Airflow(src,Z)
ShareRatio( air , Z.air , connected_zones[Z]*vsc.zone_share_percent/200 )
//Divided by 200 since each zone is processed. Each connection is considered twice
//Space tiles force it to try and move twice as much air.
if(air && Z.air)
//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.return_pressure() - air.return_pressure()) > vsc.airflow_lightest_pressure)
Airflow(src,Z)
ShareRatio( air , Z.air , connected_zones[Z]*vsc.zone_share_percent/200 )
//Divided by 200 since each zone is processed. Each connection is considered twice
//Space tiles force it to try and move twice as much air.
proc/ShareRatio(datum/gas_mixture/A, datum/gas_mixture/B, ratio)
//Shares a specific ratio of gas between mixtures using simple weighted averages.
@@ -212,7 +215,7 @@ zone/proc/Rebuild()
if(!istype(sample) || !sample.CanPass(null, sample, 1.5, 1)) //Not a single valid turf.
for(var/turf/simulated/T in contents)
air_master.tiles_to_update |= T
del src
return SoftDelete()
new_contents = FloodFill(sample)