Skip to content

Commit 148aa7f

Browse files
authored
[GEN][ZH] Fix crash in AIUpdateInterface::privateMoveAwayFromUnit() when a delayed AICommandParms relates to a then deleted object (#964)
1 parent a72a1bf commit 148aa7f

File tree

2 files changed

+18
-0
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update
  • Generals/Code/GameEngine/Source/GameLogic/Object/Update

2 files changed

+18
-0
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,9 @@ Bool AIUpdateInterface::isAllowedToRespondToAiCommands(const AICommandParms* par
25642564
//-------------------------------------------------------------------------------------------------
25652565
void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
25662566
{
2567+
// TheSuperHackers @info The AiCommandParms for m_obj, m_otherObj and m_team should be null tested before use.
2568+
// These variables could relate to a deleted object when a pending command is reconstituted.
2569+
25672570
if (!isAllowedToRespondToAiCommands(parms))
25682571
return;
25692572

@@ -3074,6 +3077,12 @@ void AIUpdateInterface::privateMoveAwayFromUnit( Object *unit, CommandSourceType
30743077
{
30753078
return;
30763079
}
3080+
3081+
// TheSuperHacker @bugfix Mauller 26/05/2025 Fix dereferencing a nullptr when a delayed ai command refers to a deleted object.
3082+
// This can occur when a hacker is told to move away from an object when in its hacking state and is transitioning to a movement state.
3083+
if (!unit)
3084+
return;
3085+
30773086
ObjectID id = unit->getID();
30783087
if (m_stateMachine->getTemporaryState() == AI_MOVE_OUT_OF_THE_WAY) {
30793088
if (m_moveOutOfWay1 == id) {

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,9 @@ Bool AIUpdateInterface::isAllowedToRespondToAiCommands(const AICommandParms* par
26252625
//-------------------------------------------------------------------------------------------------
26262626
void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
26272627
{
2628+
// TheSuperHackers @info The AiCommandParms for m_obj, m_otherObj and m_team should be null tested before use.
2629+
// These variables could relate to a deleted object when a pending command is reconstituted.
2630+
26282631
if (!isAllowedToRespondToAiCommands(parms))
26292632
return;
26302633

@@ -3215,6 +3218,12 @@ void AIUpdateInterface::privateMoveAwayFromUnit( Object *unit, CommandSourceType
32153218
{
32163219
return;
32173220
}
3221+
3222+
// TheSuperHacker @bugfix Mauller 26/05/2025 Fix dereferencing a nullptr when a delayed ai command refers to a deleted object.
3223+
// This can occur when a hacker is told to move away from an object when in its hacking state and is transitioning to a movement state.
3224+
if (!unit)
3225+
return;
3226+
32183227
ObjectID id = unit->getID();
32193228
if (m_stateMachine->getTemporaryState() == AI_MOVE_OUT_OF_THE_WAY) {
32203229
if (m_moveOutOfWay1 == id) {

0 commit comments

Comments
 (0)