Fixed #8864
This commit is contained in:
@@ -27,7 +27,7 @@ import static mindustry.Vars.*;
|
||||
public abstract class ClientLauncher extends ApplicationCore implements Platform{
|
||||
private static final int loadingFPS = 20;
|
||||
|
||||
private long lastTime;
|
||||
private long nextFrame;
|
||||
private long beginTime;
|
||||
private boolean finished = false;
|
||||
private LoadRenderer loader;
|
||||
@@ -199,6 +199,13 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
int targetfps = Core.settings.getInt("fpscap", 120);
|
||||
boolean limitFps = targetfps > 0 && targetfps <= 240;
|
||||
|
||||
if(limitFps){
|
||||
nextFrame += (1000 * 1000000) / targetfps;
|
||||
}
|
||||
|
||||
if(!finished){
|
||||
if(loader != null){
|
||||
loader.draw();
|
||||
@@ -230,17 +237,13 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
asyncCore.end();
|
||||
}
|
||||
|
||||
int targetfps = Core.settings.getInt("fpscap", 120);
|
||||
|
||||
if(targetfps > 0 && targetfps <= 240){
|
||||
long target = (1000 * 1000000) / targetfps; //target in nanos
|
||||
long elapsed = Time.timeSinceNanos(lastTime);
|
||||
if(elapsed < target){
|
||||
Threads.sleep((target - elapsed) / 1000000, (int)((target - elapsed) % 1000000));
|
||||
if(limitFps){
|
||||
long current = Time.nanos();
|
||||
if(nextFrame > current){
|
||||
long toSleep = nextFrame - current;
|
||||
Threads.sleep(toSleep / 1000000, (int)(toSleep % 1000000));
|
||||
}
|
||||
}
|
||||
|
||||
lastTime = Time.nanos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -251,6 +254,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
nextFrame = Time.nanos();
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user