Merge pull request #927 from Xertis/main

fix clock.cpp
This commit is contained in:
MihailRis 2026-08-11 18:53:36 +03:00 • committed by GitHub
commit b7641541cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View file

@ -1,6 +1,5 @@
#include "Clock.hpp"
#include <cmath>
#include <algorithm>
using namespace util;
@ -20,10 +19,8 @@ int Clock::update(float delta) {
tickTimer -= parts * delay / tickParts;
tickTimer = std::min<float>(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;
}

View file

@ -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);