Destroy() cleanups in VOREStation code

* Remove remaining hard del()'s in our code.
* Replace deleted() and gcDestroyed with QDELETED macro.
* Fix some strange calls directly to Del() (capital D)
* Make Destroy() return qdel hints.
* Make a few of the Destroy()'s more comprehensive in cleaning up references.
* In edited Destroy() procs, converted to use qdel_null and qdel_null_list macros when possible for pretty code.
* Removed unused variable `sleevecard`
This commit is contained in:
Leshana
2017-06-10 20:52:01 -04:00
parent cd88f7ca7b
commit e644dbe18a
35 changed files with 83 additions and 84 deletions

View File

@@ -46,7 +46,7 @@
overlays += I
/obj/machinery/atmospherics/binary/algae_farm/Destroy()
..()
. = ..()
internal = null
/obj/machinery/atmospherics/binary/algae_farm/process()

View File

@@ -6,7 +6,7 @@
item_state = "table_parts"
w_class = ITEMSIZE_HUGE
attack_self(mob/user as mob)
/obj/item/stolenpackage/attack_self(mob/user as mob)
// Another way of doing this. Commented out because the other method is better for this application.
/*var/spawn_chance = rand(1,100)
switch(spawn_chance)
@@ -79,8 +79,8 @@
/obj/random/contraband,
/obj/random/weapon/guarenteed)
new loot(usr.loc)
usr << "You unwrap the package."
del(src)
to_chat(user, "You unwrap the package.")
qdel(src)
/obj/item/weapon/storage/fancy/cigar/havana // Putting this here 'cuz fuck it. -Spades
name = "\improper Havana cigar case"

View File

@@ -16,7 +16,7 @@
/obj/structure/closet/secure_closet/egg/attackby(obj/item/weapon/W, mob/user as mob) //This also prevents crew from welding the eggs and making them unable to be opened.
if(istype(W, /obj/item/weapon/weldingtool))
src.dump_contents()
del(src)
qdel(src)

View File

@@ -29,9 +29,10 @@
update_icon(0)
/obj/structure/railing/Destroy()
for(var/obj/structure/railing/R in oview(src, 1))
var/turf/location = loc
. = ..()
for(var/obj/structure/railing/R in orange(location, 1))
R.update_icon()
..()
/obj/structure/railing/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(!mover)

View File

@@ -237,7 +237,7 @@
if(!path) //Tapped out, reallocate?
for(var/P in allocated_gamma)
var/obj/item/I = allocated_gamma[P]
if(!I || istype(I.loc,/obj/machinery/computer/cryopod) || I.gcDestroyed)
if(QDELETED(I) || istype(I.loc,/obj/machinery/computer/cryopod))
allocated_gamma -= P
path = P
break

View File

@@ -16,7 +16,7 @@ var/list/floor_decals = list()
// VOREStation Edit - Hack to workaround byond crash bug
/obj/effect/floor_decal/initialize()
if(!floor_decals_initialized || !loc || deleted(src))
if(!floor_decals_initialized || !loc || QDELETED(src))
return
add_to_turf_decals()
var/turf/T = get_turf(src)

View File

@@ -24,7 +24,7 @@
/datum/category_item/player_setup_item/vore/resleeve/copy_to_mob(var/mob/living/carbon/human/character)
if(character && !istype(character,/mob/living/carbon/human/dummy))
spawn(50)
if(deleted(character) || deleted(pref))
if(QDELETED(character) || QDELETED(pref))
return // They might have been deleted during the wait
if(pref.resleeve_scan)
var/datum/transhuman/body_record/BR = new() //Clearly related to size.

View File

@@ -17,13 +17,9 @@
arscreen = new arscreen_path(src)
/obj/item/clothing/glasses/omnihud/Destroy()
if(hud)
qdel(hud)
hud = null
if(arscreen)
qdel(arscreen)
arscreen = null
..()
qdel_null(hud)
qdel_null(arscreen)
. = ..()
/obj/item/clothing/glasses/omnihud/dropped()
if(arscreen)

View File

@@ -59,7 +59,7 @@
set_new_volume(usr)
/client/proc/set_new_volume(var/mob/user)
if(deleted(src.media) || !istype(src.media))
if(!QDELETED(src.media) || !istype(src.media))
to_chat(user, "<span class='warning'>You have no media datum to change, if you're not in the lobby tell an admin.</span>")
return
var/value = input("Choose your Jukebox volume.", "Jukebox volume", media.volume)

View File

@@ -20,7 +20,7 @@
if(stat!=DEAD) //If not dead.
death(1) //Brains can die again. AND THEY SHOULD AHA HA HA HA HA HA
ghostize() //Ghostize checks for key so nothing else is necessary.
..()
return ..()
say_understands(var/other)//Goddamn is this hackish, but this say code is so odd
if (istype(other, /mob/living/silicon/ai))

View File

@@ -304,7 +304,7 @@ proc/get_radio_key_from_channel(var/channel)
// VOREStation Edit - Attempt Multi-Z Talking
var/mob/above = src.shadow
while(!deleted(above))
while(!QDELETED(above))
var/turf/ST = get_turf(above)
if(ST)
var/list/results = get_mobs_and_objs_in_view_fast(ST, world.view)

View File

@@ -225,7 +225,7 @@
user.visible_message("[user] begins to lick off \the [target.name].", "<span class='notice'>You begin to lick off \the [target.name]...</span>")
if(do_after (user, 50))
user << "<span class='notice'>You finish licking off \the [target.name].</span>"
del(target)
qdel(target)
var/mob/living/silicon/robot.R = user
R.cell.charge = R.cell.charge + 50
else if(istype(target,/obj/item))
@@ -234,7 +234,7 @@
if(do_after (user, 50))
user.visible_message("[user] finishes eating \the [target.name].", "<span class='notice'>You finish eating \the [target.name].</span>")
user << "<span class='notice'>You finish off \the [target.name].</span>"
del(target)
qdel(target)
var/mob/living/silicon/robot.R = user
R.cell.charge = R.cell.charge + 250
return
@@ -246,13 +246,13 @@
var/mob/living/silicon/robot.R = user
var/obj/item/weapon/cell.C = target
R.cell.charge = R.cell.charge + (C.maxcharge / 3)
del(target)
qdel(target)
return
user.visible_message("[user] begins to lick \the [target.name] clean...", "<span class='notice'>You begin to lick \the [target.name] clean...</span>")
if(do_after (user, 50))
user << "<span class='notice'>You clean \the [target.name].</span>"
var/obj/effect/decal/cleanable/C = locate() in target
del(C)
qdel(C)
target.clean_blood()
else if(ishuman(target))
if(src.emagged)
@@ -282,7 +282,7 @@
if(do_after (user, 50))
user << "<span class='notice'>You clean \the [target.name].</span>"
var/obj/effect/decal/cleanable/C = locate() in target
del(C)
qdel(C)
target.clean_blood()
return

View File

@@ -383,9 +383,9 @@
if (istype(T, /obj/item/device/pda))
var/obj/item/device/pda/PDA = T
if (PDA.id)
PDA.id.loc = src
PDA.id.forceMove(src)
PDA.id = null
T.Del()
qdel(T)
//Special case for IDs to make them digested
//else if (istype(T, /obj/item/weapon/card/id))

View File

@@ -35,7 +35,8 @@
for(var/I in vore_organs)
var/datum/belly/B = vore_organs[I]
B.release_all_contents() // When your stomach is empty
..()
prey_excludes.Cut()
. = ..()
//For all those ID-having mobs
/mob/living/simple_animal/GetIdCard()

View File

@@ -53,7 +53,7 @@
"You start to weld \the [src] to the floor.", \
"You hear welding")
if(do_after(user, 2 SECONDS))
if(deleted(src) || !WT.isOn()) return
if(QDELETED(src) || !WT.isOn()) return
state = CONSTRUCTION_WELDED
to_chat(user, "You weld \the [src] to the floor.")
try_construct(user)
@@ -66,7 +66,7 @@
"You start to cut \the [src] free from the floor.", \
"You hear welding")
if(do_after(user, 2 SECONDS))
if(deleted(src) || !WT.isOn()) return
if(QDELETED(src) || !WT.isOn()) return
state = CONSTRUCTION_WRENCHED
to_chat(user, "You cut \the [src] free from the floor.")
else

View File

@@ -36,7 +36,7 @@
for(last_object in turfs_to_process_old)
var/turf/T = last_object
if(T && !T.gcDestroyed)
if(!QDELETED(T))
update_turf(T)
SCHECK

View File

@@ -91,7 +91,7 @@ obj/machinery/atmospherics/pipe/zpipe/Destroy()
node1.disconnect(src)
if(node2)
node2.disconnect(src)
..()
. = ..()
obj/machinery/atmospherics/pipe/zpipe/pipeline_expansion()
return list(node1, node2)

View File

@@ -100,16 +100,11 @@ You can also set the stat of a NIF to NIF_TEMPFAIL without any issues to disable
if(human)
human.nif = null
human = null
for(var/S in nifsofts)
if(S)
qdel(S)
if(nif_hud)
qdel(nif_hud)
if(comm)
qdel(comm)
nifsofts.Cut()
..()
qdel_null_list(nifsofts)
qdel_null(nif_hud)
qdel_null(comm)
nifsofts_life.Cut()
return ..()
//Being implanted in some mob
/obj/item/device/nif/proc/implant(var/mob/living/carbon/human/H)
@@ -541,7 +536,7 @@ You can also set the stat of a NIF to NIF_TEMPFAIL without any issues to disable
if(nif)
nif.nif_hud = null
nif = null
..()
return ..()
/obj/item/clothing/glasses/hud/nif_hud/process_hud(M,var/thing)
//Faster checking with local var, and this is called often so I want fast.

View File

@@ -47,7 +47,7 @@
/obj/effect/nif_stat/Destroy()
nifsoft = null
..()
return ..()
/obj/effect/nif_stat/proc/atom_button_text()
name = nifsoft.stat_text()

View File

@@ -50,11 +50,10 @@
//Destructor cleans up the software and nif reference
/datum/nifsoft/Destroy()
if(nif)
uninstall(nif)
uninstall()
nif = null
qdel(stat_line)
stat_line = null
..()
qdel_null(stat_line)
return ..()
//Called when the software is installed in the NIF
/datum/nifsoft/proc/install()
@@ -67,7 +66,8 @@
if(nif)
. = nif.uninstall(src)
nif = null
qdel(src)
if(!QDESTROYING(src))
qdel(src)
//Called every life() tick on a mob on active implants
/datum/nifsoft/proc/life(var/mob/living/carbon/human/human)
@@ -126,7 +126,7 @@
/datum/nifsoft/package/Destroy()
software.Cut()
software = null
..()
return ..()
/////////////////
// A NIFSoft Disk

View File

@@ -12,8 +12,8 @@
arscreen = new(nif)
Destroy()
qdel(arscreen)
..()
qdel_null(arscreen)
return ..()
activate()
if((. = ..()))

View File

@@ -25,11 +25,8 @@
load_settings()
Destroy()
for(var/brain in brainmobs)
var/mob/living/carbon/brain/caught_soul/CS = brain
qdel(CS)
brainmobs.Cut()
..()
qdel_null_list(brainmobs)
return ..()
install()
if((. = ..()))
@@ -249,10 +246,8 @@
soulcatcher = null
if(nif)
nif = null
if(mind && ckey)
src.ghostize()
container = null
..()
return ..()
/mob/living/carbon/brain/caught_soul/Life()
if(!mind)

View File

@@ -43,13 +43,14 @@
nif = newloc
nifsoft = soft
register_device(nif.human)
qdel(camera) //Not supported on internal one.
qdel_null(camera) //Not supported on internal one.
Destroy()
if(nif)
nif.comm = null
nif = null
..()
nifsoft = null
return ..()
//So that only the owner's chat is relayed to others.
/obj/item/device/communicator/commlink/hear_talk(mob/living/M, text, verb, datum/language/speaking)

View File

@@ -121,7 +121,7 @@ var/global/ingredientLimit = 20
return new_name
/obj/item/weapon/reagent_containers/food/snacks/customizable/Destroy()
for(. in ingredients) qdel(.)
qdel_null_list(ingredients)
return ..()
/obj/item/weapon/reagent_containers/food/snacks/customizable/proc/drawTopping()

View File

@@ -24,7 +24,7 @@
/obj/machinery/computer/transhuman/resleeving/Destroy()
releasepods()
..()
return ..()
/obj/machinery/computer/transhuman/resleeving/proc/updatemodules()
releasepods()

View File

@@ -27,7 +27,7 @@
preview_icon = null
mannequin = null
disk = null
..()
return ..()
/obj/machinery/computer/transhuman/designer/dismantle()
if(disk)
@@ -241,8 +241,8 @@
return preview_icon
/obj/machinery/computer/transhuman/designer/proc/update_preview_mob(var/mob/living/carbon/human/H)
ASSERT(!deleted(H))
ASSERT(!deleted(active_br))
ASSERT(!QDELETED(H))
ASSERT(!QDELETED(active_br))
//log_debug("designer.update_preview_mob([H]) active_br = \ref[active_br]")
//Get the DNA and generate a new mob
var/datum/dna2/record/R = active_br.mydna

View File

@@ -187,10 +187,10 @@ var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore
mind_ref = null
limb_data.Cut()
organ_data.Cut()
..()
return QDEL_HINT_HARDDEL // For now at least there is no easy way to clear references to this in machines etc.
/datum/transhuman/body_record/proc/init_from_mob(var/mob/living/carbon/human/M, var/add_to_db = 0, var/ckeylock = 0)
ASSERT(!deleted(M))
ASSERT(!QDELETED(M))
ASSERT(istype(M))
//Person OOCly doesn't want people impersonating them
@@ -277,7 +277,7 @@ var/datum/transhuman/infocore/transcore = new/datum/transhuman/infocore
* or anything like that! This is the computer science concept of "cloning" a data structure!
*/
/datum/transhuman/body_record/proc/init_from_br(var/datum/transhuman/body_record/orig)
ASSERT(!deleted(orig))
ASSERT(!QDELETED(orig))
ASSERT(istype(orig))
src.mydna = new ()
src.mydna.dna = orig.mydna.dna.Clone()

