add operator<, -, -=
This commit is contained in:
@@ -105,6 +105,13 @@ float RageTimer::operator-(const RageTimer &rhs) const
|
||||
return Difference(*this, rhs);
|
||||
}
|
||||
|
||||
bool RageTimer::operator<( const RageTimer &rhs ) const
|
||||
{
|
||||
if( m_secs != rhs.m_secs ) return m_secs < rhs.m_secs;
|
||||
return m_us < rhs.m_us;
|
||||
|
||||
}
|
||||
|
||||
RageTimer RageTimer::Sum(const RageTimer &lhs, float tm)
|
||||
{
|
||||
/* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25
|
||||
|
||||
@@ -29,11 +29,15 @@ public:
|
||||
|
||||
/* Add (or subtract) a duration from a timestamp. The result is another timestamp. */
|
||||
RageTimer operator+( float tm ) const;
|
||||
RageTimer operator-( float tm ) const { return *this + -tm; }
|
||||
void operator+=( float tm ) { *this = *this + tm; }
|
||||
void operator-=( float tm ) { *this = *this + -tm; }
|
||||
|
||||
/* Find the amount of time between two timestamps. The result is a duration. */
|
||||
float operator-( const RageTimer &rhs ) const;
|
||||
|
||||
bool operator<( const RageTimer &rhs ) const;
|
||||
|
||||
/* "float" is bad for a "time since start" RageTimer. If the game is running for
|
||||
* several days, we'll lose a lot of resolution. I don't want to use double
|
||||
* everywhere, since it's slow. I'd rather not use double just for RageTimers, since
|
||||
|
||||
Reference in New Issue
Block a user