From c9f4d5e92fa3e2233d736992d2003fd2c5ff6fe0 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Wed, 15 Oct 2025 08:18:39 +0000 Subject: [PATCH] AIGroup: Advance iterator before calling doCommandButton --- .../Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp | 9 ++++++--- .../Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp index d3dbb67e24b..70ac05b3f2b 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp @@ -2889,11 +2889,12 @@ void AIGroup::groupDoCommandButton( const CommandButton *commandButton, CommandS std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButton( commandButton, cmdSource ); } @@ -2909,11 +2910,12 @@ void AIGroup::groupDoCommandButtonAtPosition( const CommandButton *commandButton std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButtonAtPosition( commandButton, pos, cmdSource ); } @@ -2928,11 +2930,12 @@ void AIGroup::groupDoCommandButtonAtObject( const CommandButton *commandButton, std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButtonAtObject( commandButton, obj, cmdSource ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp index effcd157c50..17f7b045bc1 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp @@ -2962,11 +2962,12 @@ void AIGroup::groupDoCommandButton( const CommandButton *commandButton, CommandS std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButton( commandButton, cmdSource ); } @@ -2982,11 +2983,12 @@ void AIGroup::groupDoCommandButtonAtPosition( const CommandButton *commandButton std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButtonAtPosition( commandButton, pos, cmdSource ); } @@ -3001,11 +3003,12 @@ void AIGroup::groupDoCommandButtonUsingWaypoints( const CommandButton *commandBu std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButtonUsingWaypoints( commandButton, way, cmdSource ); } @@ -3020,11 +3023,12 @@ void AIGroup::groupDoCommandButtonAtObject( const CommandButton *commandButton, std::list::iterator i; Object *source; - for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) + for( i = m_memberList.begin(); i != m_memberList.end(); /* empty */ ) { // get object source = *i; + ++i; // Advance iterator before the call that might destroy the object source->doCommandButtonAtObject( commandButton, obj, cmdSource ); }