Fixed crash when connnecting, improved error messages

This commit is contained in:
Anuken
2018-01-12 20:03:52 -05:00
parent 77d8464623
commit 5e2173fc54
10 changed files with 52 additions and 12 deletions
+6 -1
View File
@@ -18,6 +18,7 @@ import java.io.IOException;
public class Net{
private static boolean server;
private static boolean active;
private static boolean clientLoaded;
private static ObjectMap<Class<?>, Consumer> clientListeners = new ObjectMap<>();
private static ObjectMap<Class<?>, Consumer> serverListeners = new ObjectMap<>();
private static ClientProvider clientProvider;
@@ -26,6 +27,10 @@ public class Net{
private static int lastConnection = -1;
private static IntMap<StreamBuilder> streams = new IntMap<>();
private static AsyncExecutor executor = new AsyncExecutor(4);
public static void setClientLoaded(boolean loaded){
clientLoaded = loaded;
}
/**Connect to an address.*/
public static void connect(String ip, int port) throws IOException{
@@ -141,7 +146,7 @@ public class Net{
handleClientReceived(builder.build());
}
}else if(clientListeners.get(object.getClass()) != null){
clientListeners.get(object.getClass()).accept(object);
if(clientLoaded) clientListeners.get(object.getClass()).accept(object);
}else{
Gdx.app.error("Mindustry::Net", "Unhandled packet type: '" + object.getClass() + "'!");
}
@@ -7,7 +7,6 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.net.Streamable.StreamBegin;
import io.anuke.mindustry.net.Streamable.StreamChunk;
import io.anuke.mindustry.resource.Mech;
import io.anuke.ucore.entities.Entity;
public class Registrator {
@@ -47,15 +46,11 @@ public class Registrator {
int[].class,
int[][].class,
Entity[].class,
Player[].class,
Array.class,
Vector2.class,
EnemySpawnPacket[].class,
Entity.class,
Player.class,
Mech.class,
Enemy.class
};
}