Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/cooldowns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

#define COOLDOWN_DECLARE(cd_index) var/##cd_index = 0

#define COOLDOWN_START(cd_source, cd_index, cd_time) (cd_source.cd_index = world.time + cd_time)
#define COOLDOWN_START(cd_source, cd_index, cd_time) (cd_source.cd_index = world.time + (cd_time))

//Returns true if the cooldown has run its course, false otherwise
#define COOLDOWN_FINISHED(cd_source, cd_index) (cd_source.cd_index < world.time)
Expand Down
6 changes: 6 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,9 @@
#define FLAVOR_TEXT_GOOD "good" //ie do not cause evil
#define FLAVOR_TEXT_NONE "none"
#define FLAVOR_TEXT_GOAL_ANTAG "blob" //is antag, but should work towards its goals
<<<<<<< HEAD
=======

//Saves a proc call, life is suffering. If who has no targets_from var, we assume it's just who
#define GET_TARGETS_FROM(who) (who.targets_from ? who.get_targets_from() : who)
>>>>>>> e260143132 (Port harddel fixes, as well as "Fixes stasis bed runtimes" (#4598))
3 changes: 3 additions & 0 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
///Call qdel on the atom after intialization
#define INITIALIZE_HINT_QDEL 2

///Call qdel with a force of TRUE after initialization
#define INITIALIZE_HINT_QDEL_FORCE 3

///type and all subtypes should always immediately call Initialize in New()
#define INITIALIZE_IMMEDIATE(X) ##X/New(loc, ...){\
..();\
Expand Down
5 changes: 5 additions & 0 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
SEND_TEXT(world.log, text)
#endif

#ifdef REFERENCE_TRACKING_LOG
#define log_reftracker(msg) log_world("## REF SEARCH [msg]")
#else
#define log_reftracker(msg)
#endif

/* Items with ADMINPRIVATE prefixed are stripped from public logs. */
/proc/log_admin(text)
Expand Down
3 changes: 3 additions & 0 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
//#define LEGACY_REFERENCE_TRACKING
#ifdef LEGACY_REFERENCE_TRACKING

///Should we be logging our findings or not
#define REFERENCE_TRACKING_LOG

///Use the legacy reference on things hard deleting by default.
//#define GC_FAILURE_HARD_LOOKUP
#ifdef GC_FAILURE_HARD_LOOKUP
Expand Down
15 changes: 13 additions & 2 deletions code/_onclick/hud/radial.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ GLOBAL_LIST_EMPTY(radial_menus)
plane = ABOVE_HUD_PLANE
var/datum/radial_menu/parent

/atom/movable/screen/radial/proc/set_parent(new_value)
if(parent)
UnregisterSignal(parent, COMSIG_PARENT_QDELETING)
parent = new_value
if(parent)
RegisterSignal(parent, COMSIG_PARENT_QDELETING, .proc/handle_parent_del)

/atom/movable/screen/radial/proc/handle_parent_del()
SIGNAL_HANDLER
set_parent(null)

/atom/movable/screen/radial/slice
icon_state = "radial_slice"
var/choice
Expand Down Expand Up @@ -132,7 +143,7 @@ GLOBAL_LIST_EMPTY(radial_menus)
for(var/i in 1 to elements_to_add) //Create all elements
var/atom/movable/screen/radial/slice/new_element = new /atom/movable/screen/radial/slice
new_element.tooltips = use_tooltips
new_element.parent = src
new_element.set_parent(src)
elements += new_element

var/page = 1
Expand Down Expand Up @@ -222,7 +233,7 @@ GLOBAL_LIST_EMPTY(radial_menus)

/datum/radial_menu/New()
close_button = new
close_button.parent = src
close_button.set_parent(src)

/datum/radial_menu/proc/Reset()
choices.Cut()
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/radial_persistent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/datum/radial_menu/persistent/New()
close_button = new /atom/movable/screen/radial/persistent/center
close_button.parent = src
close_button.set_parent(src)


/datum/radial_menu/persistent/element_chosen(choice_id,mob/user)
Expand Down
3 changes: 3 additions & 0 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ SUBSYSTEM_DEF(atoms)
if(INITIALIZE_HINT_QDEL)
qdel(A)
qdeleted = TRUE
if(INITIALIZE_HINT_QDEL_FORCE)
qdel(A, force = TRUE)
qdeleted = TRUE
else
BadInitializeCalls[the_type] |= BAD_INIT_NO_HINT

Expand Down
20 changes: 16 additions & 4 deletions code/controllers/subsystem/garbage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,36 @@ SUBSYSTEM_DEF(garbage)

// Something's still referring to the qdel'd object.
fail_counts[level]++

#ifdef REFERENCE_TRACKING
var/ref_searching = FALSE
#endif

switch (level)
if (GC_QUEUE_CHECK)
#ifdef REFERENCE_TRACKING
D.find_references()
#elif defined(LEGACY_REFERENCE_TRACKING)
if(reference_find_on_fail[refID])
D.find_references_legacy()
INVOKE_ASYNC(D, /datum/proc/find_references_legacy)
ref_searching = TRUE
#ifdef GC_FAILURE_HARD_LOOKUP
else
D.find_references_legacy()
INVOKE_ASYNC(D, /datum/proc/find_references_legacy)
ref_searching = TRUE
#endif
reference_find_on_fail -= refID
#endif
var/type = D.type
var/datum/qdel_item/I = items[type]
#ifdef TESTING

log_world("## TESTING: GC: -- \ref[D] | [type] was unable to be GC'd --")
#ifdef TESTING
for(var/c in GLOB.admins) //Using testing() here would fill the logs with ADMIN_VV garbage
var/client/admin = c
if(!check_rights_for(admin, R_ADMIN))
continue
to_chat(admin, "## TESTING: GC: -- [ADMIN_VV(D)] | [type] was unable to be GC'd --")
testing("GC: -- \ref[src] | [type] was unable to be GC'd --")
#endif
#ifdef REFERENCE_TRACKING
GLOB.deletion_failures += D //It should no longer be bothered by the GC, manual deletion only.
Expand All @@ -185,6 +192,11 @@ SUBSYSTEM_DEF(garbage)

Queue(D, level+1)

#ifdef REFERENCE_TRACKING
if(ref_searching)
return
#endif

if (MC_TICK_CHECK)
return
if (count)
Expand Down
18 changes: 14 additions & 4 deletions code/datums/browser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var/window_id // window_id is used as the window name for browse and onclose
var/width = 0
var/height = 0
var/atom/ref = null
var/datum/weakref/ref = null
var/window_options = "can_close=1;can_minimize=1;can_maximize=0;can_resize=1;titlebar=1;" // window option is set using window_id
var/stylesheets[0]
var/scripts[0]
Expand All @@ -17,6 +17,7 @@
/datum/browser/New(nuser, nwindow_id, ntitle = 0, nwidth = 0, nheight = 0, var/atom/nref = null)

user = nuser
RegisterSignal(user, COMSIG_PARENT_QDELETING, .proc/user_deleted)
window_id = nwindow_id
if (ntitle)
title = format_text(ntitle)
Expand All @@ -25,7 +26,11 @@
if (nheight)
height = nheight
if (nref)
ref = nref
ref = WEAKREF(nref)

/datum/browser/proc/user_deleted(datum/source)
SIGNAL_HANDLER
user = null

/datum/browser/proc/add_head_content(nhead_content)
head_content = nhead_content
Expand Down Expand Up @@ -111,8 +116,13 @@
/datum/browser/proc/setup_onclose()
set waitfor = 0 //winexists sleeps, so we don't need to.
for (var/i in 1 to 10)
if (user && winexists(user, window_id))
onclose(user, window_id, ref)
if (user?.client && winexists(user, window_id))
var/atom/send_ref
if(ref)
send_ref = ref.resolve()
if(!send_ref)
ref = null
onclose(user, window_id, send_ref)
break

/datum/browser/proc/close()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/squeak.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
if(istype(AM, /obj/effect/dummy/phased_mob)) //don't squeek if they're in a phased/jaunting container.
return
var/atom/current_parent = parent
if(isturf(current_parent.loc))
if(isturf(current_parent?.loc))
play_squeak()

/datum/component/squeak/proc/use_squeak()
Expand Down
16 changes: 12 additions & 4 deletions code/datums/components/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,27 @@
M.client.screen |= boxes
M.client.screen |= closer
M.client.screen |= real_location.contents
M.active_storage = src
M.set_active_storage(src)
LAZYOR(is_using, M)
RegisterSignal(M, COMSIG_PARENT_QDELETING, .proc/mob_deleted)
return TRUE

/datum/component/storage/proc/mob_deleted(datum/source)
SIGNAL_HANDLER
hide_from(source)

/datum/component/storage/proc/hide_from(mob/M)
if(M.active_storage == src)
M.set_active_storage(null)
LAZYREMOVE(is_using, M)

UnregisterSignal(M, COMSIG_PARENT_QDELETING)
if(!M.client)
return TRUE
var/atom/real_location = real_location()
M.client.screen -= boxes
M.client.screen -= closer
M.client.screen -= real_location.contents
if(M.active_storage == src)
M.active_storage = null
LAZYREMOVE(is_using, M)
return TRUE

/datum/component/storage/proc/close(mob/M)
Expand Down Expand Up @@ -451,6 +458,7 @@
cansee |= M
else
LAZYREMOVE(is_using, M)
UnregisterSignal(M, COMSIG_PARENT_QDELETING)
return cansee

//Tries to dump content
Expand Down
14 changes: 8 additions & 6 deletions code/datums/dash_weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
var/current_charges = 1
var/max_charges = 1
var/charge_rate = 250
var/mob/living/carbon/human/holder
var/obj/item/dashing_item
var/dash_sound = 'sound/magic/blink.ogg'
var/recharge_sound = 'sound/magic/charge.ogg'
Expand All @@ -17,7 +16,10 @@
/datum/action/innate/dash/Grant(mob/user, obj/dasher)
. = ..()
dashing_item = dasher
holder = user

/datum/action/innate/dash/Destroy()
dashing_item = null
return ..()

/datum/action/innate/dash/IsAvailable()
if(current_charges > 0)
Expand All @@ -26,7 +28,7 @@
return FALSE

/datum/action/innate/dash/Activate()
dashing_item.attack_self(holder) //Used to toggle dash behavior in the dashing item
dashing_item.attack_self(owner) //Used to toggle dash behavior in the dashing item

/datum/action/innate/dash/proc/Teleport(mob/user, atom/target)
if(!IsAvailable())
Expand All @@ -39,14 +41,14 @@
var/obj/spot2 = new phasein(get_turf(user), user.dir)
spot1.Beam(spot2,beam_effect,time=20)
current_charges--
holder.update_action_buttons_icon()
owner.update_action_buttons_icon()
addtimer(CALLBACK(src, .proc/charge), charge_rate)
else
to_chat(user, "<span class='warning'>You cannot dash here!</span>")

/datum/action/innate/dash/proc/charge()
current_charges = CLAMP(current_charges + 1, 0, max_charges)
holder.update_action_buttons_icon()
owner.update_action_buttons_icon()
if(recharge_sound)
playsound(dashing_item, recharge_sound, 50, 1)
to_chat(holder, "<span class='notice'>[src] now has [current_charges]/[max_charges] charges.</span>")
to_chat(owner, "<span class='notice'>[src] now has [current_charges]/[max_charges] charges.</span>")
1 change: 1 addition & 0 deletions code/datums/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ GLOBAL_LIST_INIT(huds, list(
/datum/atom_hud/proc/unregister_mob(datum/source, force)
SIGNAL_HANDLER
remove_hud_from(source, TRUE)
remove_from_hud(source)

/datum/atom_hud/proc/show_hud_images_after_cooldown(M)
if(queued_to_see[M])
Expand Down
20 changes: 17 additions & 3 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,22 @@
qdel(i)
antag_datums = null
QDEL_NULL(language_holder)
set_current(null)
return ..()

/datum/mind/proc/set_current(mob/new_current)
if(new_current && QDELING(new_current))
CRASH("Tried to set a mind's current var to a qdeleted mob, what the fuck")
if(current)
UnregisterSignal(src, COMSIG_PARENT_QDELETING)
current = new_current
if(current)
RegisterSignal(src, COMSIG_PARENT_QDELETING, .proc/clear_current)

/datum/mind/proc/clear_current(datum/source)
SIGNAL_HANDLER
set_current(null)

/datum/mind/proc/get_language_holder()
if(!language_holder)
language_holder = new (src)
Expand All @@ -108,13 +122,13 @@
key = new_character.key

if(new_character.mind) //disassociate any mind currently in our new body's mind variable
new_character.mind.current = null
new_character.mind.set_current(null)

var/datum/atom_hud/antag/hud_to_transfer = antag_hud//we need this because leave_hud() will clear this list
var/mob/living/old_current = current
if(current)
current.transfer_observers_to(new_character) //transfer anyone observing the old character to the new one
current = new_character //associate ourself with our new body
set_current(new_character) //associate ourself with our new body
new_character.mind = src //and associate our new body with ourself
for(var/a in antag_datums) //Makes sure all antag datums effects are applied in the new body
var/datum/antagonist/A = a
Expand Down Expand Up @@ -726,7 +740,7 @@
SSticker.minds += mind
if(!mind.name)
mind.name = real_name
mind.current = src
mind.set_current(src)

/mob/living/carbon/mind_initialize()
..()
Expand Down
5 changes: 3 additions & 2 deletions code/game/gamemodes/clown_ops/clown_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@
if(iscarbon(hit_atom) && !caught)//if they are a carbon and they didn't catch it
var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery)
slipper.Slip(src, hit_atom)
if(thrownby && !caught)
addtimer(CALLBACK(src, /atom/movable.proc/throw_at, thrownby, throw_range+2, throw_speed, null, TRUE), 1)
var/mob/thrown_by = thrownby?.resolve()
if(thrown_by && !caught)
addtimer(CALLBACK(src, /atom/movable.proc/throw_at, thrown_by, throw_range+2, throw_speed, null, TRUE), 1)
else
return ..()

Expand Down
5 changes: 5 additions & 0 deletions code/game/gamemodes/objective.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ GLOBAL_LIST_EMPTY(objectives)
if(text)
explanation_text = text

//Apparently objectives can be qdel'd. Learn a new thing every day
/datum/objective/Destroy()
GLOB.objectives -= src
return ..()

/datum/objective/proc/get_owners() // Combine owner and team into a single list.
. = (team && team.members) ? team.members.Copy() : list()
if(owner)
Expand Down
Loading