Fix destroys() not calling parent, tweak qdel to use one loop only.

This commit is contained in:
ESwordTheCat
2014-06-14 15:26:29 -08:00
parent a63edbb3fe
commit e40fa55b3b
20 changed files with 56 additions and 134 deletions

View File

@@ -62,8 +62,6 @@ obj/machinery/atmospherics/binary
return null
Destroy()
loc = null
if(node1)
node1.disconnect(src)
del(network1)

View File

@@ -77,8 +77,6 @@
return null
Destroy()
loc = null
if(connected_device)
connected_device.disconnect()

View File

@@ -73,8 +73,6 @@ obj/machinery/atmospherics/trinary
return null
Destroy()
loc = null
if(node1)
node1.disconnect(src)
del(network1)

View File

@@ -99,8 +99,6 @@ obj/machinery/atmospherics/tvalve
return null
Destroy()
loc = null
if(node1)
node1.disconnect(src)
del(network_node1)

View File

@@ -43,8 +43,6 @@
return null
Destroy()
loc = null
if(node)
node.disconnect(src)
del(network)

View File

@@ -78,8 +78,6 @@ obj/machinery/atmospherics/valve
return null
Destroy()
loc = null
if(node1)
node1.disconnect(src)
del(network_node1)

View File

@@ -153,8 +153,6 @@ atom/movable/Destroy()
if(loc:lighting_lumcount > 1)
UpdateAffectingLights()
areaMaster = null
loc = null
..()
//Sets our luminosity.

View File

@@ -1,120 +1,58 @@
#define GC_COLLECTIONS_PER_TICK 250 // Was 100.
#define GC_COLLECTION_TIMEOUT 100 // 10s.
#define GC_FORCE_DEL_PER_TICK 15
#define GC_FORCE_DEL_PER_TICK 20
var/global/datum/controller/garbage_collector/garbage
var/global/list/uncollectable_vars=list(
"alpha",
"bestF",
"bounds",
"bound_height",
"bound_width",
"ckey",
"color",
"contents",
"gender",
"group",
"key",
//"loc",
"locs",
"luminosity",
"parent",
"parent_type",
"step_size",
"glide_size",
"gc_destroyed",
"step_x",
"step_y",
"step_z",
"tag",
"thermal_conductivity",
"type",
"vars",
"verbs",
"x",
"y",
"z",
)
/datum/controller/garbage_collector
var/list/queue = list()
var/list/destroyed = list()
var/waiting = 0
var/del_everything = 1
var/dels = 0
/datum/controller/garbage_collector/proc/Pop()
var/atom/A = queue[1]
if (isnull(A))
var/loopcheck = 0
while (queue.Remove(null))
loopcheck++
if (loopcheck > 50)
break
return
if (del_everything)
del A
return
if (!istype(A,/atom/movable))
testing("GC given a [A.type].")
del A
return
for (var/vname in A.vars)
if (!issaved(A.vars[vname]))
continue
if (vname in uncollectable_vars)
continue
//testing("Unsetting [vname] in [A.type]!")
A.vars[vname] = null
destroyed.Add("\ref[A]")
queue.Remove(A)
// To let them know how hardworking am I :^).
var/dels_count = 0
var/hard_dels = 0
/datum/controller/garbage_collector/proc/process()
dels = 0
var/dels = 0
var/queue_size = min(queue.len, GC_COLLECTIONS_PER_TICK)
for (var/i = 0, ++i <= min(waiting, GC_COLLECTIONS_PER_TICK))
if (waiting--)
Pop()
for (var/i = 0, ++i <= queue_size)
var/atom/movable/A = locate(queue[1])
for (var/i = 0, ++i <= min(destroyed.len, GC_COLLECTIONS_PER_TICK))
var/refID = destroyed[1]
var/atom/A = locate(refID)
if (A && A.gc_destroyed)
if (++dels <= GC_FORCE_DEL_PER_TICK)
break
WARNING("gc process force delete [A.type]")
if (A && A.gc_destroyed && A.gc_destroyed >= world.timeofday - GC_COLLECTION_TIMEOUT)
// Something's still referring to the qdel'd object. Kill it.
del A
dels++
hard_dels++
destroyed.Remove(refID)
queue.Cut(1, 2)
dels_count++
/datum/controller/garbage_collector/proc/AddTrash(const/atom/A)
#undef GC_FORCE_DEL_PER_TICK
#undef GC_COLLECTION_TIMEOUT
#undef GC_COLLECTIONS_PER_TICK
/datum/controller/garbage_collector/proc/AddTrash(const/atom/movable/A)
if (isnull(A))
return
if (del_everything)
del A
dels++
hard_dels++
dels_count++
return
queue.Add(A)
waiting++
/*
* NEVER USE THIS FOR ANYTHING OTHER THAN /atom.
* NEVER USE THIS FOR ANYTHING OTHER THAN /atom/movable and derived types.
*/
/proc/qdel(const/atom/A)
if (isnull(A)) // Two possibilities, proc is called with null arg or object is gced normally.
/proc/qdel(const/atom/movable/A)
if (isnull(A))
return
if (isnull(garbage))
@@ -122,9 +60,10 @@ var/global/list/uncollectable_vars=list(
return
if (!istype(A))
WARNING("qdel() passed object of type [A.type]. qdel() can only handle /atom types.")
WARNING("qdel() passed object of type [A.type]. qdel() can only handle /atom/movable derived types.")
del A
garbage.dels++
garbage.hard_dels++
garbage.dels_count++
return
// Let our friend know they're about to get fucked up.

View File

@@ -27,9 +27,6 @@
//Detective Work, used for the duplicate data points kept in the scanners
var/list/original_atom
// Garbage collection
var/gc_destroyed=null
/atom/proc/throw_impact(atom/hit_atom, var/speed)
if(istype(hit_atom,/mob/living))
var/mob/living/M = hit_atom
@@ -68,10 +65,6 @@
warning("Type [type] does not inherit /atom/New(). Please ensure ..() is called, or that the type at least adds to type_instances\[type\].")
/atom/Del()
// Pass to Destroy().
if(!gc_destroyed)
Destroy()
// Only call when we're actually deleted.
DeleteFromProfiler()
@@ -80,13 +73,6 @@
/atom/New()
AddToProfiler()
// Like Del(), but for qdel.
// Called BEFORE qdel moves shit.
/atom/proc/Destroy()
gc_destroyed = world.timeofday
invisibility = 101
/atom/proc/assume_air(datum/gas_mixture/giver)
return null

View File

@@ -18,6 +18,9 @@
var/area/areaMaster
// Garbage collection (qdel).
var/gc_destroyed
/atom/movable/Move()
var/atom/A = src.loc
. = ..()
@@ -186,9 +189,24 @@
return src.master.attack_hand(a, b, c)
return
/atom/movable/Del()
// Pass to Destroy().
if (isnull(gc_destroyed))
Destroy()
..()
/*
* Like Del(), but for qdel.
* Called BEFORE qdel moves shit.
*/
/atom/movable/proc/Destroy()
gc_destroyed = world.timeofday
areaMaster = null
loc = null
/////////////////////////////
// SINGULOTH PULL REFACTOR
/////////////////////////////
/atom/movable/proc/canSingulothPull(var/obj/machinery/singularity/singulo)
return 1

View File

@@ -26,7 +26,6 @@
del(overmind)
processing_objects.Remove(src)
..()
return
fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
return

View File

@@ -18,7 +18,6 @@
blob_nodes -= src
processing_objects.Remove(src)
..()
return
Life()
for(var/i = 1; i < 8; i += i)

View File

@@ -26,8 +26,6 @@
/obj/effect/blob/Destroy()
blobs -= src
..()
return
/obj/effect/blob/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group || (height==0)) return 1

