diff --git a/build.gradle b/build.gradle index 8f52837553..adb7a5c3f1 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { appName = "Mindustry" gdxVersion = '1.9.8' aiVersion = '1.8.1' - uCoreVersion = '0eb75cc'; + uCoreVersion = 'd5ca764'; } repositories { diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 1bdeec41b7..3a83166a24 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -122,6 +122,10 @@ public class Pathfind{ //go through each spawnpoint, and if it's not found a path yet, update it for(SpawnPoint point : Vars.control.getSpawnPoints()){ + if(point.request == null){ + resetPathFor(point); + } + if(!point.request.pathFound){ try{ if(point.finder.search(point.request, maxTime)){ @@ -161,17 +165,21 @@ public class Pathfind{ /**Reset and clear the paths.*/ public void resetPaths(){ for(SpawnPoint point : Vars.control.getSpawnPoints()){ - point.finder = new OptimizedPathFinder<>(graph); - - point.path.clear(); - - point.pathTiles = null; - - point.request = new PathFinderRequest<>(point.start, Vars.control.getCore(), Vars.control.getDifficulty().heuristic, point.path); - point.request.statusChanged = true; //IMPORTANT! + resetPathFor(point); } } + private void resetPathFor(SpawnPoint point){ + point.finder = new OptimizedPathFinder<>(graph); + + point.path.clear(); + + point.pathTiles = null; + + point.request = new PathFinderRequest<>(point.start, Vars.control.getCore(), Vars.control.getDifficulty().heuristic, point.path); + point.request.statusChanged = true; //IMPORTANT! + } + /**For an enemy that was just loaded from a save, find the node in the path it should be following.*/ void findNode(Enemy enemy){ if(enemy.lane >= Vars.control.getSpawnPoints().size || enemy.lane < 0){ diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index fcb29d510f..e7c66c9499 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -291,6 +291,7 @@ public class NetClient extends Module { Net.disconnect(); GameState.set(State.menu); Vars.ui.showError("$text.server.kicked." + packet.reason.name()); + Vars.ui.loadfrag.hide(); }); Net.handle(WeaponSwitchPacket.class, packet -> { diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index fecf7afe3b..78dc8e902c 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -257,6 +257,7 @@ public class BlockRenderer{ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ Tile tile = world.tile(tilex, tiley); + if(tile == null) continue; if(floor){ if(!(tile.block() instanceof StaticBlock)){ tile.floor().draw(tile); diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index fce1b036a7..f7f663c910 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -6,8 +6,7 @@ import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.async.AsyncExecutor; import io.anuke.mindustry.Mindustry; -import io.anuke.mindustry.net.Packets.Connect; -import io.anuke.mindustry.net.Packets.Disconnect; +import io.anuke.mindustry.net.Packet.ImportantPacket; import io.anuke.mindustry.net.Packets.KickReason; import io.anuke.mindustry.net.Streamable.StreamBegin; import io.anuke.mindustry.net.Streamable.StreamBuilder; @@ -20,7 +19,7 @@ import io.anuke.ucore.function.Consumer; import java.io.IOException; public class Net{ - public static final int version = 12; + public static final int version = 13; private static boolean server; private static boolean active; @@ -152,7 +151,7 @@ public class Net{ handleClientReceived(builder.build()); } }else if(clientListeners.get(object.getClass()) != null){ - if(clientLoaded || object instanceof Connect || object instanceof Disconnect || object instanceof Streamable){ + if(clientLoaded || object instanceof ImportantPacket){ clientListeners.get(object.getClass()).accept(object); }else{ UCore.log("Recieved " + object, "but ignoring data, as client is not loaded."); diff --git a/core/src/io/anuke/mindustry/net/NetworkIO.java b/core/src/io/anuke/mindustry/net/NetworkIO.java index 1a48926dfd..c5424e966d 100644 --- a/core/src/io/anuke/mindustry/net/NetworkIO.java +++ b/core/src/io/anuke/mindustry/net/NetworkIO.java @@ -15,12 +15,10 @@ import io.anuke.mindustry.world.WorldGenerator; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.types.BlockPart; import io.anuke.mindustry.world.blocks.types.Rock; -import io.anuke.ucore.UCore; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entities; import java.io.*; -import java.nio.ByteBuffer; public class NetworkIO { diff --git a/core/src/io/anuke/mindustry/net/Packet.java b/core/src/io/anuke/mindustry/net/Packet.java index a2c0c6e1d3..fb53af86e4 100644 --- a/core/src/io/anuke/mindustry/net/Packet.java +++ b/core/src/io/anuke/mindustry/net/Packet.java @@ -5,4 +5,6 @@ import java.nio.ByteBuffer; public interface Packet { void read(ByteBuffer buffer); void write(ByteBuffer buffer); + + interface ImportantPacket{} } diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index af89163612..7fbf71f714 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.net; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.SyncEntity; +import io.anuke.mindustry.net.Packet.ImportantPacket; import io.anuke.mindustry.resource.Item; import java.nio.ByteBuffer; @@ -9,12 +10,12 @@ import java.nio.ByteBuffer; /**Class for storing all packets.*/ public class Packets { - public static class Connect{ + public static class Connect implements ImportantPacket{ public int id; public String addressTCP; } - public static class Disconnect { + public static class Disconnect implements ImportantPacket{ public int id; public String addressTCP; } @@ -382,7 +383,7 @@ public class Packets { } } - public static class KickPacket implements Packet{ + public static class KickPacket implements Packet, ImportantPacket{ public KickReason reason; @Override diff --git a/core/src/io/anuke/mindustry/net/Streamable.java b/core/src/io/anuke/mindustry/net/Streamable.java index e115dd5bfb..1d700b2087 100644 --- a/core/src/io/anuke/mindustry/net/Streamable.java +++ b/core/src/io/anuke/mindustry/net/Streamable.java @@ -2,13 +2,14 @@ package io.anuke.mindustry.net; import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.ReflectionException; +import io.anuke.mindustry.net.Packet.ImportantPacket; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.ByteBuffer; -public class Streamable{ +public class Streamable implements ImportantPacket{ public transient ByteArrayInputStream stream; /**Marks the beginning of a stream.*/ diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java index 8abc755f58..8b74b8c645 100644 --- a/kryonet/src/io/anuke/kryonet/KryoServer.java +++ b/kryonet/src/io/anuke/kryonet/KryoServer.java @@ -23,7 +23,6 @@ import io.anuke.mindustry.net.Streamable; import io.anuke.mindustry.net.Streamable.StreamBegin; import io.anuke.mindustry.net.Streamable.StreamChunk; import io.anuke.ucore.UCore; -import io.anuke.ucore.core.Timers; import org.java_websocket.WebSocket; import org.java_websocket.exceptions.WebsocketNotConnectedException; import org.java_websocket.handshake.ClientHandshake; @@ -125,7 +124,6 @@ public class KryoServer implements ServerProvider { p.reason = reason; con.send(p, SendMode.tcp); - Timers.runTask(1f, con::close); } @Override