Skip to content

Commit 2a5e8f8

Browse files
committed
Add conditional compilation for move vs swap and clear source vector
1 parent e951e6c commit 2a5e8f8

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,27 @@ class AICommandInterface
539539
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
540540
{
541541
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
542+
#if __cplusplus >= 201103L
543+
parms.m_coords = std::move(*path);
544+
#else
545+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
542546
parms.m_coords.swap(*path);
547+
path->clear();
548+
#endif
543549
parms.m_obj = ignoreObject;
544550
aiDoCommand(&parms);
545551
}
546552

547553
inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
548554
{
549555
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
556+
#if __cplusplus >= 201103L
557+
parms.m_coords = std::move(*path);
558+
#else
559+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
550560
parms.m_coords.swap(*path);
561+
path->clear();
562+
#endif
551563
parms.m_obj = ignoreObject;
552564
aiDoCommand(&parms);
553565
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,14 @@ void AIStateMachine::loadPostProcess( void )
818818
*/
819819
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
820820
{
821+
#if __cplusplus >= 201103L
822+
m_goalPath = std::move(*path);
823+
#else
824+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
825+
// Swap transfers ownership without copying. Clear source to make intent explicit.
821826
m_goalPath.swap(*path);
827+
path->clear();
828+
#endif
822829
}
823830

824831
#ifdef STATE_MACHINE_DEBUG

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,27 @@ class AICommandInterface
553553
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
554554
{
555555
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
556+
#if __cplusplus >= 201103L
557+
parms.m_coords = std::move(*path);
558+
#else
559+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
556560
parms.m_coords.swap(*path);
561+
path->clear();
562+
#endif
557563
parms.m_obj = ignoreObject;
558564
aiDoCommand(&parms);
559565
}
560566

561567
inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
562568
{
563569
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
570+
#if __cplusplus >= 201103L
571+
parms.m_coords = std::move(*path);
572+
#else
573+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
564574
parms.m_coords.swap(*path);
575+
path->clear();
576+
#endif
565577
parms.m_obj = ignoreObject;
566578
aiDoCommand(&parms);
567579
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,14 @@ void AIStateMachine::loadPostProcess( void )
823823
*/
824824
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
825825
{
826+
#if __cplusplus >= 201103L
827+
m_goalPath = std::move(*path);
828+
#else
829+
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
830+
// Swap transfers ownership without copying. Clear source to make intent explicit.
826831
m_goalPath.swap(*path);
832+
path->clear();
833+
#endif
827834
}
828835

829836
#ifdef STATE_MACHINE_DEBUG

0 commit comments

Comments
 (0)