View File

@@ -49,7 +49,6 @@ ________________________________________________________________________________
del(hologram.i_attached)//Delete it and the attached image.
del(hologram)
..()
return
//Simply deletes all the attachments and self, killing all related procs.
/obj/item/clothing/suit/space/space_ninja/proc/terminate()

View File

@@ -23,3 +23,5 @@ obj/structure/meteorhit(obj/O as obj)
/obj/structure/Destroy()
if(hascall(src, "unbuckle"))
src:unbuckle()
..()

View File

@@ -100,7 +100,7 @@
..()*/
/turf/simulated/wall/Destroy()
/turf/simulated/wall/Del()
var/temploc = src.loc

View File

@@ -421,7 +421,7 @@
ReplaceWithLattice()
return 0
/turf/simulated/wall/Destroy()
/turf/simulated/wall/Del()
for(var/obj/effect/E in src) if(E.name == "Wallrot") del E
..()

View File

@@ -68,6 +68,8 @@
A.a_right = null
src.holder = null
..()
pulsed(var/radio = 0)
if(holder && (wires & WIRE_RECEIVE))
activate()

View File

@@ -26,9 +26,6 @@ var/list/artifact_spawn = list() // Runtime fix for geometry loading before cont
var/datum/artifact_find/artifact_find
var/scan_state = null //Holder for the image we display when we're pinged by a mining scanner
/turf/unsimulated/mineral/Destroy()
return
/turf/unsimulated/mineral/New()
. = ..()
MineralSpread()
@@ -669,9 +666,6 @@ var/list/artifact_spawn = list() // Runtime fix for geometry loading before cont
"Phazon" = 10
)
/turf/unsimulated/mineral/random/Destroy()
return
/turf/unsimulated/mineral/uranium
name = "Uranium deposit"
icon_state = "rock_Uranium"

View File

@@ -11,7 +11,7 @@
if(ticker)
cameranet.updateVisibility(src)
/turf/simulated/Destroy()
/turf/simulated/Del()
visibilityChanged()
..()