View File

@@ -16,7 +16,6 @@
var/obj/item/device/radio/sleevecard/radio
var/mob/living/silicon/infomorph/infomorph
var/datum/mind/sleeved
var/current_emotion = 1
matter = list(DEFAULT_WALL_MATERIAL = 4000, "glass" = 4000)
@@ -36,7 +35,9 @@
/obj/item/device/sleevecard/Destroy()
if(!isnull(infomorph))
infomorph.death(0)
..()
infomorph = null
qdel_null(radio)
return ..()
/obj/item/device/sleevecard/attack_self(mob/user)
add_fingerprint(user)

View File

@@ -19,9 +19,9 @@ var/global/list/GPS_list = list()
name = "global positioning system ([gpstag])"
overlays += "working"
/obj/item/device/gps/advanced/Del()
/obj/item/device/gps/advanced/Destroy()
GPS_list.Remove(src)
..()
. = ..()
/obj/item/device/gps/advanced/emp_act(severity)
emped = 1

View File

@@ -39,7 +39,7 @@
/obj/effect/overlay/aiholo/Destroy()
drop_prey()
..()
return ..()
/mob/living/silicon/ai/verb/holo_nom()
set name = "Hardlight Nom"

View File

@@ -31,6 +31,11 @@
var/datum/browser/popup
var/loop = null; // Magic self-reference to stop the handler from being GC'd before user takes action.
/datum/vore_look/Destroy()
loop = null
selected = null
return QDEL_HINT_HARDDEL // TODO - Until I can better analyze how this weird thing works, lets be safe
/datum/vore_look/Topic(href,href_list[])
if (vp_interact(href, href_list))
popup.set_content(gen_ui(usr))
@@ -243,7 +248,7 @@
for(var/H in href_list)
if(href_list["close"])
del(src) // Cleanup
qdel(src) // Cleanup
return
if(href_list["show_int"])

