Skip to content

Commit e9b7e5c

Browse files
committed
refactor(perf): keep AICommandParms const and copy coords where needed
1 parent 803e5b3 commit e9b7e5c

File tree

2 files changed

+20
-4
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update
  • Generals/Code/GameEngine/Source/GameLogic/Object/Update

2 files changed

+20
-4
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,14 +2619,22 @@ void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
26192619
privateFollowWaypointPathAsTeamExact(parms->m_waypoint, parms->m_cmdSource);
26202620
break;
26212621
case AICMD_FOLLOW_PATH:
2622-
privateFollowPath(&parms->m_coords, parms->m_obj, parms->m_cmdSource, FALSE);
2622+
{
2623+
// Keep AICommandParms const; use a local copy of the coordinates when following the path.
2624+
std::vector<Coord3D> coords = parms->m_coords;
2625+
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, FALSE);
26232626
break;
2627+
}
26242628
case AICMD_FOLLOW_PATH_APPEND:
26252629
privateFollowPathAppend(&parms->m_pos, parms->m_cmdSource);
26262630
break;
26272631
case AICMD_FOLLOW_EXITPRODUCTION_PATH:
2628-
privateFollowPath(&parms->m_coords, parms->m_obj, parms->m_cmdSource, TRUE);
2632+
{
2633+
// Keep AICommandParms const; use a local copy of the coordinates when following the exit path.
2634+
std::vector<Coord3D> coords = parms->m_coords;
2635+
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, TRUE);
26292636
break;
2637+
}
26302638
case AICMD_ATTACK_OBJECT:
26312639
privateAttackObject(parms->m_obj, parms->m_intValue, parms->m_cmdSource);
26322640
break;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,14 +2681,22 @@ void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
26812681
privateFollowWaypointPathAsTeamExact(parms->m_waypoint, parms->m_cmdSource);
26822682
break;
26832683
case AICMD_FOLLOW_PATH:
2684-
privateFollowPath(&parms->m_coords, parms->m_obj, parms->m_cmdSource, FALSE);
2684+
{
2685+
// Keep AICommandParms const; use a local copy of the coordinates when following the path.
2686+
std::vector<Coord3D> coords = parms->m_coords;
2687+
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, FALSE);
26852688
break;
2689+
}
26862690
case AICMD_FOLLOW_PATH_APPEND:
26872691
privateFollowPathAppend(&parms->m_pos, parms->m_cmdSource);
26882692
break;
26892693
case AICMD_FOLLOW_EXITPRODUCTION_PATH:
2690-
privateFollowPath(&parms->m_coords, parms->m_obj, parms->m_cmdSource, TRUE);
2694+
{
2695+
// Keep AICommandParms const; use a local copy of the coordinates when following the exit path.
2696+
std::vector<Coord3D> coords = parms->m_coords;
2697+
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, TRUE);
26912698
break;
2699+
}
26922700
case AICMD_ATTACK_OBJECT:
26932701
privateAttackObject(parms->m_obj, parms->m_intValue, parms->m_cmdSource);
26942702
break;

0 commit comments

Comments
 (0)