From b1dbba62153fda1d85468660453d15f63d058cd4 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 13:42:23 +0000 Subject: [PATCH] Fix TurretAI crash during state machine destruction --- Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp | 6 ++++++ GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp | 6 ++++++ 2 files changed, 12 insertions(+) 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); + } } // ------------------------------------------------------------------------------------------------