mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
* Attempting to fix search_object hard dels (#85394) ## About The Pull Request  These were coming up often, had a hunch that the callback may have been hanging their refs. It seems to be true from my testing, they should be passing GLOBAL_PROC as the `object` arg, not `src`, since qdel is not a `search_object` proc. (Thanks Melbert for noticing that detail!) Also just tidies up the code a bit, adding checks to prevent redundant qdel calls and preventing a potential race condition with qdeleted atoms. ## Why It's Good For The Game Hard dels here in particular have potential to cause significant lag and issues. ## Changelog Not player-facing really * Attempting to fix search_object hard dels --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
/// Adds the item to contents and to_image (if needed)
|
|
/datum/lootpanel/proc/add_to_index(datum/search_object/index)
|
|
RegisterSignal(index, COMSIG_QDELETING, PROC_REF(on_searchable_deleted))
|
|
if(isnull(index.icon))
|
|
to_image += index
|
|
|
|
contents += index
|
|
|
|
|
|
/// Used to populate contents and start generating if needed
|
|
/datum/lootpanel/proc/populate_contents()
|
|
if(length(contents))
|
|
reset_contents()
|
|
|
|
// Add source turf first
|
|
var/datum/search_object/source = new(owner, source_turf)
|
|
add_to_index(source)
|
|
|
|
for(var/atom/thing as anything in source_turf.contents)
|
|
// validate
|
|
if(!istype(thing))
|
|
stack_trace("Non-atom in the contents of [source_turf]!")
|
|
continue
|
|
if(QDELETED(thing))
|
|
continue
|
|
if(thing.mouse_opacity == MOUSE_OPACITY_TRANSPARENT)
|
|
continue
|
|
if(thing.IsObscured())
|
|
continue
|
|
if(thing.invisibility > owner.mob.see_invisible)
|
|
continue
|
|
|
|
// convert
|
|
var/datum/search_object/index = new(owner, thing)
|
|
add_to_index(index)
|
|
|
|
var/datum/tgui/window = SStgui.get_open_ui(owner.mob, src)
|
|
window?.send_update()
|
|
|
|
if(length(to_image))
|
|
SSlooting.backlog += src
|
|
|
|
|
|
/// For: Resetting to empty. Ignores the searchable qdel event
|
|
/datum/lootpanel/proc/reset_contents()
|
|
for(var/datum/search_object/index as anything in contents)
|
|
contents -= index
|
|
to_image -= index
|
|
|
|
if(QDELETED(index))
|
|
continue
|
|
|
|
UnregisterSignal(index, COMSIG_QDELETING)
|
|
qdel(index)
|