From b3bde8b9682bf7108f422c00bc1854b05bba52f4 Mon Sep 17 00:00:00 2001 From: Xertis <118364459+Xertis@users.noreply.github.com> Date: Tue, 11 Aug 2026 14:32:12 +0300 Subject: [PATCH] fix clock.cpp --- src/util/Clock.cpp | 9 +++------ src/util/Clock.hpp | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) 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);