From e40fa55b3bc9fb85d38a4e9b5993210d7f9553e9 Mon Sep 17 00:00:00 2001 From: ESwordTheCat Date: Sat, 14 Jun 2014 15:26:29 -0800 Subject: [PATCH] Fix destroys() not calling parent, tweak qdel to use one loop only. --- .../binary_devices/binary_atmos_base.dm | 2 - .../components/portables_connector.dm | 2 - .../trinary_devices/trinary_base.dm | 2 - code/ATMOSPHERICS/components/tvalve.dm | 2 - .../components/unary/unary_base.dm | 2 - code/ATMOSPHERICS/components/valve.dm | 2 - code/controllers/_DynamicAreaLighting_TG.dm | 2 - code/controllers/garbage.dm | 119 +++++------------- code/game/atoms.dm | 14 --- code/game/atoms_movable.dm | 20 ++- code/game/gamemodes/blob/blobs/core.dm | 1 - code/game/gamemodes/blob/blobs/node.dm | 1 - code/game/gamemodes/blob/theblob.dm | 2 - code/game/gamemodes/events/ninja_equipment.dm | 1 - code/game/objects/structures.dm | 4 +- code/game/smoothwall.dm | 2 +- code/game/turfs/simulated/walls.dm | 2 +- code/modules/assembly/assembly.dm | 2 + code/modules/mining/mine_turfs.dm | 6 - .../silicon/ai/freelook/update_triggers.dm | 2 +- 20 files changed, 56 insertions(+), 134 deletions(-) diff --git a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm index 0225bafb171..c24b92b5d3a 100644 --- a/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm +++ b/code/ATMOSPHERICS/components/binary_devices/binary_atmos_base.dm @@ -62,8 +62,6 @@ obj/machinery/atmospherics/binary return null Destroy() - loc = null - if(node1) node1.disconnect(src) del(network1) diff --git a/code/ATMOSPHERICS/components/portables_connector.dm b/code/ATMOSPHERICS/components/portables_connector.dm index 771c010c3da..9023c0b9645 100644 --- a/code/ATMOSPHERICS/components/portables_connector.dm +++ b/code/ATMOSPHERICS/components/portables_connector.dm @@ -77,8 +77,6 @@ return null Destroy() - loc = null - if(connected_device) connected_device.disconnect() diff --git a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm index 243fd257dcc..a4c5fb35680 100644 --- a/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm +++ b/code/ATMOSPHERICS/components/trinary_devices/trinary_base.dm @@ -73,8 +73,6 @@ obj/machinery/atmospherics/trinary return null Destroy() - loc = null - if(node1) node1.disconnect(src) del(network1) diff --git a/code/ATMOSPHERICS/components/tvalve.dm b/code/ATMOSPHERICS/components/tvalve.dm index 8934ec5995c..8e2a9973d16 100644 --- a/code/ATMOSPHERICS/components/tvalve.dm +++ b/code/ATMOSPHERICS/components/tvalve.dm @@ -99,8 +99,6 @@ obj/machinery/atmospherics/tvalve return null Destroy() - loc = null - if(node1) node1.disconnect(src) del(network_node1) diff --git a/code/ATMOSPHERICS/components/unary/unary_base.dm b/code/ATMOSPHERICS/components/unary/unary_base.dm index b0896793b6e..0f0aaa6af09 100644 --- a/code/ATMOSPHERICS/components/unary/unary_base.dm +++ b/code/ATMOSPHERICS/components/unary/unary_base.dm @@ -43,8 +43,6 @@ return null Destroy() - loc = null - if(node) node.disconnect(src) del(network) diff --git a/code/ATMOSPHERICS/components/valve.dm b/code/ATMOSPHERICS/components/valve.dm index f1c40dec981..1af64d638e9 100644 --- a/code/ATMOSPHERICS/components/valve.dm +++ b/code/ATMOSPHERICS/components/valve.dm @@ -78,8 +78,6 @@ obj/machinery/atmospherics/valve return null Destroy() - loc = null - if(node1) node1.disconnect(src) del(network_node1) diff --git a/code/controllers/_DynamicAreaLighting_TG.dm b/code/controllers/_DynamicAreaLighting_TG.dm index ec704d5710c..16fa1886a98 100644 --- a/code/controllers/_DynamicAreaLighting_TG.dm +++ b/code/controllers/_DynamicAreaLighting_TG.dm @@ -153,8 +153,6 @@ atom/movable/Destroy() if(loc:lighting_lumcount > 1) UpdateAffectingLights() - areaMaster = null - loc = null ..() //Sets our luminosity. diff --git a/code/controllers/garbage.dm b/code/controllers/garbage.dm index 713f1dac6ad..3c7c2664aac 100644 --- a/code/controllers/garbage.dm +++ b/code/controllers/garbage.dm @@ -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. diff --git a/code/game/atoms.dm b/code/game/atoms.dm index bb8e0caf0e8..178bb5af28c 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -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 diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 3b364afbfe3..f3c990494a9 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -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 - diff --git a/code/game/gamemodes/blob/blobs/core.dm b/code/game/gamemodes/blob/blobs/core.dm index 3859a247dbe..636d33a178d 100644 --- a/code/game/gamemodes/blob/blobs/core.dm +++ b/code/game/gamemodes/blob/blobs/core.dm @@ -26,7 +26,6 @@ del(overmind) processing_objects.Remove(src) ..() - return fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) return diff --git a/code/game/gamemodes/blob/blobs/node.dm b/code/game/gamemodes/blob/blobs/node.dm index 94d2fb4a5d0..e3a56a9043d 100644 --- a/code/game/gamemodes/blob/blobs/node.dm +++ b/code/game/gamemodes/blob/blobs/node.dm @@ -18,7 +18,6 @@ blob_nodes -= src processing_objects.Remove(src) ..() - return Life() for(var/i = 1; i < 8; i += i) diff --git a/code/game/gamemodes/blob/theblob.dm b/code/game/gamemodes/blob/theblob.dm index 073aad38817..a06e9ffbfe1 100644 --- a/code/game/gamemodes/blob/theblob.dm +++ b/code/game/gamemodes/blob/theblob.dm @@ -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 diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index bb0feabe2a2..058dc7290aa 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -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() diff --git a/code/game/objects/structures.dm b/code/game/objects/structures.dm index 4dba4393f5f..dbde40c07fd 100644 --- a/code/game/objects/structures.dm +++ b/code/game/objects/structures.dm @@ -22,4 +22,6 @@ obj/structure/meteorhit(obj/O as obj) /obj/structure/Destroy() if(hascall(src, "unbuckle")) - src:unbuckle() \ No newline at end of file + src:unbuckle() + + ..() \ No newline at end of file diff --git a/code/game/smoothwall.dm b/code/game/smoothwall.dm index a6a42109559..11382d67ff6 100644 --- a/code/game/smoothwall.dm +++ b/code/game/smoothwall.dm @@ -100,7 +100,7 @@ ..()*/ -/turf/simulated/wall/Destroy() +/turf/simulated/wall/Del() var/temploc = src.loc diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 3b99bc41d95..37e264c0575 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -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 ..() diff --git a/code/modules/assembly/assembly.dm b/code/modules/assembly/assembly.dm index b4a57ee6702..6102e2b29fc 100644 --- a/code/modules/assembly/assembly.dm +++ b/code/modules/assembly/assembly.dm @@ -68,6 +68,8 @@ A.a_right = null src.holder = null + ..() + pulsed(var/radio = 0) if(holder && (wires & WIRE_RECEIVE)) activate() diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm index bef82e604e9..5e8a1f1c1e5 100644 --- a/code/modules/mining/mine_turfs.dm +++ b/code/modules/mining/mine_turfs.dm @@ -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" diff --git a/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm b/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm index 2b4b52e5ba7..6392b67c570 100644 --- a/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm +++ b/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm @@ -11,7 +11,7 @@ if(ticker) cameranet.updateVisibility(src) -/turf/simulated/Destroy() +/turf/simulated/Del() visibilityChanged() ..()