Completed ZAS rework. Needs testing, and consideration to make zones sleep.

This commit is contained in:
SkyMarshal
2013-08-26 20:57:38 -07:00
committed by SkyMarshal
parent 073f462e1b
commit e8f9d19c75
9 changed files with 85 additions and 27 deletions

View File

@@ -1,3 +1,14 @@
client/proc/ZoneTick()
set category = "Debug"
set name = "Process Atmos"
var/result = air_master.Tick()
if(result)
src << "Sucessfully Processed."
else
src << "Failed to process! ([air_master.tick_progress])"
client/proc/Zone_Info(turf/T as null|turf)
set category = "Debug"

View File

@@ -53,7 +53,6 @@ Important Procedures
*/
var/kill_air = 0
var/tick_multiplier = 2
atom/proc/CanPass(atom/movable/mover, turf/target, height=1.5, air_group = 0)
@@ -113,7 +112,7 @@ var/datum/controller/air_system/air_master
var/tick_progress = 0
/datum/controller/air_system/proc/Tetup()
/datum/controller/air_system/proc/Setup()
//Purpose: Call this at the start to setup air groups geometry
// (Warning: Very processor intensive but only must be done once per round)
//Called by: Gameticker/Master controller
@@ -155,20 +154,21 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
set background = 1
while(1)
if(!kill_air)
current_cycle++
if(!air_processing_killed)
var/success = Tick() //Changed so that a runtime does not crash the ticker.
if(!success) //Runtimed.
failed_ticks++
if(failed_ticks > 20)
world << "<font color='red'><b>ERROR IN ATMOS TICKER. Killing air simulation!</font></b>"
kill_air = 1
air_processing_killed = 1
sleep(max(5,update_delay*tick_multiplier))
/datum/controller/air_system/proc/Tick()
. = 1 //Set the default return value, for runtime detection.
current_cycle++
//If there are tiles to update, do so.
tick_progress = "update_air_properties"
if(tiles_to_update.len)
@@ -184,27 +184,47 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
if(.)
if(tiles_to_update_alternate)
tiles_to_update = tiles_to_update_alternate
tiles_to_update_alternate = null
else
tiles_to_update = list()
else if(tiles_to_update_alternate)
tiles_to_update |= tiles_to_update_alternate
tiles_to_update_alternate = null
//Check sanity on connection objects.
if(.)
tick_progress = "connections_to_check"
if(connections_to_check.len)
checking_connections = TRUE
for(var/connection/C in connections_to_check)
C.CheckPassSanity()
checking_connections = FALSE
if(connections_to_check_alternate)
connections_to_check = connections_to_check_alternate
connections_to_check_alternate = null
else
connections_to_check = list()
//Ensure tiles still have zones.
if(.)
tick_progress = "tiles_to_reconsider_zones"
if(tiles_to_reconsider_zones.len)
reconsidering_zones = TRUE
for(var/turf/simulated/T in tiles_to_reconsider_zones)
if(!T.zone)
new /zone(T)
reconsidering_zones = FALSE
if(tiles_to_reconsider_alternate)
tiles_to_reconsider_zones = tiles_to_reconsider_alternate
tiles_to_reconsider_alternate = null
else
tiles_to_reconsider_zones = list()
//Process zones.
@@ -217,6 +237,7 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
Z.last_update = current_cycle
if(. && Z && !output)
. = 0
//Process fires.
if(.)
tick_progress = "active_hotspots (fire)"
@@ -247,3 +268,32 @@ Total Unsimulated Turfs: [world.maxx*world.maxy*world.maxz - simulated_turf_coun
tiles_to_update_alternate |= tiles_to_check
else
tiles_to_update |= tiles_to_check
/datum/controller/air_system/proc/AddConnectionToCheck(connection/connection)
if(checking_connections)
if(istype(connection, /list))
if(!connections_to_check_alternate)
connections_to_check_alternate = connection
else if(!connections_to_check_alternate)
connections_to_check_alternate = list()
connections_to_check_alternate |= connection
else
connections_to_check |= connection
/datum/controller/air_system/proc/ReconsiderTileZone(var/turf/simulated/zoneless_turf)
if(zoneless_turf.zone)
return
if(reconsidering_zones)
if(!tiles_to_reconsider_alternate)
tiles_to_reconsider_alternate = list()
tiles_to_reconsider_alternate |= zoneless_turf
else
tiles_to_reconsider_zones |= zoneless_turf

View File

@@ -158,10 +158,9 @@
//Check pass sanity of the connections.
if("\ref[src]" in air_master.turfs_with_connections)
for(var/connection/C in air_master.turfs_with_connections["\ref[src]"])
air_master.connections_to_check |= C
air_master.AddConnectionToCheck(air_master.turfs_with_connections["\ref[src]"])
if(zone && !zone.rebuild && CanPass(null, src, 0, 0))
if(zone && CanPass(null, src, 0, 0))
for(var/direction in cardinal)
var/turf/T = get_step(src,direction)

View File

@@ -54,12 +54,11 @@ var/list/CounterDoorDirections = list(SOUTH,EAST) //Which directions doors turfs
//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
air_master.ReconsiderTileZone(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)
air_master.connections_to_check += C
air_master.AddConnectionToCheck(connections)
zones.Remove(src)
air = null
. = ..()
@@ -73,7 +72,7 @@ var/list/CounterDoorDirections = list(SOUTH,EAST) //Which directions doors turfs
//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
air_master.ReconsiderTileZone(T)
//Removing zone connections and scheduling connection cleanup
for(var/zone/Z in connected_zones)
@@ -81,8 +80,7 @@ var/list/CounterDoorDirections = list(SOUTH,EAST) //Which directions doors turfs
Z.connected_zones.Remove(src)
connected_zones = null
for(var/connection/C in connections)
air_master.connections_to_check += C
air_master.AddConnectionToCheck(connections)
connections = null
return 1

View File

@@ -126,7 +126,6 @@ datum/controller/game_controller/proc/process()
timer = world.timeofday
last_thing_processed = air_master.type
air_master.current_cycle++
if(!air_master.Tick()) //Runtimed.
air_master.failed_ticks++
if(air_master.failed_ticks > 5)
@@ -136,6 +135,7 @@ datum/controller/game_controller/proc/process()
log_admin("ZASALERT: unable run zone/process() -- [air_master.tick_progress]")
air_processing_killed = 1
air_master.failed_ticks = 0
air_cost = (world.timeofday - timer) / 10
sleep(breather_ticks)

View File

@@ -318,7 +318,7 @@
/obj/structure/window/proc/update_nearby_tiles(need_rebuild)
if(!air_master)
return 0
AddTurfToUpdate(
air_master.AddTurfToUpdate(get_turf(src))
return 1

View File

@@ -231,8 +231,8 @@
W.zone = src.zone
W.zone.AddTurf(W)
for(var/turf/simulated/T in orange(src,1))
air_master.tiles_to_update.Add(T)
if(air_master)
air_master.AddTurfToUpdate(src)
W.levelupdate()
return W
@@ -252,8 +252,7 @@
W.zone.AddTurf(W)
if(air_master)
for(var/turf/simulated/T in orange(src,1))
air_master.tiles_to_update.Add(T)
air_master.AddTurfToUpdate(src)
W.levelupdate()
return W

View File

@@ -580,11 +580,11 @@ var/list/admin_verbs_mod = list(
set category = "Debug"
set name = "Kill Air"
set desc = "Toggle Air Processing"
if(kill_air)
kill_air = 0
if(air_processing_killed)
air_processing_killed = 0
usr << "<b>Enabled air processing.</b>"
else
kill_air = 1
air_processing_killed = 1
usr << "<b>Disabled air processing.</b>"
feedback_add_details("admin_verb","KA") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
log_admin("[key_name(usr)] used 'kill air'.")

View File

@@ -161,6 +161,7 @@ var/intercom_range_display_status = 0
src.verbs += /client/proc/disable_movement
src.verbs += /client/proc/Zone_Info
src.verbs += /client/proc/Test_ZAS_Connection
src.verbs += /client/proc/ZoneTick
//src.verbs += /client/proc/cmd_admin_rejuvenate
feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!