iw4x-client/src/Utils/Time.cpp

43 lines
742 B
C++
Raw Normal View History

2017-01-19 16:23:59 -05:00
#include "STDInclude.hpp"
namespace Utils
{
namespace Time
{
void Interval::update()
{
this->lastPoint = std::chrono::high_resolution_clock::now();
}
bool Interval::elapsed(std::chrono::nanoseconds nsecs)
{
return ((std::chrono::high_resolution_clock::now() - this->lastPoint) >= nsecs);
}
2017-06-25 15:54:35 -04:00
2017-06-26 17:23:08 -04:00
Point::Point() : lastPoint(Game::Sys_Milliseconds())
{
}
void Point::update()
{
this->lastPoint = Game::Sys_Milliseconds();
}
int Point::diff(Point point)
2017-06-25 15:54:35 -04:00
{
return point.lastPoint - this->lastPoint;
}
bool Point::after(Point point)
{
2017-06-26 17:23:08 -04:00
return this->diff(point) < 0;
}
bool Point::elapsed(int milliseconds)
{
return (Game::Sys_Milliseconds() - this->lastPoint) >= milliseconds;
2017-06-25 15:54:35 -04:00
}
2017-01-19 16:23:59 -05:00
}
}