View File

@@ -321,7 +321,7 @@ obj/item/weapon/material/hatchet/tacknife/combatknife/fluff/katarina/handle_shie
O.icon_state = new_icon // Changes the icon without changing the access.
playsound(user.loc, 'sound/items/polaroid2.ogg', 100, 1)
user.visible_message("<span class='warning'> [user] reprints their ID.</span>")
del(src)
qdel(src)
else if(O.icon_state == new_icon)
user << "<span class='notice'>[O] already has been reprinted.</span>"
return
@@ -490,7 +490,7 @@ obj/item/weapon/material/hatchet/tacknife/combatknife/fluff/katarina/handle_shie
Destroy() //Waitwaitwait
if(state == 1)
process() //Nownownow
..() //Okfine
return ..() //Okfine
process()
check_owner()
@@ -914,9 +914,13 @@ obj/item/weapon/material/hatchet/tacknife/combatknife/fluff/katarina/handle_shie
spk.attach(src)
/obj/item/device/perfect_tele/Destroy()
// Must clear the beacon's backpointer or we won't GC. Someday maybe do something nicer even.
for(var/obj/item/device/perfect_tele_beacon/B in beacons)
B.tele_hand = null
beacons.Cut()
qdel(spk)
..()
qdel_null(power_source)
qdel_null(spk)
return ..()
/obj/item/device/perfect_tele/update_icon()
if(!power_source)
@@ -1169,7 +1173,7 @@ obj/item/weapon/material/hatchet/tacknife/combatknife/fluff/katarina/handle_shie
/obj/item/device/perfect_tele_beacon/Destroy()
tele_name = null
tele_hand = null
..()
return ..()
/obj/item/device/perfect_tele_beacon/attack_hand(mob/user)
if((user.ckey != creator) && !(user.ckey in warned_users))

View File

@@ -34,4 +34,4 @@
var/turf/here = get_turf(src)
for(var/atom/movable/A in src)
A.forceMove(here)
..()
return ..()

View File

@@ -90,7 +90,7 @@
/obj/machinery/door/airlock/vault/temple/New()
if(prob(33))
new /obj/structure/falsewall/cultspecial(src.loc)
del(src)
qdel(src)
if(prob(33))
safe = 0
if(prob(33))

View File

@@ -127,7 +127,7 @@
/obj/machinery/smartfridge/chemistry/chemvator/down/Destroy()
attached = null
..()
return ..()
/obj/machinery/smartfridge/chemistry/chemvator/down
name = "\improper Smart Chemavator - Lower"