Skip to content

Commit 5965d08

Browse files
committed
Replicate AI path function changes from GeneralsMD
1 parent 95b00a1 commit 5965d08

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

Generals/Code/GameEngine/Include/GameLogic/AI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,15 @@ class AICommandInterface
536536
aiDoCommand(&parms);
537537
}
538538

539-
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
539+
void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
540540
{
541541
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
542542
move_or_swap(parms.m_coords, *path);
543543
parms.m_obj = ignoreObject;
544544
aiDoCommand(&parms);
545545
}
546546

547-
inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
547+
void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
548548
{
549549
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
550550
move_or_swap(parms.m_coords, *path);

Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ void AICommandParmsStorage::store(const AICommandParms& parms)
9595
m_obj = parms.m_obj ? parms.m_obj->getID() : INVALID_ID;
9696
m_otherObj = parms.m_otherObj ? parms.m_otherObj->getID() : INVALID_ID;
9797
m_teamName = parms.m_team ? parms.m_team->getName() : AsciiString::TheEmptyString;
98-
// We intentionally const_cast here so we can move the path coordinates into storage.
99-
// AICommandParms is treated as a transient command container that is not reused after dispatch.
100-
std::vector<Coord3D>& coords = const_cast<std::vector<Coord3D>&>(parms.m_coords);
101-
move_or_swap(m_coords, coords);
98+
m_coords = parms.m_coords;
10299
m_waypoint = parms.m_waypoint;
103100
m_polygon = parms.m_polygon;
104101
m_intValue = parms.m_intValue; /// misc usage

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
26202620
break;
26212621
case AICMD_FOLLOW_PATH:
26222622
{
2623-
// Keep AICommandParms const; use a local copy of the coordinates when following the path.
2623+
// Copy coordinates to a local vector since privateFollowPath requires a non-const pointer.
26242624
std::vector<Coord3D> coords = parms->m_coords;
26252625
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, FALSE);
26262626
break;
@@ -2630,7 +2630,7 @@ void AIUpdateInterface::aiDoCommand(const AICommandParms* parms)
26302630
break;
26312631
case AICMD_FOLLOW_EXITPRODUCTION_PATH:
26322632
{
2633-
// Keep AICommandParms const; use a local copy of the coordinates when following the exit path.
2633+
// Copy coordinates to a local vector since privateFollowPath requires a non-const pointer.
26342634
std::vector<Coord3D> coords = parms->m_coords;
26352635
privateFollowPath(&coords, parms->m_obj, parms->m_cmdSource, TRUE);
26362636
break;

0 commit comments

Comments
 (0)