preciseWait flag on client

This commit is contained in:
DBotThePony 2023-10-18 22:25:49 +07:00
parent 5fb6d817fc
commit b1b5b598f0
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -139,6 +139,8 @@ class StarboundClient : Closeable {
var fullbright = true
var preciseWait = false
var clientTerminated = false
private set
@ -741,14 +743,17 @@ class StarboundClient : Closeable {
// try to sleep until next frame as precise as possible
while (diff > 0L) {
executeQueuedTasks()
if (diff >= 1_500_000L) {
LockSupport.parkNanos(1_000_000L)
} else {
Thread.yield()
}
diff = nextRender - System.nanoTime()
if (preciseWait) {
if (diff >= 1_500_000L) {
LockSupport.parkNanos(1_000_000L)
} else {
Thread.yield()
}
} else {
LockSupport.parkNanos(diff)
}
}
val mark = System.nanoTime()