mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-25 05:58:14 +07:00
Slightly more informative D/C messages
This commit is contained in:
parent
34df9cca2c
commit
528f5295c2
@ -118,6 +118,9 @@ confirmunadmin = Are you sure you want to remove admin status from this player?
|
||||
joingame.title = Join Game
|
||||
joingame.ip = Address:
|
||||
disconnect = Disconnected.
|
||||
disconnect.error = Connection error.
|
||||
disconnect.closed = Connection closed.
|
||||
disconnect.timeout = Timed out.
|
||||
disconnect.data = Failed to load world data!
|
||||
connecting = [accent]Connecting...
|
||||
connecting.data = [accent]Loading world data...
|
||||
|
@ -107,7 +107,17 @@ public class NetClient implements ApplicationListener{
|
||||
|
||||
Time.runTask(3f, ui.loadfrag::hide);
|
||||
|
||||
ui.showError("$disconnect");
|
||||
if(packet.reason != null){
|
||||
if(packet.reason.equals("closed")){
|
||||
ui.showSmall("$disconnect", "$disconnect.closed");
|
||||
}else if(packet.reason.equals("timeout")){
|
||||
ui.showSmall("$disconnect", "$disconnect.timeout");
|
||||
}else if(packet.reason.equals("error")){
|
||||
ui.showSmall("$disconnect", "$disconnect.error");
|
||||
}
|
||||
}else{
|
||||
ui.showError("$disconnect");
|
||||
}
|
||||
});
|
||||
|
||||
Net.handleClient(WorldStream.class, data -> {
|
||||
|
@ -76,7 +76,7 @@ public class NetServer implements ApplicationListener{
|
||||
Net.handleServer(Disconnect.class, (id, packet) -> {
|
||||
Player player = connections.get(id);
|
||||
if(player != null){
|
||||
onDisconnect(player);
|
||||
onDisconnect(player, packet.reason);
|
||||
}
|
||||
connections.remove(id);
|
||||
});
|
||||
@ -362,7 +362,7 @@ public class NetServer implements ApplicationListener{
|
||||
Log.debug("Packed {0} compressed bytes of world data.", stream.size());
|
||||
}
|
||||
|
||||
public static void onDisconnect(Player player){
|
||||
public static void onDisconnect(Player player, String reason){
|
||||
//singleplayer multiplayer wierdness
|
||||
if(player.con == null){
|
||||
player.remove();
|
||||
@ -375,7 +375,7 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
player.remove();
|
||||
netServer.connections.remove(player.con.id);
|
||||
Log.info("&lm[{1}] &lc{0} has disconnected.", player.name, player.uuid);
|
||||
Log.info("&lm[{1}] &lc{0} has disconnected. &lg&fi({2})", player.name, player.uuid, reason);
|
||||
}
|
||||
|
||||
private static float compound(float speed, float drag){
|
||||
@ -701,7 +701,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
if(connection == null || !connection.isConnected() || !connections.containsKey(connection.id)){
|
||||
//player disconnected, call d/c event
|
||||
onDisconnect(player);
|
||||
onDisconnect(player, "disappeared");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -360,6 +360,15 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showSmall(String titleText, String text){
|
||||
new Dialog(titleText, "dialog"){{
|
||||
cont.margin(10).add(text);
|
||||
titleTable.row();
|
||||
titleTable.addImage("whiteui").color(Pal.accent).height(3f).growX().pad(2f);
|
||||
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showConfirm(String title, String text, Runnable confirmed){
|
||||
showConfirm(title, text, null, confirmed);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public class Packets{
|
||||
|
||||
public static class Disconnect implements Packet{
|
||||
public int id;
|
||||
public String reason;
|
||||
|
||||
@Override
|
||||
public boolean isImportant(){
|
||||
|
@ -36,12 +36,13 @@ public class ArcNetClient implements ClientProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected(Connection connection){
|
||||
public void disconnected(Connection connection, DcReason reason){
|
||||
if(connection.getLastProtocolError() != null){
|
||||
netClient.setQuiet();
|
||||
}
|
||||
|
||||
Disconnect c = new Disconnect();
|
||||
c.reason = reason.toString();
|
||||
Core.app.post(() -> Net.handleClientReceived(c));
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,13 @@ public class ArcNetServer implements ServerProvider{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected(Connection connection){
|
||||
public void disconnected(Connection connection, DcReason reason){
|
||||
ArcConnection k = getByKryoID(connection.getID());
|
||||
if(k == null) return;
|
||||
|
||||
Disconnect c = new Disconnect();
|
||||
c.id = k.id;
|
||||
c.reason = reason.toString();
|
||||
|
||||
Core.app.post(() -> {
|
||||
Net.handleServerReceived(k.id, c);
|
||||
@ -159,7 +160,7 @@ public class ArcNetServer implements ServerProvider{
|
||||
}catch(Exception e){
|
||||
Log.err(e);
|
||||
Log.info("Error sending packet. Disconnecting invalid client!");
|
||||
connection.close();
|
||||
connection.close(DcReason.error);
|
||||
|
||||
ArcConnection k = getByKryoID(connection.getID());
|
||||
if(k != null) connections.remove(k);
|
||||
@ -168,7 +169,7 @@ public class ArcNetServer implements ServerProvider{
|
||||
|
||||
@Override
|
||||
public void close(){
|
||||
if(connection.isConnected()) connection.close();
|
||||
if(connection.isConnected()) connection.close(DcReason.closed);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user