diff --git a/build.gradle b/build.gradle index 0ac560c982..63cf126d57 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects { gdxVersion = '1.9.8' roboVMVersion = '2.3.0' aiVersion = '1.8.1' - uCoreVersion = '7673041e62' + uCoreVersion = '05f51b183e' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 3b2110156b..5b820adf88 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.core; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.Base64Coder; import com.badlogic.gdx.utils.IntSet; @@ -175,7 +176,7 @@ public class NetClient extends Module { ui.loadfrag.hide(); ui.join.hide(); Net.setClientLoaded(true); - Call.connectConfirm(); + Gdx.app.postRunnable(Call::connectConfirm); Timers.runTask(40f, Platform.instance::updateRPC); } diff --git a/core/src/io/anuke/mindustry/core/ThreadHandler.java b/core/src/io/anuke/mindustry/core/ThreadHandler.java index e87203a1a9..c90a32131c 100644 --- a/core/src/io/anuke/mindustry/core/ThreadHandler.java +++ b/core/src/io/anuke/mindustry/core/ThreadHandler.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.core; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.Queue; import com.badlogic.gdx.utils.TimeUtils; import io.anuke.ucore.core.Timers; import io.anuke.ucore.util.Log; @@ -10,7 +10,7 @@ import static io.anuke.mindustry.Vars.control; import static io.anuke.mindustry.Vars.logic; public class ThreadHandler { - private final Array toRun = new Array<>(); + private final Queue toRun = new Queue<>(); private final ThreadProvider impl; private float delta = 1f; private float smoothDelta = 1f; @@ -33,7 +33,7 @@ public class ThreadHandler { public void run(Runnable r){ if(enabled) { synchronized (toRun) { - toRun.add(r); + toRun.addLast(r); } }else{ r.run(); @@ -51,7 +51,7 @@ public class ThreadHandler { public void runDelay(Runnable r){ if(enabled) { synchronized (toRun) { - toRun.add(r); + toRun.addLast(r); } }else{ Gdx.app.postRunnable(r); @@ -103,7 +103,7 @@ public class ThreadHandler { } public boolean doInterpolate(){ - return enabled && Math.abs(Gdx.graphics.getFramesPerSecond() - getTPS()) > 15; + return enabled && Gdx.graphics.getFramesPerSecond() - getTPS() > 20 && getTPS() < 30; } public boolean isOnThread(){ @@ -119,13 +119,12 @@ public class ThreadHandler { Runnable r; synchronized (toRun){ if(toRun.size > 0){ - r = toRun.pop(); + r = toRun.removeFirst(); }else{ - r = null; + break; } } - if(r == null) break; r.run(); } diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 2775aa3438..064377e7d3 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -542,7 +542,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra pointerY = vec.y; updateShooting(); - movement.limit(speed); + movement.limit(speed * Timers.delta()); if(getCarrier() == null){ velocity.add(movement); @@ -751,13 +751,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra public void write(DataOutput buffer) throws IOException { super.writeSave(buffer, !isLocal); buffer.writeUTF(name); //TODO writing strings is very inefficient - buffer.writeBoolean(isAdmin); + buffer.writeByte(Bits.toByte(isAdmin) | (Bits.toByte(dead) << 1) | (Bits.toByte(isBoosting) << 2)); buffer.writeInt(Color.rgba8888(color)); - buffer.writeBoolean(dead); buffer.writeByte(mech.id); - buffer.writeBoolean(isBoosting); buffer.writeInt(mining == null ? -1 : mining.packedPosition()); buffer.writeInt(spawner); + buffer.writeShort((short)(baseRotation * 2)); writeBuilding(buffer); } @@ -767,17 +766,19 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra float lastx = x, lasty = y, lastrot = rotation; super.readSave(buffer); name = buffer.readUTF(); - isAdmin = buffer.readBoolean(); + byte bools = buffer.readByte(); + isAdmin = (bools & 1) != 0; + dead = (bools & 2) != 0; + boolean boosting = (bools & 4) != 0; color.set(buffer.readInt()); - dead = buffer.readBoolean(); mech = Upgrade.getByID(buffer.readByte()); - boolean boosting = buffer.readBoolean(); int mine = buffer.readInt(); spawner = buffer.readInt(); + float baseRotation = buffer.readShort()/2f; readBuilding(buffer, !isLocal); - interpolator.read(lastx, lasty, x, y, time, rotation); + interpolator.read(lastx, lasty, x, y, time, rotation, baseRotation); rotation = lastrot; if(isLocal){ diff --git a/core/src/io/anuke/mindustry/net/Interpolator.java b/core/src/io/anuke/mindustry/net/Interpolator.java index 1c0d4735d6..ed983bbbf0 100644 --- a/core/src/io/anuke/mindustry/net/Interpolator.java +++ b/core/src/io/anuke/mindustry/net/Interpolator.java @@ -38,11 +38,12 @@ public class Interpolator { public void update(){ + /* if(pos.dst(target) > 128){ pos.set(target); lastUpdated = 0; updateSpacing = 16; - } + }*/ if(lastUpdated != 0 && updateSpacing != 0){ float timeSinceUpdate = TimeUtils.timeSinceMillis(lastUpdated);