Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 55249d0

Browse files
committed
Use std::min/max instead of macros in Timer
This also applies in a bunch of other places because the Windows macros were undefined and using std::min/max was declared.
1 parent 820f818 commit 55249d0

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

Managers/TimerMan.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
//////////////////////////////////////////////////////////////////////////////////////////
1515
// Inclusions of header files
1616

17+
// TODO: Figure out where we can include this without imploding the whole game and keeping QPC working and having no method/macro conflicts.
1718
#include <allegro.h>
18-
#include <winalleg.h>
19+
#include <winalleg.h>
1920

2021
// Windows.h defines these and they conflict with our methods so we need to undefine them manually.
2122
#undef GetClassName
2223
#undef PlaySound
2324

25+
// minwindef.h defines these and they conflict with the std methods so we need to undefine them manually.
26+
#undef min
27+
#undef max
28+
2429
//#include "Entity.h"
2530
#include "Singleton.h"
2631
#define g_TimerMan TimerMan::Instance()

System/Controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ namespace RTE {
8080
// See if there's other analog input, only if the mouse isn't active (or the cursor will float if mouse is used!)
8181
} else if (GetAnalogCursor().GetLargest() > 0.1 && !IsMouseControlled()) {
8282
// See how much to accelerate the joystick input based on how long the stick has been pushed around
83-
float acceleration = 0.5 + MIN(m_JoyAccelTimer.GetElapsedRealTimeS(), 0.5) * 6;
83+
float acceleration = 0.5 + std::min(m_JoyAccelTimer.GetElapsedRealTimeS(), 0.5) * 6;
8484
cursorPos += GetAnalogCursor() * 10 * moveScale * acceleration;
8585
altered = true;
8686

8787
// Digital movement
8888
} else {
8989
// See how much to accelerate the keyboard input based on how long any key has been pressed
90-
float acceleration = 0.25 + MIN(m_KeyAccelTimer.GetElapsedRealTimeS(), 0.75) * 6;
90+
float acceleration = 0.25 + std::min(m_KeyAccelTimer.GetElapsedRealTimeS(), 0.75) * 6;
9191

9292
if (IsState(HOLD_LEFT)) {
9393
cursorPos.m_X -= 10 * moveScale * acceleration;

System/StandardIncludes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ using std::set;
4242
using std::vector;
4343
using std::ios_base;
4444
using std::make_pair;
45+
using std::min;
46+
using std::max;
4547

4648
#endif

System/Timer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ namespace RTE {
161161
/// 0 means no progress, 1.0 means the timer has reached, or is beyond the limit.
162162
/// </summary>
163163
/// <returns>A normalized scalar between 0.0 - 1.0 showing the progress toward the limit.</returns>
164-
double RealTimeLimitProgress() const { return (m_RealTimeLimit == 0) ? 1.0 : (MIN(1.0, GetElapsedRealTimeMS() / (m_RealTimeLimit / m_TicksPerMS))); }
164+
double RealTimeLimitProgress() const { return (m_RealTimeLimit == 0) ? 1.0 : (std::min(1.0, GetElapsedRealTimeMS() / (m_RealTimeLimit / m_TicksPerMS))); }
165165

166166
/// <summary>
167167
/// Returns true or false, depending on whether the elapsed time falls in one of two repeating intervals which divide it.
@@ -274,7 +274,7 @@ namespace RTE {
274274
/// 0 means no progress, 1.0 means the timer has reached, or is beyond the limit.
275275
/// </summary>
276276
/// <returns>A normalized scalar between 0.0 - 1.0 showing the progress toward the limit.</returns>
277-
double SimTimeLimitProgress() const { return (m_SimTimeLimit == 0) ? 1.0 : (MIN(1.0, GetElapsedSimTimeMS() / (m_SimTimeLimit / m_TicksPerMS))); }
277+
double SimTimeLimitProgress() const { return (m_SimTimeLimit == 0) ? 1.0 : (std::min(1.0, GetElapsedSimTimeMS() / (m_SimTimeLimit / m_TicksPerMS))); }
278278

279279
/// <summary>
280280
/// Returns true or false, depending on whether the elapsed time falls in one of two repeating intervals which divide it.

0 commit comments

Comments
 (0)