Fixed crash when connnecting, improved error messages
This commit is contained in:
@@ -47,6 +47,7 @@ public class NetClient extends Module {
|
||||
public NetClient(){
|
||||
|
||||
Net.handle(Connect.class, packet -> {
|
||||
Net.setClientLoaded(false);
|
||||
requests.clear();
|
||||
connecting = true;
|
||||
gotData = false;
|
||||
@@ -99,6 +100,7 @@ public class NetClient extends Module {
|
||||
|
||||
Net.send(new ConnectConfirmPacket(), SendMode.tcp);
|
||||
GameState.set(State.playing);
|
||||
Net.setClientLoaded(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -180,6 +180,10 @@ public class UI extends SceneModule{
|
||||
}
|
||||
|
||||
public void showError(String text){
|
||||
if(hasDialog()){
|
||||
Dialog dialog = scene.getScrollFocus() instanceof Dialog ? (Dialog)scene.getScrollFocus() : (Dialog)scene.getKeyboardFocus();
|
||||
dialog.hide();
|
||||
}
|
||||
new Dialog("$text.error.title", "dialog"){{
|
||||
content().margin(15).add(text);
|
||||
buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4);
|
||||
|
||||
@@ -51,6 +51,10 @@ public class Saves {
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if(GameState.is(State.menu)){
|
||||
current = null;
|
||||
}
|
||||
|
||||
if(!GameState.is(State.menu) && !Vars.control.isGameOver() && current != null && current.isAutosave()){
|
||||
time += Timers.delta();
|
||||
if(time > Settings.getInt("saveinterval")*60) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class HostDialog extends FloatingDialog{
|
||||
Vars.player.name = text;
|
||||
Settings.put("name", text);
|
||||
Settings.save();
|
||||
Vars.ui.listfrag.rebuild();
|
||||
}).grow().pad(8);
|
||||
}).width(w).height(70f).pad(4);
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ public class Sorter extends Junction{
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
Tile to = getTileTarget(item, tile, source, true);
|
||||
|
||||
Timers.run(15, ()->{
|
||||
if(to == null || to.entity == null) return;
|
||||
Timers.run(15, () -> {
|
||||
to.block().handleItem(item, to, tile);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user