diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 60e1fe6986..2df2ef14c4 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -41,12 +41,14 @@ import static io.anuke.mindustry.Vars.*; public class NetClient extends Module { private final static float dataTimeout = 60*18; //18 seconds timeout private final static float playerSyncTime = 2; + private final static int maxRequests = 50; private Timer timer = new Timer(5); private boolean connecting = false; private boolean kicked = false; private IntSet recieved = new IntSet(); private IntMap recent = new IntMap<>(); + private int requests = 0; private float timeoutTime = 0f; //data timeout counter public NetClient(){ @@ -137,11 +139,12 @@ public class NetClient extends Module { if(entity instanceof Enemy) enemies ++; if (entity == null || id == player.id) { - if (id != player.id) { + if (id != player.id && requests < maxRequests) { EntityRequestPacket req = new EntityRequestPacket(); req.id = id; req.group = groupid; Net.send(req, SendMode.udp); + requests ++; } data.position(data.position() + SyncEntity.getWriteSize((Class) group.getType())); } else { @@ -362,6 +365,7 @@ public class NetClient extends Module { } void sync(){ + requests = 0; if(timer.get(0, playerSyncTime)){ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 2e49c7db94..dbd1d3cb20 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -267,15 +267,15 @@ public class Renderer extends RendererModule{ if(!player.isLocal && !player.isDead()){ layout.setText(Core.font, player.name); Draw.color(0f, 0f, 0f, 0.3f); - Draw.rect("blank", player.x, player.y + 8 - layout.height/2, layout.width + 2, layout.height + 2); + Draw.rect("blank", player.getDrawPosition().x, player.getDrawPosition().y + 8 - layout.height/2, layout.width + 2, layout.height + 2); Draw.color(); Draw.tcolor(player.getColor()); - Draw.text(player.name, player.x, player.y + 8); + Draw.text(player.name, player.getDrawPosition().x, player.getDrawPosition().y + 8); if(player.isAdmin){ Draw.color(player.getColor()); float s = 3f; - Draw.rect("icon-admin-small", player.x + layout.width/2f + 2 + 1, player.y + 7f, s, s); + Draw.rect("icon-admin-small", player.getDrawPosition().x + layout.width/2f + 2 + 1, player.getDrawPosition().y + 7f, s, s); } Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/entities/SyncEntity.java b/core/src/io/anuke/mindustry/entities/SyncEntity.java index 21f3000a24..f24186e66b 100644 --- a/core/src/io/anuke/mindustry/entities/SyncEntity.java +++ b/core/src/io/anuke/mindustry/entities/SyncEntity.java @@ -122,6 +122,8 @@ public abstract class SyncEntity extends DestructibleEntity{ time += 1f / spacing * Math.min(Timers.delta(), 1f); + time = Mathf.clamp(time, 0, 2f); + Mathf.lerp2(pos.set(last), target, time); angle = Mathf.slerpDelta(angle, targetrot, 0.6f); diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 5c5630aeaf..106ac056bd 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -162,7 +162,7 @@ public class Packets { public int color; } - public static class ShootPacket implements Packet{ + public static class ShootPacket implements Packet, UnimportantPacket{ public byte weaponid; public float x, y, rotation; public int playerid; @@ -186,7 +186,7 @@ public class Packets { } } - public static class BulletPacket implements Packet{ + public static class BulletPacket implements Packet, UnimportantPacket{ public int type, owner; public float x, y, angle; public short damage; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidJunction.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidJunction.java index e604e8c5af..55fa80fab5 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidJunction.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidJunction.java @@ -3,7 +3,6 @@ package io.anuke.mindustry.world.blocks.types.distribution; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.LiquidBlock; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; public class LiquidJunction extends Conduit{ @@ -26,10 +25,8 @@ public class LiquidJunction extends Conduit{ dir = (dir+4)%4; Tile to = tile.getNearby(dir); - Timers.run(20f, () -> { - if(to.block() instanceof LiquidBlock && ((LiquidBlock)to.block()).acceptLiquid(to, tile, liquid, amount)) - ((LiquidBlock)to.block()).handleLiquid(to, tile, liquid, amount); - }); + if(to.block() instanceof LiquidBlock && ((LiquidBlock)to.block()).acceptLiquid(to, tile, liquid, amount)) + ((LiquidBlock)to.block()).handleLiquid(to, tile, liquid, amount); } @Override diff --git a/kryonet/src/io/anuke/kryonet/KryoClient.java b/kryonet/src/io/anuke/kryonet/KryoClient.java index d9f25b830e..2e220d1bdd 100644 --- a/kryonet/src/io/anuke/kryonet/KryoClient.java +++ b/kryonet/src/io/anuke/kryonet/KryoClient.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.ObjectSet; import com.esotericsoftware.kryonet.*; import com.esotericsoftware.kryonet.Listener.LagListener; +import com.esotericsoftware.minlog.Log; import io.anuke.mindustry.net.Host; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net.ClientProvider; @@ -70,6 +71,7 @@ public class KryoClient implements ClientProvider{ Disconnect c = new Disconnect(); Gdx.app.postRunnable(() -> Net.handleClientReceived(c)); + if(connection.getLastProtocolError() != null) Log.error("\n\n\n\nProtocol error: " + connection.getLastProtocolError() + "\n\n\n\n"); } @Override @@ -80,6 +82,7 @@ public class KryoClient implements ClientProvider{ try{ Net.handleClientReceived(object); }catch (Exception e){ + e.printStackTrace(); if(e instanceof KryoNetException && e.getMessage() != null && e.getMessage().toLowerCase().contains("incorrect")) { Net.showError("$text.server.mismatch"); netClient.disconnectQuietly(); @@ -159,11 +162,7 @@ public class KryoClient implements ClientProvider{ ByteBuffer buffer = ByteBuffer.wrap(packet.getData()); Host host = NetworkIO.readServerData(packet.getAddress().getHostAddress(), buffer); - if (host != null) { - Gdx.app.postRunnable(() -> valid.accept(host)); - } else { - Gdx.app.postRunnable(() -> invalid.accept(new IOException("Outdated server."))); - } + Gdx.app.postRunnable(() -> valid.accept(host)); } catch (Exception e) { Gdx.app.postRunnable(() -> invalid.accept(e)); }