Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2722,23 +2722,21 @@ void AIGroup::groupCheer( CommandSourceType cmdSource )
*/
void AIGroup::groupSell( CommandSourceType cmdSource )
{
std::list<Object *>::iterator i, thisIterator;
Object *obj;
std::list<Object *>::iterator i;
std::vector<Object *> groupObjectsCopy;
groupObjectsCopy.reserve(m_memberListSize);
Comment thread
Mauller marked this conversation as resolved.
Outdated

// TheSuperHackers @bugfix Mauller 26/06/2025 when sellObject is called, the member list objects in this AIGroup get removed from it. This happens within the Object::deselectObject() function.
// This deletes the local AIGroup object from under the call to groupSell, therefore we need to make a local copy of the objects that need selling.
for( i = m_memberList.begin(); i != m_memberList.end(); /*empty*/ )
Comment thread
Mauller marked this conversation as resolved.
Outdated
{
groupObjectsCopy.push_back( *i++ );
}

// work off of 'thisIterator' as we may change the contents of this list
thisIterator = i;
++i;

// get object
obj = *thisIterator;

// try to sell object
TheBuildAssistant->sellObject( obj );

} // end for, i
for( size_t j = 0; j < groupObjectsCopy.size(); ++j )
{
TheBuildAssistant->sellObject( groupObjectsCopy[j] );
}

}

Expand Down
24 changes: 11 additions & 13 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2795,23 +2795,21 @@ void AIGroup::groupCheer( CommandSourceType cmdSource )
*/
void AIGroup::groupSell( CommandSourceType cmdSource )
{
std::list<Object *>::iterator i, thisIterator;
Object *obj;
std::list<Object *>::iterator i;
std::vector<Object *> groupObjectsCopy;
groupObjectsCopy.reserve(m_memberListSize);

// TheSuperHackers @bugfix Mauller 26/06/2025 when sellObject is called, the member list objects in this AIGroup get removed from it. This happens within the Object::deselectObject() function.
// This deletes the local AIGroup object from under the call to groupSell, therefore we need to make a local copy of the objects that need selling.
for( i = m_memberList.begin(); i != m_memberList.end(); /*empty*/ )
{
groupObjectsCopy.push_back( *i++ );
}

// work off of 'thisIterator' as we may change the contents of this list
thisIterator = i;
++i;

// get object
obj = *thisIterator;

// try to sell object
TheBuildAssistant->sellObject( obj );

} // end for, i
for( size_t j = 0; j < groupObjectsCopy.size(); ++j )
{
TheBuildAssistant->sellObject( groupObjectsCopy[j] );
}

}

Expand Down
Loading