Merge pull request #12091 from Heroman3003/aifix2

Fixes AI subsystem locking up on trying to process null entries
This commit is contained in:
Novacat
2022-01-22 09:16:57 -05:00
committed by CHOMPStation2
parent e611f86f3f
commit affc70ee1b
2 changed files with 16 additions and 7 deletions

View File

@@ -32,8 +32,11 @@ SUBSYSTEM_DEF(ai)
while(currentrun.len)
var/datum/ai_holder/A = currentrun[currentrun.len]
--currentrun.len
if(!A || QDELETED(A) || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
continue
var/mob/living/L = A.holder //VOREStation Edit Start
if(!A || QDELETED(A) || !L?.loc || A.busy) // Doesn't exist or won't exist soon or not doing it this tick
if(!L?.loc)
continue
if(process_z[get_z(L)] || !L.low_priority) //VOREStation Edit End

View File

@@ -291,6 +291,9 @@
// 'Tactical' processes such as moving a step, meleeing an enemy, firing a projectile, and other fairly cheap actions that need to happen quickly.
/datum/ai_holder/proc/handle_tactics()
if(!istype(holder) || QDELETED(holder))
qdel(src)
return
if(holder.key && !autopilot)
return
handle_special_tactic()
@@ -298,6 +301,9 @@
// 'Strategical' processes that are more expensive on the CPU and so don't get run as often as the above proc, such as A* pathfinding or robust targeting.
/datum/ai_holder/proc/handle_strategicals()
if(!istype(holder) || QDELETED(holder))
qdel(src)
return
if(holder.key && !autopilot)
return
handle_special_strategical()