mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
bunch of optimizations
This commit is contained in:
@@ -37,6 +37,7 @@ ticks_t Clock::updateTicks()
|
||||
{
|
||||
auto timeNow = std::chrono::high_resolution_clock::now();
|
||||
m_currentTicks = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow - m_startupTime).count();
|
||||
m_currentTime = m_currentTicks/1000.0f;
|
||||
return m_currentTicks;
|
||||
}
|
||||
|
||||
|
@@ -34,15 +34,16 @@ public:
|
||||
void sleep(int ms);
|
||||
|
||||
ticks_t ticks() { return m_currentTicks; }
|
||||
ticks_t ticksElapsed(long prevTicks) { return ticks() - prevTicks; }
|
||||
ticks_t ticksFor(int delay) { return ticks() + delay; }
|
||||
ticks_t ticksElapsed(long prevTicks) { return m_currentTicks - prevTicks; }
|
||||
ticks_t ticksFor(int delay) { return m_currentTicks + delay; }
|
||||
|
||||
double time() { return m_currentTicks/1000.0; }
|
||||
double timeElapsed(double prevTime) { return time() - prevTime; }
|
||||
double timeFor(double delay) { return time() + delay; }
|
||||
float time() { return m_currentTime; }
|
||||
float timeElapsed(float prevTime) { return m_currentTime - prevTime; }
|
||||
float timeFor(float delay) { return m_currentTime + delay; }
|
||||
|
||||
private:
|
||||
ticks_t m_currentTicks;
|
||||
float m_currentTime;
|
||||
std::chrono::system_clock::time_point m_startupTime;
|
||||
};
|
||||
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
ticks_t startTicks() { return m_startTicks; }
|
||||
ticks_t ticksElapsed();
|
||||
double timeElapsed() { return ticksElapsed()/1000.0; }
|
||||
float timeElapsed() { return ticksElapsed()/1000.0f; }
|
||||
|
||||
bool running() { return !m_stopped; }
|
||||
|
||||
|
Reference in New Issue
Block a user