Undefine macro in RageTimer.cpp
This commit is contained in:
+14
-12
@@ -30,7 +30,9 @@
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#define TIMESTAMP_RESOLUTION 1000000
|
||||
const std::uint64_t ONE_SECOND_IN_MICROSECONDS_ULL = 1000000ULL;
|
||||
const std::int64_t ONE_SECOND_IN_MICROSECONDS_LL = 1000000LL;
|
||||
const double ONE_SECOND_IN_MICROSECONDS_DBL = 1000000.0;
|
||||
|
||||
const RageTimer RageZeroTimer(0,0);
|
||||
static std::uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true );
|
||||
@@ -52,7 +54,7 @@ double RageTimer::GetTimeSinceStart(bool bAccurate)
|
||||
{
|
||||
std::uint64_t usecs = GetTime(bAccurate);
|
||||
usecs -= g_iStartTime;
|
||||
return usecs / 1000000.0;
|
||||
return usecs / ONE_SECOND_IN_MICROSECONDS_DBL;
|
||||
}
|
||||
|
||||
std::uint64_t RageTimer::GetUsecsSinceStart()
|
||||
@@ -64,8 +66,8 @@ void RageTimer::Touch()
|
||||
{
|
||||
std::uint64_t usecs = GetTime( true );
|
||||
|
||||
this->m_secs = std::uint64_t(usecs / TIMESTAMP_RESOLUTION);
|
||||
this->m_us = std::uint64_t(usecs % TIMESTAMP_RESOLUTION);
|
||||
this->m_secs = std::uint64_t(usecs / ONE_SECOND_IN_MICROSECONDS_ULL);
|
||||
this->m_us = std::uint64_t(usecs % ONE_SECOND_IN_MICROSECONDS_ULL);
|
||||
}
|
||||
|
||||
float RageTimer::Ago() const
|
||||
@@ -119,8 +121,8 @@ RageTimer RageTimer::Sum(const RageTimer& lhs, float tm)
|
||||
/* Calculate the seconds and microseconds from the time:
|
||||
* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25
|
||||
* tm == -1.25 -> secs = -2, us = -1.25 - (-2) = .75 */
|
||||
int64_t seconds = std::floor(tm);
|
||||
int64_t us = int64_t((tm - seconds) * TIMESTAMP_RESOLUTION);
|
||||
std::int64_t seconds = std::floor(tm);
|
||||
std::int64_t us = static_cast<int64_t>((tm - seconds) * ONE_SECOND_IN_MICROSECONDS_LL);
|
||||
|
||||
// Prevent unnecessarily checking the time
|
||||
RageTimer ret(0, 0);
|
||||
@@ -130,9 +132,9 @@ RageTimer RageTimer::Sum(const RageTimer& lhs, float tm)
|
||||
ret.m_us = us + lhs.m_us;
|
||||
|
||||
// Adjust the seconds and microseconds if microseconds is greater than or equal to TIMESTAMP_RESOLUTION
|
||||
if (ret.m_us >= TIMESTAMP_RESOLUTION)
|
||||
if (ret.m_us >= ONE_SECOND_IN_MICROSECONDS_ULL)
|
||||
{
|
||||
ret.m_us -= TIMESTAMP_RESOLUTION;
|
||||
ret.m_us -= ONE_SECOND_IN_MICROSECONDS_ULL;
|
||||
++ret.m_secs;
|
||||
}
|
||||
|
||||
@@ -142,18 +144,18 @@ RageTimer RageTimer::Sum(const RageTimer& lhs, float tm)
|
||||
double RageTimer::Difference(const RageTimer& lhs, const RageTimer& rhs)
|
||||
{
|
||||
// Calculate the difference in seconds and microseconds respectively
|
||||
int64_t secs = lhs.m_secs - rhs.m_secs;
|
||||
int64_t us = lhs.m_us - rhs.m_us;
|
||||
std::int64_t secs = lhs.m_secs - rhs.m_secs;
|
||||
std::int64_t us = lhs.m_us - rhs.m_us;
|
||||
|
||||
// Adjust seconds and microseconds if microseconds is negative
|
||||
if ( us < 0 )
|
||||
{
|
||||
us += TIMESTAMP_RESOLUTION;
|
||||
us += ONE_SECOND_IN_MICROSECONDS_LL;
|
||||
--secs;
|
||||
}
|
||||
|
||||
// Return the difference as a double to preserve the fractional part
|
||||
return static_cast<double>(secs) + static_cast<double>(us) / TIMESTAMP_RESOLUTION;
|
||||
return static_cast<double>(secs) + static_cast<double>(us) / ONE_SECOND_IN_MICROSECONDS_DBL;
|
||||
}
|
||||
|
||||
#include "LuaManager.h"
|
||||
|
||||
Reference in New Issue
Block a user