diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index e9406426a1..69608c4750 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5096,6 +5096,10 @@ StateReturnType AIAttackFireWeaponState::update() if (m_att->isAttackingObject()) { + // Re-validate victim immediately before firing; it may have been destroyed since the earlier check. + if (!victim || victim->isEffectivelyDead()) + return STATE_FAILURE; + obj->fireCurrentWeapon(victim); // clear this, just in case. obj->clearStatus( MAKE_OBJECT_STATUS_MASK( OBJECT_STATUS_IGNORING_STEALTH ) ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 6a0ccd6226..92ceeca545 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5256,6 +5256,9 @@ StateReturnType AIAttackFireWeaponState::update() // If the concept of linked turrets is further developed then God help you, and put more code right here // that lookl like the //LINKED TURRETS// block, below + // Re-validate victim immediately before firing; it may have been destroyed since the earlier check. + if (!victim || victim->isEffectivelyDead()) + return STATE_FAILURE; obj->fireCurrentWeapon(victim);