0
0
Fork 0
mirror of https://git.do.srb2.org/STJr/SRB2.git synced 2025-02-25 13:11:54 +00:00

Adjust slack based on precision

This commit is contained in:
Gustaf Alhäll 2025-01-05 15:58:18 +01:00
parent c00d139e55
commit d20552c49d

View file

@ -2310,9 +2310,9 @@ void I_SleepDuration(precise_t duration)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__)
UINT64 precision = I_GetPrecisePrecision(); UINT64 precision = I_GetPrecisePrecision();
precise_t dest = I_GetPreciseTime() + duration; precise_t dest = I_GetPreciseTime() + duration;
if (duration > 100000) if (duration * 100000 / precision > 1)
{ {
duration -= 100000; // 0.1 ms slack duration -= (precision / 10000); // 0.1 ms slack
struct timespec ts = { struct timespec ts = {
.tv_sec = duration / precision, .tv_sec = duration / precision,
.tv_nsec = duration * 1000000000 / precision % 1000000000, .tv_nsec = duration * 1000000000 / precision % 1000000000,