Skip to content

Commit a1f5d61

Browse files
committed
removes obsolete code, adds comments for readability
1 parent 5529abc commit a1f5d61

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/game/logic/ai/aigroup.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,19 +1641,25 @@ void Get_Helicopter_Offset(Coord3D &pos, int count)
16411641
}
16421642
}
16431643

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+
*/
16441654
void AIGroup::Group_Tighten_To_Position(const Coord3D *target_pos, bool append, CommandSourceType cmd_source)
16451655
{
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, &center);
1651-
}
16521656

1657+
// Create a SimpleObjectIterator to hold and iterate over the group members
16531658
MemoryPoolObjectHolder holder(nullptr);
16541659
SimpleObjectIterator *iter = new SimpleObjectIterator();
16551660
holder.Hold(iter);
16561661

1662+
// Iterate over the group members and insert them into the iterator based on distance to target
16571663
for (auto it = m_memberList.begin(); it != m_memberList.end(); it++) {
16581664
Coord3D member_pos = *(*it)->Get_Position();
16591665

@@ -1668,9 +1674,11 @@ void AIGroup::Group_Tighten_To_Position(const Coord3D *target_pos, bool append,
16681674
}
16691675
}
16701676

1677+
// Sort the iterator in ascending order based on the distance to target
16711678
iter->Sort(ITER_SORTED_NEAR_TO_FAR);
16721679
int heli_count = 0;
16731680

1681+
// Iterate over the sorted members and apply tightening behavior
16741682
for (Object *iter_obj = iter->First(); iter_obj != nullptr; iter_obj = iter->Next()) {
16751683
AIUpdateInterface *update = iter_obj->Get_AI_Update_Interface();
16761684

@@ -1686,6 +1694,7 @@ void AIGroup::Group_Tighten_To_Position(const Coord3D *target_pos, bool append,
16861694
}
16871695
}
16881696

1697+
// Update the positions of the members in the Pathfinder
16891698
for (Object *iter_obj = iter->First(); iter_obj != nullptr; iter_obj = iter->Next()) {
16901699
Coord3D iter_pos = *iter_obj->Get_Position();
16911700
g_theAI->Get_Pathfinder()->Update_Pos(iter_obj, &iter_pos);

0 commit comments

Comments
 (0)