diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp index 5f8eb499fa..2b2ff40675 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp @@ -316,7 +316,13 @@ TurretAI::~TurretAI() stopRotOrPitchSound(); if (m_turretStateMachine) + { + // TheSuperHackers @bugfix xezon 2025 Halt the state machine before deleting it to prevent + // StateMachine::~StateMachine() from calling onExit() on the current state, which may + // access the owning object's AI interface (already nulled in Object::~Object()) and crash. + m_turretStateMachine->halt(); deleteInstance(m_turretStateMachine); + } } // ------------------------------------------------------------------------------------------------ diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp index 6b2c0c2fc4..bd5cde637f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp @@ -316,7 +316,13 @@ TurretAI::~TurretAI() stopRotOrPitchSound(); if (m_turretStateMachine) + { + // TheSuperHackers @bugfix xezon 2025 Halt the state machine before deleting it to prevent + // StateMachine::~StateMachine() from calling onExit() on the current state, which may + // access the owning object's AI interface (already nulled in Object::~Object()) and crash. + m_turretStateMachine->halt(); deleteInstance(m_turretStateMachine); + } } // ------------------------------------------------------------------------------------------------