From 2019196f65163bec31f52bc579708eb833f3f672 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 28 Sep 2019 18:01:55 -0400 Subject: [PATCH] Sort Steam server lists, ignore version when unimportant --- .../io/anuke/mindustry/ui/dialogs/JoinDialog.java | 4 +++- .../src/io/anuke/mindustry/desktop/steam/SNet.java | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index d8c7b33f7e..d6d579a787 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -202,11 +202,13 @@ public class JoinDialog extends FloatingDialog{ }else if(host.version > Version.build && Version.build != -1){ versionString = Core.bundle.get("server.outdated.client") + "\n" + Core.bundle.format("server.version", host.version, ""); + }else if(host.version == Version.build && Version.type.equals(host.versionType)){ + //not important + versionString = ""; }else{ versionString = Core.bundle.format("server.version", host.version, host.versionType); } - content.table(t -> { t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true); t.row(); diff --git a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java index c8bf159796..f6f9a6c3bf 100644 --- a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java +++ b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java @@ -7,14 +7,13 @@ import com.codedisaster.steamworks.SteamNetworking.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.function.*; -import io.anuke.arc.input.*; import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.*; import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.Version; import io.anuke.mindustry.game.*; -import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.ArcNetImpl.*; +import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Net.*; import io.anuke.mindustry.net.Packets.*; @@ -302,6 +301,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, Log.info("found {0} matches {1}", matches, lobbyDoneCallback); if(lobbyDoneCallback != null){ + Array hosts = new Array<>(); for(int i = 0; i < matches; i++){ try{ SteamID lobby = smat.getLobbyByIndex(i); @@ -316,13 +316,15 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, Gamemode.valueOf(smat.getLobbyData(lobby, "gamemode")), smat.getLobbyMemberLimit(lobby) ); - - lobbyCallback.accept(out); + hosts.add(out); }catch(Exception e){ Log.err(e); } } + hosts.sort(Structs.comparingInt(h -> -h.players)); + hosts.each(lobbyCallback); + lobbyDoneCallback.run(); } } @@ -344,7 +346,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, currentLobby = steamID; smat.setLobbyData(steamID, "name", player.name); - smat.setLobbyData(steamID, "mapname", world.getMap() == null ? "Unknown" : world.getMap().name()); + smat.setLobbyData(steamID, "mapname", world.getMap() == null ? "Unknown" : state.rules.zone == null ? world.getMap().name() : state.rules.zone.localizedName); smat.setLobbyData(steamID, "version", Version.build + ""); smat.setLobbyData(steamID, "versionType", Version.type); smat.setLobbyData(steamID, "wave", state.wave + "");