diff --git a/src/util/Clock.cpp b/src/util/Clock.cpp index dbe7b870f..f0d011c46 100644 --- a/src/util/Clock.cpp +++ b/src/util/Clock.cpp @@ -1,6 +1,5 @@ #include "Clock.hpp" -#include #include using namespace util; @@ -20,10 +19,8 @@ int Clock::update(float delta) { tickTimer -= parts * delay / tickParts; tickTimer = std::min(tickTimer, delay); } - currentTickPart += parts; - if (currentTickPart >= tickParts) { - currentTickPart %= tickParts; - } + lastPartsStart = currentTickPart; + currentTickPart = (currentTickPart + parts) % tickParts; return parts; } @@ -40,5 +37,5 @@ int Clock::getTickId() const { } int Clock::convertPart(int index) const { - return (tickParts - currentTickPart) % tickParts + index; + return (lastPartsStart + index) % tickParts; } diff --git a/src/util/Clock.hpp b/src/util/Clock.hpp index a8ae83fd2..0b91c3fa6 100644 --- a/src/util/Clock.hpp +++ b/src/util/Clock.hpp @@ -8,6 +8,7 @@ namespace util { float tickTimer = 0.0f; int tickId = 0; int currentTickPart = 0; + int lastPartsStart = 0; public: Clock(int tickRate, int tickParts);