Skip to content

Commit

Permalink
remove_from_queue() and qdel signals
Browse files Browse the repository at this point in the history
  • Loading branch information
xDanilcusx committed Jan 25, 2024
1 parent 4624562 commit 02738c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides)
game_master.images -= behavior_image

QDEL_NULL(behavior_image)

for(var/assigned_xeno in currently_assigned)
UnregisterSignal(assigned_xeno, COMSIG_PARENT_QDELETING)
currently_assigned = null

. = ..()
Expand All @@ -54,6 +57,14 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides)
/datum/component/ai_behavior_override/proc/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time)
SHOULD_NOT_SLEEP(TRUE)

RegisterSignal(processing_xeno, COMSIG_PARENT_QDELETING, PROC_REF(remove_from_queue), TRUE)
currently_assigned |= processing_xeno

return TRUE

/datum/component/ai_behavior_override/proc/remove_from_queue(mob/removed_xeno)
SIGNAL_HANDLER
if(currently_assigned)
currently_assigned -= removed_xeno

UnregisterSignal(removed_xeno, COMSIG_PARENT_QDELETING)
4 changes: 0 additions & 4 deletions code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,6 @@
if(hardcore)
attack_log?.Cut() // Completely clear out attack_log to limit mem usage if we fail to delete

for(var/datum/component/ai_behavior_override/override in GLOB.all_ai_behavior_overrides)
if(override.currently_assigned)
override.currently_assigned -= src

. = ..()

// Everything below fits the "we have to clear by principle it but i dont wanna break stuff" bill
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@
var/validity = cycled_override.check_behavior_validity(src, distance)

if(!validity || distance >= shortest_distance)
if(cycled_override.currently_assigned)
cycled_override.currently_assigned -= src
cycled_override.remove_from_queue(src)
continue

shortest_distance = distance
Expand Down

0 comments on commit 02738c2

Please sign in to comment.