Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Dependencies/Utility/Utility/CppMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
// This file contains macros to help upgrade the code for newer cpp standards.
#pragma once

#if __cplusplus >= 201103L
#include <utility>
#endif

#if __cplusplus >= 201703L
#define NOEXCEPT_17 noexcept
#define REGISTER
Expand All @@ -44,3 +48,15 @@
#define constexpr
#define nullptr 0
#endif

// TheSuperHackers @performance bobtista 25/11/2025 Helper to move-assign from pointer: uses std::move in C++11, swap in C++98
template<typename T>
inline void move_assign_from_pointer(T& dest, T* src)
{
#if __cplusplus >= 201103L
dest = std::move(*src);
#else
// Use swap to emulate move semantics for VC6 compatibility
dest.swap(*src);
#endif
}
17 changes: 3 additions & 14 deletions Generals/Code/GameEngine/Include/GameLogic/AI.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "GameLogic/Damage.h"
#include "Common/STLTypedefs.h"
#include "ref_ptr.h"
#include "Utility/CppMacros.h"

class AIGroup;
class AttackPriorityInfo;
Expand Down Expand Up @@ -539,27 +540,15 @@ class AICommandInterface
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
{
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
#if __cplusplus >= 201103L
parms.m_coords = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
parms.m_coords.swap(*path);
path->clear();
#endif
move_assign_from_pointer(parms.m_coords, path);
parms.m_obj = ignoreObject;
aiDoCommand(&parms);
}

inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
{
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
#if __cplusplus >= 201103L
parms.m_coords = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
parms.m_coords.swap(*path);
path->clear();
#endif
move_assign_from_pointer(parms.m_coords, path);
parms.m_obj = ignoreObject;
aiDoCommand(&parms);
}
Expand Down
2 changes: 2 additions & 0 deletions Generals/Code/GameEngine/Include/GameLogic/AIStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ extern Bool outOfWeaponRangeObject( State *thisState, void* userData );
extern Bool outOfWeaponRangePosition( State *thisState, void* userData );
extern Bool wantToSquishTarget( State *thisState, void* userData );

#include "Utility/CppMacros.h"

//-----------------------------------------------------------------------------------------------------------
/**
The AI state machine. This is used by AIUpdate to implement all of the
Expand Down
8 changes: 1 addition & 7 deletions Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,13 +818,7 @@ void AIStateMachine::loadPostProcess( void )
*/
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
{
#if __cplusplus >= 201103L
m_goalPath = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
m_goalPath.swap(*path);
path->clear();
#endif
move_assign_from_pointer(m_goalPath, path);
}

#ifdef STATE_MACHINE_DEBUG
Expand Down
17 changes: 3 additions & 14 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "GameLogic/Damage.h"
#include "Common/STLTypedefs.h"
#include "ref_ptr.h"
#include "Utility/CppMacros.h"

class AIGroup;
class AttackPriorityInfo;
Expand Down Expand Up @@ -553,27 +554,15 @@ class AICommandInterface
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
{
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
#if __cplusplus >= 201103L
parms.m_coords = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
parms.m_coords.swap(*path);
path->clear();
#endif
move_assign_from_pointer(parms.m_coords, path);
parms.m_obj = ignoreObject;
aiDoCommand(&parms);
}

inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
{
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
#if __cplusplus >= 201103L
parms.m_coords = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
parms.m_coords.swap(*path);
path->clear();
#endif
move_assign_from_pointer(parms.m_coords, path);
parms.m_obj = ignoreObject;
aiDoCommand(&parms);
}
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ extern Bool outOfWeaponRangeObject( State *thisState, void* userData );
extern Bool outOfWeaponRangePosition( State *thisState, void* userData );
extern Bool wantToSquishTarget( State *thisState, void* userData );

#include "Utility/CppMacros.h"

//-----------------------------------------------------------------------------------------------------------
/**
The AI state machine. This is used by AIUpdate to implement all of the
Expand Down
8 changes: 1 addition & 7 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,7 @@ void AIStateMachine::loadPostProcess( void )
*/
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
{
#if __cplusplus >= 201103L
m_goalPath = std::move(*path);
#else
// TheSuperHackers @performance bobtista 23/11/2025 Use swap to emulate move semantics for VC6 compatibility
m_goalPath.swap(*path);
path->clear();
#endif
move_assign_from_pointer(m_goalPath, path);
}

#ifdef STATE_MACHINE_DEBUG
Expand Down
Loading