From 6638faad4cf3c7d171352ab69ecac19ead977f1f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 24 Oct 2002 07:07:26 +0000 Subject: [PATCH] Use for min and max, and whatever else it has. Add a workaround for a VC6 STL bug. --- stepmania/src/RageUtil.h | 21 ++++++--------------- stepmania/src/StdAfx.h | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index 21276ea232..0be8958a92 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -28,16 +28,6 @@ inline int RECTCENTERX(RECT rect) { return rect.left + (rect.right-rect.left)/2; } inline int RECTCENTERY(RECT rect) { return rect.top + (rect.bottom-rect.top)/2; } -#undef min -#undef max -#define NOMINMAX /* make sure Windows doesn't try to define this */ - -template -inline const T & max(const T &a, const T &b) { return a > b? a:b; } - -template -inline const T & min(const T &a, const T &b) { return a < b? a:b; } - /* Common harmless mismatches. */ inline float min(float a, int b) { return a < b? a:b; } inline float max(float a, int b) { return a > b? a:b; } @@ -56,10 +46,7 @@ inline float max(int a, float b) { return a > b? a:b; } #define clamp(val,low,high) ( max( (low), min((val),(high)) ) ) -template -void swap(T &a, T &b) { T c = a; a = b; b = c; } - -#define PI D3DX_PI +#define PI 3.1415926535897932384626433832795 #define DEG (PI / 180.0f) #define RAD (180.0f / PI) // Scales x so that l1 corresponds to l2 and h1 corresponds to h2. Does not modify x, MUST assign the result to something! @@ -202,8 +189,12 @@ void ReadFloatFromFile( FILE* file, float& f ); void WriteUlongToFile( FILE* file, ULONG u ); void ReadUlongFromFile( FILE* file, ULONG& u ); +/* Find the mean and standard deviation of all numbers in [start,end). */ +float calc_mean(const float *start, const float *end); +float calc_stddev(const float *start, const float *end); + /* Fix Windows breakage ... */ -#ifdef WINDOWS +#ifdef WIN32 #define getcwd _getcwd #define wgetcwd _wgetcwd #define chdir _chdir diff --git a/stepmania/src/StdAfx.h b/stepmania/src/StdAfx.h index 8f5875255d..d4b9ee94a9 100644 --- a/stepmania/src/StdAfx.h +++ b/stepmania/src/StdAfx.h @@ -29,7 +29,14 @@ #pragma warning (disable : 4127) #endif +#undef min +#undef max +#define NOMINMAX /* make sure Windows doesn't try to define this */ + #include // MFC core and standard components +#include + +using namespace std; #include #include @@ -64,6 +71,21 @@ public: }; #define CString CStringTemp #define CStringArray CArray + +/* VC6's is doesn't actually define min and max. */ +template +inline const T& max(const T &a, const T &b) +{ return a < b? b:a; } +template +inline const T& max(const T &a, const T &b, P Pr) +{ return Pr(a, b)? b:a; } +template +inline const T& min(const T &a, const T &b) +{ return b < a? b:a; } +template +inline const T& min(const T &a, const T &b, P Pr) +{ return Pr(b, a)? b:a; } + #endif #endif