@@ -1641,19 +1641,25 @@ void Get_Helicopter_Offset(Coord3D &pos, int count)
1641
1641
}
1642
1642
}
1643
1643
1644
+ /* *
1645
+ Group_Tighten_To_Position - Performs tightening of the group members towards a target position.
1646
+ This method iterates over the group members, calculates their distances to the target position,
1647
+ and sorts them in ascending order based on the squared distance. It then applies tightening
1648
+ behavior to each member based on the specified conditions.
1649
+
1650
+ @param target_pos The target position to tighten towards.
1651
+ @param append A flag indicating whether to append to existing waypoints or not.
1652
+ @param cmd_source The source of the command.
1653
+ */
1644
1654
void AIGroup::Group_Tighten_To_Position (const Coord3D *target_pos, bool append, CommandSourceType cmd_source)
1645
1655
{
1646
- if (cmd_source == COMMANDSOURCE_PLAYER && g_theWriteableGlobalData->m_groupMoveClickToGatherAreaFactor > 0 .0f ) {
1647
- Coord2D min;
1648
- Coord2D max;
1649
- Coord3D center;
1650
- Get_Min_Max_And_Center (&min, &max, ¢er);
1651
- }
1652
1656
1657
+ // Create a SimpleObjectIterator to hold and iterate over the group members
1653
1658
MemoryPoolObjectHolder holder (nullptr );
1654
1659
SimpleObjectIterator *iter = new SimpleObjectIterator ();
1655
1660
holder.Hold (iter);
1656
1661
1662
+ // Iterate over the group members and insert them into the iterator based on distance to target
1657
1663
for (auto it = m_memberList.begin (); it != m_memberList.end (); it++) {
1658
1664
Coord3D member_pos = *(*it)->Get_Position ();
1659
1665
@@ -1668,9 +1674,11 @@ void AIGroup::Group_Tighten_To_Position(const Coord3D *target_pos, bool append,
1668
1674
}
1669
1675
}
1670
1676
1677
+ // Sort the iterator in ascending order based on the distance to target
1671
1678
iter->Sort (ITER_SORTED_NEAR_TO_FAR);
1672
1679
int heli_count = 0 ;
1673
1680
1681
+ // Iterate over the sorted members and apply tightening behavior
1674
1682
for (Object *iter_obj = iter->First (); iter_obj != nullptr ; iter_obj = iter->Next ()) {
1675
1683
AIUpdateInterface *update = iter_obj->Get_AI_Update_Interface ();
1676
1684
@@ -1686,6 +1694,7 @@ void AIGroup::Group_Tighten_To_Position(const Coord3D *target_pos, bool append,
1686
1694
}
1687
1695
}
1688
1696
1697
+ // Update the positions of the members in the Pathfinder
1689
1698
for (Object *iter_obj = iter->First (); iter_obj != nullptr ; iter_obj = iter->Next ()) {
1690
1699
Coord3D iter_pos = *iter_obj->Get_Position ();
1691
1700
g_theAI->Get_Pathfinder ()->Update_Pos (iter_obj, &iter_pos);
0 commit comments