Merge branch 'dev' of https://github.com/Baystation12/Baystation12 into 4/27/2015_bay_sync_2

This commit is contained in:
Neerti
2015-04-27 05:30:36 -04:00
694 changed files with 13409 additions and 13050 deletions
@@ -184,8 +184,7 @@ datum/controller/process/proc/kill()
killed = TRUE
// This should del
del(src)
del(src) // This should del
datum/controller/process/proc/scheck(var/tickId = 0)
if (killed)
@@ -315,3 +314,9 @@ datum/controller/process/proc/enable()
/datum/controller/process/proc/getTicks()
return ticks
/datum/controller/process/proc/getStatName()
return name
/datum/controller/process/proc/getTickTime()
return "#[getTicks()]\t- [getLastRunTime()]"
+4
View File
@@ -4,3 +4,7 @@
/datum/controller/process/alarm/doWork()
alarm_manager.fire()
/datum/controller/process/alarm/getStatName()
var/list/alarms = alarm_manager.active_alarms()
return ..()+"([alarms.len])"
+3
View File
@@ -9,3 +9,6 @@
/datum/controller/process/disease/doWork()
updateQueueInstance.init(active_diseases, "process")
updateQueueInstance.Run()
/datum/controller/process/disease/getStatName()
return ..()+"([active_diseases.len])"
+73 -27
View File
@@ -1,12 +1,14 @@
var/datum/controller/process/garbage_collector/garbage_collector
var/list/delayed_garbage = list()
// #define GC_DEBUG 1
/datum/controller/process/garbage_collector
var/garbage_collect = 1 // Whether or not to actually do work
var/collection_timeout = 300 //deciseconds to wait to let running procs finish before we just say fuck it and force del() the object
var/max_checks_multiplier = 5 //multiplier (per-decisecond) for calculating max number of tests per SS tick. These tests check if our GC'd objects are actually GC'd
var/max_forcedel_multiplier = 1 //multiplier (per-decisecond) for calculating max number of force del() calls per SS tick.
var/max_checks_multiplier = 5 //multiplier (per-decisecond) for calculating max number of tests per tick. These tests check if our GC'd objects are actually GC'd
var/max_forcedel_multiplier = 1 //multiplier (per-decisecond) for calculating max number of force del() calls per tick.
var/dels = 0 // number of del()'s we've done this tick
var/dels = 0 // number of del()'s we've done this tick
var/hard_dels = 0 // number of hard dels in total
var/list/destroyed = list() // list of refID's of things that should be garbage collected
// refID's are associated with the time at which they time out and need to be manually del()
// we do this so we aren't constantly locating them and preventing them from being gc'd
@@ -16,14 +18,21 @@ var/datum/controller/process/garbage_collector/garbage_collector
/datum/controller/process/garbage_collector/setup()
name = "garbage"
schedule_interval = 60 // every 6 seconds
schedule_interval = 6 SECONDS
if(!garbage_collector)
garbage_collector = src
/datum/controller/process/garbage_collector/doWork()
dels = 0
for(var/garbage in delayed_garbage)
qdel(garbage)
delayed_garbage.Cut()
delayed_garbage = null
/datum/controller/process/garbage_collector/doWork()
if(!garbage_collect)
return
dels = 0
var/time_to_kill = world.time - collection_timeout // Anything qdel() but not GC'd BEFORE this time needs to be manually del()
var/checkRemain = max_checks_multiplier * schedule_interval
var/maxDels = max_forcedel_multiplier * schedule_interval
@@ -31,76 +40,113 @@ var/datum/controller/process/garbage_collector/garbage_collector
while(destroyed.len && --checkRemain >= 0)
if(dels >= maxDels)
#ifdef GC_DEBUG
testing("GC: Reached max force dels per tick [dels] vs [GC_FORCE_DEL_PER_TICK]")
testing("GC: Reached max force dels per tick [dels] vs [maxDels]")
#endif
break // Server's already pretty pounded, everything else can wait 2 seconds
var/refID = destroyed[1]
var/GCd_at_time = destroyed[refID]
if(GCd_at_time > time_to_kill)
#ifdef GC_DEBUG
testing("GC: [refID] not old enough, breaking at [world.time] for [GCd_at_time - time_to_kill] deciseconds until [GCd_at_time + GC_COLLECTION_TIMEOUT]")
testing("GC: [refID] not old enough, breaking at [world.time] for [GCd_at_time - time_to_kill] deciseconds until [GCd_at_time + collection_timeout]")
#endif
break // Everything else is newer, skip them
var/atom/A = locate(refID)
#ifdef GC_DEBUG
testing("GC: [refID] old enough to test: GCd_at_time: [GCd_at_time] time_to_kill: [time_to_kill] current: [world.time]")
#endif
if(A && A.gc_destroyed == GCd_at_time) // So if something else coincidently gets the same ref, it's not deleted by mistake
if(A && A.gcDestroyed == GCd_at_time) // So if something else coincidently gets the same ref, it's not deleted by mistake
// Something's still referring to the qdel'd object. Kill it.
testing("GC: -- \ref[A] | [A.type] was unable to be GC'd and was deleted --")
logging["[A.type]"]++
del(A)
++dels
++hard_dels
#ifdef GC_DEBUG
else
testing("GC: [refID] properly GC'd at [world.time] with timeout [GCd_at_time]")
#endif
destroyed.Cut(1, 2)
scheck()
/datum/controller/process/garbage_collector/proc/AddTrash(datum/A)
if(!istype(A) || !isnull(A.gc_destroyed))
if(!istype(A) || !isnull(A.gcDestroyed))
return
#ifdef GC_DEBUG
testing("GC: AddTrash([A.type])")
testing("GC: AddTrash(\ref[A] - [A.type])")
#endif
A.gc_destroyed = world.time
A.gcDestroyed = world.time
destroyed -= "\ref[A]" // Removing any previous references that were GC'd so that the current object will be at the end of the list.
destroyed["\ref[A]"] = world.time
/datum/controller/process/garbage_collector/getStatName()
return ..()+"([garbage_collector.dels]/[garbage_collector.hard_dels])"
// Should be treated as a replacement for the 'del' keyword.
// Datums passed to this will be given a chance to clean up references to allow the GC to collect them.
/proc/qdel(var/datum/A)
if(!A)
return
if(istype(A, /list))
var/list/L = A
for(var/E in L)
qdel(E)
return
if(!istype(A))
//warning("qdel() passed object of type [A.type]. qdel() can only handle /datum types.")
del(A)
garbage_collector.dels++
else if(isnull(A.gc_destroyed))
// Let our friend know they're about to get fucked up.
garbage_collector.hard_dels++
else if(isnull(A.gcDestroyed))
// Let our friend know they're about to get collected
. = !A.Destroy()
if(. && A)
A.finalize_qdel()
/datum/proc/finalize_qdel()
if(IsPooled(src))
PlaceInPool(src)
else
del(src)
/atom/finalize_qdel()
if(IsPooled(src))
PlaceInPool(src)
else
if(garbage_collector)
garbage_collector.AddTrash(src)
else
delayed_garbage |= src
/icon/finalize_qdel()
del(src)
/imagine/finalize_qdel()
del(src)
/mob/finalize_qdel()
del(src)
/turf/finalize_qdel()
garbage_collector.AddTrash(src)
del(src)
// Default implementation of clean-up code.
// This should be overridden to remove all references pointing to the object being destroyed.
// Return true if the the GC controller should allow the object to continue existing. (Useful if pooling objects.)
/datum/proc/Destroy()
tag = null
return
/datum/var/gc_destroyed //Time when this object was destroyed.
#ifdef TESTING
/client/var/running_find_references
/mob/verb/create_thing()
set category = "Debug"
set name = "Create Thing"
var/path = input("Enter path")
var/atom/thing = new path(loc)
thing.find_references()
/atom/verb/find_references()
set category = "Debug"
set name = "Find References"
@@ -119,8 +165,8 @@ var/datum/controller/process/garbage_collector/garbage_collector
return
// Remove this object from the list of things to be auto-deleted.
if(garbage)
garbage.destroyed -= "\ref[src]"
if(garbage_collector)
garbage_collector.destroyed -= "\ref[src]"
usr.client.running_find_references = type
testing("Beginning search for references to a [type].")
@@ -146,13 +192,13 @@ var/datum/controller/process/garbage_collector/garbage_collector
/client/verb/purge_all_destroyed_objects()
set category = "Debug"
if(garbage)
while(garbage.destroyed.len)
var/datum/o = locate(garbage.destroyed[1])
if(istype(o) && o.gc_destroyed)
if(garbage_collector)
while(garbage_collector.destroyed.len)
var/datum/o = locate(garbage_collector.destroyed[1])
if(istype(o) && o.gcDestroyed)
del(o)
garbage.dels++
garbage.destroyed.Cut(1, 2)
garbage_collector.dels++
garbage_collector.destroyed.Cut(1, 2)
#endif
#ifdef GC_DEBUG
+1 -1
View File
@@ -9,7 +9,7 @@
if(!istype(C.mob, /mob/dead))
log_access("AFK: [key_name(C)]")
C << "<SPAN CLASS='warning'>You have been inactive for more than 10 minutes and have been disconnected.</SPAN>"
del(C)
del(C) // Don't qdel, cannot override finalize_qdel behaviour for clients.
scheck()
+4
View File
@@ -42,3 +42,7 @@
#endif
scheck()
/datum/controller/process/machinery/getStatName()
return ..()+"([machines.len])"
+3
View File
@@ -18,3 +18,6 @@
if(updateQueueInstance)
updateQueueInstance.init(mob_list, "Life")
updateQueueInstance.Run()
/datum/controller/process/mob/getStatName()
return ..()+"([mob_list.len])"
+3
View File
@@ -9,3 +9,6 @@
/datum/controller/process/nanoui/doWork()
updateQueueInstance.init(nanomanager.processing_uis, "process")
updateQueueInstance.Run()
/datum/controller/process/nanoui/getStatName()
return ..()+"([nanomanager.processing_uis.len])"
+3
View File
@@ -19,3 +19,6 @@ var/global/list/object_profiling = list()
if(updateQueueInstance)
updateQueueInstance.init(processing_objects, "process")
updateQueueInstance.Run()
/datum/controller/process/obj/getStatName()
return ..()+"([processing_objects.len])"
+3
View File
@@ -10,3 +10,6 @@
continue
pipe_networks.Remove(pipeNetwork)
/datum/controller/process/pipenet/getStatName()
return ..()+"([pipe_networks.len])"
+3
View File
@@ -10,3 +10,6 @@
continue
powernets.Remove(powerNetwork)
/datum/controller/process/powernet/getStatName()
return ..()+"([powernets.len])"
@@ -161,15 +161,6 @@ atom/movable/New()
trueLuminosity = luminosity * luminosity
light = new(src)
//Objects with opacity will trigger nearby lights to update at next lighting process.
atom/movable/Del()
if(opacity)
if(isturf(loc))
if(loc:lighting_lumcount > 1)
UpdateAffectingLights()
..()
//Sets our luminosity.
//If we have no light it will create one.
//If we are setting luminosity to 0 the light will be cleaned up by the controller and garbage collected once all its
+1 -1
View File
@@ -7,7 +7,7 @@ datum/controller/transfer_controller/New()
timerbuffer = config.vote_autotransfer_initial
processing_objects += src
datum/controller/transfer_controller/Del()
datum/controller/transfer_controller/Destroy()
processing_objects -= src
datum/controller/transfer_controller/proc/process()
+3 -3
View File
@@ -223,7 +223,7 @@ var/global/datum/controller/radio/radio_controller
frequency.remove_listener(device)
if(frequency.devices.len == 0)
del(frequency)
qdel(frequency)
frequencies -= f_text
return 1
@@ -248,7 +248,7 @@ var/global/datum/controller/radio/radio_controller
if(range)
start_point = get_turf(source)
if(!start_point)
del(signal)
qdel(signal)
return 0
if (filter)
send_to_filter(source, signal, filter, start_point, range)
@@ -297,7 +297,7 @@ var/global/datum/controller/radio/radio_controller
devices_line -= null
if (devices_line.len==0)
devices -= devices_filter
del(devices_line)
qdel(devices_line)
/datum/signal
var/obj/source
@@ -242,8 +242,8 @@ var/global/datum/emergency_shuttle_controller/emergency_shuttle
sleep(speed)
step(src, direction)
for(var/obj/effect/starender/E in loc)
del(src)
qdel(src)
return
/obj/effect/starender
invisibility = 101
+1 -1
View File
@@ -14,7 +14,7 @@ var/datum/controller/failsafe/Failsafe
//There can be only one failsafe. Out with the old in with the new (that way we can restart the Failsafe by spawning a new one)
if(Failsafe != src)
if(istype(Failsafe))
del(Failsafe)
qdel(Failsafe)
Failsafe = src
Failsafe.process()
+1 -1
View File
@@ -22,7 +22,7 @@ datum/controller/lighting/New()
if(lighting_controller != src)
if(istype(lighting_controller,/datum/controller/lighting))
Recover() //if we are replacing an existing lighting_controller (due to a crash) we attempt to preserve as much as we can
del(lighting_controller)
qdel(lighting_controller)
lighting_controller = src
+1 -1
View File
@@ -19,7 +19,7 @@ datum/controller/game_controller/New()
if(master_controller != src)
log_debug("Rebuilding Master Controller")
if(istype(master_controller))
del(master_controller)
qdel(master_controller)
master_controller = src
if(!job_master)
+4 -1
View File
@@ -62,7 +62,7 @@
usr.client.debug_variables(antag)
message_admins("Admin [key_name_admin(usr)] is debugging the [antag.role_text] template.")
/client/proc/debug_controller(controller in list("Master","Failsafe","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano"))
/client/proc/debug_controller(controller in list("Master","Failsafe","Ticker","Ticker Process","Lighting","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano"))
set category = "Debug"
set name = "Debug Controller"
set desc = "Debug the various periodic loop controllers for the game (be careful!)"
@@ -78,6 +78,9 @@
if("Ticker")
debug_variables(ticker)
feedback_add_details("admin_verb","DTicker")
if("Ticker Process")
debug_variables(tickerProcess)
feedback_add_details("admin_verb","DTickerProcess")
if("Lighting")
debug_variables(lighting_controller)
feedback_add_details("admin_verb","DLighting")