[NO GBP] Fixes even more AI related CI runtimes (#80262)

## About The Pull Request

Consider this a continuation of
https://github.com/tgstation/tgstation/pull/80202


![firefox_P62DdMv946](https://github.com/tgstation/tgstation/assets/13398309/1a784a27-e5c9-42d1-b160-7eb9251b3997)

~~It seems I missed a few.~~

Edit: Modified per request to handle this more broadly. If a pawn gets
`qdel`'d, the ai controller should be set to off and get removed from
the list of active controllers, and all their actions should be
canceled.

Also adds some qdeleted checks to `finish_action()`, which can still run
after the pawn gets qdeleted as part of the `CancelActions()` chain.

## Why It's Good For The Game

Less spurious CI failures.

## Changelog

Nothing player facing really.
This commit is contained in:
Bloop
2023-12-17 05:04:28 -05:00
committed by GitHub
parent 095b2e088f
commit 4a989723e1
22 changed files with 58 additions and 45 deletions
@@ -25,6 +25,8 @@
. = ..()
var/obj/structure/flora/target_tree = controller.blackboard[target_key]
var/mob/living/basic/living_pawn = controller.pawn
if(QDELETED(living_pawn)) // pawn can be null at this point
return
SEND_SIGNAL(living_pawn, COMSIG_LIVING_CLIMB_TREE, target_tree)
finish_action(controller, TRUE, target_key)
@@ -4,11 +4,11 @@
. = ..()
var/mob/living/living_pawn = controller.pawn
var/atom/movable/buckled_too = living_pawn.buckled
var/atom/movable/buckled_to = living_pawn.buckled
if(isnull(buckled_too))
if(isnull(buckled_to))
finish_action(controller, FALSE)
return
buckled_too.unbuckle_mob(living_pawn)
buckled_to.unbuckle_mob(living_pawn)
finish_action(controller, TRUE)
@@ -2,7 +2,7 @@
/datum/ai_planning_subtree/opportunistic_ventcrawler
/datum/ai_planning_subtree/opportunistic_ventcrawler/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
if(QDELETED(controller.pawn) || HAS_TRAIT(controller.pawn, TRAIT_MOVE_VENTCRAWLING))
if(HAS_TRAIT(controller.pawn, TRAIT_MOVE_VENTCRAWLING))
return SUBTREE_RETURN_FINISH_PLANNING // hold on let me cook
var/obj/machinery/atmospherics/components/unary/vent_pump/target = controller.blackboard[BB_ENTRY_VENT_TARGET]
@@ -16,7 +16,7 @@
finish_action(controller, FALSE, ability_key, target_key)
return
var/mob/pawn = controller.pawn
if (ability.InterceptClickOn(pawn, null, target))
if(QDELETED(pawn) || ability.InterceptClickOn(pawn, null, target))
finish_action(controller, TRUE, ability_key, target_key)
/datum/ai_behavior/pet_use_ability/finish_action(datum/ai_controller/controller, succeeded, ability_key, target_key)
@@ -18,7 +18,7 @@
/datum/ai_behavior/play_dead/finish_action(datum/ai_controller/controller, succeeded)
. = ..()
var/mob/living/basic/basic_pawn = controller.pawn
if(!istype(basic_pawn) || basic_pawn.stat) // imagine actually dying while playing dead. hell, imagine being the kid waiting for your pup to get back up :(
if(QDELETED(basic_pawn) || basic_pawn.stat) // imagine actually dying while playing dead. hell, imagine being the kid waiting for your pup to get back up :(
return
basic_pawn.visible_message(span_notice("[basic_pawn] miraculously springs back to life!"))
REMOVE_TRAIT(basic_pawn, TRAIT_FAKEDEATH, BASIC_MOB_DEATH_TRAIT)