From 552dc254dacd2eece87d74aa9e8b91c7d7f83389 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 21 Sep 2019 23:41:56 -0400 Subject: [PATCH] spgashfetiti --- .../mindustry/ui/dialogs/PausedDialog.java | 4 +- .../mindustry/desktop/DesktopLauncher.java | 2 +- .../anuke/mindustry/desktop/steam/SNet.java | 40 ++++++++++++++----- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index 75edf6df92..4937287922 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -58,7 +58,7 @@ public class PausedDialog extends FloatingDialog{ cont.row(); cont.addButton("$hostserver", () -> { - if(net.active() && steam){ + if(net.server() && steam){ platform.inviteFriends(); }else{ if(steam){ @@ -67,7 +67,7 @@ public class PausedDialog extends FloatingDialog{ ui.host.show(); } } - }).disabled(b -> net.active() && !steam).colspan(2).width(dw * 2 + 20f).update(e -> e.setText(net.active() && steam && net.server() ? "$invitefriends" : "$hostserver")); + }).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 20f).update(e -> e.setText(net.server() && steam ? "$invitefriends" : "$hostserver")); } cont.row(); diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index c253ed3a03..d215e28d9c 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -143,7 +143,7 @@ public class DesktopLauncher extends ClientLauncher{ SVars.user = new SUser(); Events.on(ClientLoadEvent.class, event -> { - player.name = "ffmpeg";//SVars.net.friends.getPersonaName(); + player.name = SVars.net.friends.getPersonaName(); Core.settings.defaults("name", SVars.net.friends.getPersonaName()); Core.settings.put("name", player.name); Core.settings.save(); diff --git a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java index 6c5d608980..c45e04c8a8 100644 --- a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java +++ b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java @@ -61,20 +61,31 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, if(net.server()){ SteamConnection con = steamConnections.get(fromID); - //accept users on request - if(con == null){ - con = new SteamConnection(from); - Connect c = new Connect(); - c.addressTCP = "steam:" + from.getAccountID(); + try{ + //accept users on request + if(con == null){ + con = new SteamConnection(from); + Connect c = new Connect(); + c.addressTCP = "steam:" + from.getAccountID(); - Log.info("&bRecieved connection: {0}", c.addressTCP); + Log.info("&bRecieved connection: {0}", c.addressTCP); - steamConnections.put(from.getAccountID(), con); - connections.add(con); - net.handleServerReceived(con, c); + steamConnections.put(from.getAccountID(), con); + connections.add(con); + net.handleServerReceived(con, c); + } + + net.handleServerReceived(con, output); + }catch(RuntimeException e){ + if(e.getCause() instanceof ValidateException){ + ValidateException v = (ValidateException)e.getCause(); + Log.err("Validation failed: {0} ({1})", v.player.name, v.getMessage()); + }else{ + Log.err(e); + } + }catch(Exception e){ + Log.err(e); } - - net.handleServerReceived(con, output); }else if(currentServer != null && fromID == currentServer.getAccountID()){ net.handleClientReceived(output); } @@ -169,6 +180,8 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, public void hostServer(int port) throws IOException{ provider.hostServer(port); smat.createLobby(Core.settings.getBool("publichost") ? LobbyType.Public : LobbyType.FriendsOnly, 16); + + Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> Log.info("Server: {0}\nClient: {1}\nActive: {2}", net.server(), net.client(), net.active())))); } public void updateLobby(){ @@ -237,6 +250,8 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, currentLobby = steamIDLobby; currentServer = smat.getLobbyOwner(steamIDLobby); + Log.info("Connect to {0}"); + if(joinCallback != null){ joinCallback.run(); joinCallback = null; @@ -247,6 +262,8 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, net.setClientConnected(); net.handleClientReceived(con); + + Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> Log.info("Server: {0}\nClient: {1}\nActive: {2}", net.server(), net.client(), net.active())))); } @Override @@ -421,6 +438,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, public SteamConnection(SteamID sid){ super(sid.getAccountID() + ""); this.sid = sid; + Log.info("Create STEAM client {0}", sid.getAccountID()); } @Override