diff --git a/Generals/Code/Libraries/Include/Lib/BaseType.h b/Generals/Code/Libraries/Include/Lib/BaseType.h index 73b766ede9a..ccb2f34ffc8 100644 --- a/Generals/Code/Libraries/Include/Lib/BaseType.h +++ b/Generals/Code/Libraries/Include/Lib/BaseType.h @@ -58,6 +58,28 @@ inline int sign(NUM x) else return 0; } +// TheSuperHackers @refactor JohnsterID 24/01/2026 Add lowercase min/max templates for GameEngine layer. +// GameEngine code typically uses BaseType.h, but may include WWVegas headers (which define min/max in always.h). +// Header guard prevents duplicate definitions. VC6's lacks std::min/std::max. +#ifndef _MIN_MAX_TEMPLATES_DEFINED_ +#define _MIN_MAX_TEMPLATES_DEFINED_ + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +template +inline T min(T a, T b) { return (a < b) ? a : b; } + +template +inline T max(T a, T b) { return (a > b) ? a : b; } + +#endif // _MIN_MAX_TEMPLATES_DEFINED_ + //----------------------------------------------------------------------------- inline Real rad2deg(Real rad) { return rad * (180/PI); } inline Real deg2rad(Real rad) { return rad * (PI/180); } @@ -174,8 +196,8 @@ struct RealRange // both ranges void combine( RealRange &other ) { - lo = MIN( lo, other.lo ); - hi = MAX( hi, other.hi ); + lo = min( lo, other.lo ); + hi = max( hi, other.hi ); } }; diff --git a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h index 383c2471418..f67ac0d2efe 100644 --- a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h +++ b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h @@ -58,6 +58,28 @@ inline int sign(NUM x) else return 0; } +// TheSuperHackers @refactor JohnsterID 24/01/2026 Add lowercase min/max templates for GameEngine layer. +// GameEngine code typically uses BaseType.h, but may include WWVegas headers (which define min/max in always.h). +// Header guard prevents duplicate definitions. VC6's lacks std::min/std::max. +#ifndef _MIN_MAX_TEMPLATES_DEFINED_ +#define _MIN_MAX_TEMPLATES_DEFINED_ + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +template +inline T min(T a, T b) { return (a < b) ? a : b; } + +template +inline T max(T a, T b) { return (a > b) ? a : b; } + +#endif // _MIN_MAX_TEMPLATES_DEFINED_ + //----------------------------------------------------------------------------- inline Real rad2deg(Real rad) { return rad * (180/PI); } inline Real deg2rad(Real rad) { return rad * (PI/180); } @@ -174,8 +196,8 @@ struct RealRange // both ranges void combine( RealRange &other ) { - lo = MIN( lo, other.lo ); - hi = MAX( hi, other.hi ); + lo = min( lo, other.lo ); + hi = max( hi, other.hi ); } };