Sort Steam server lists, ignore version when unimportant

This commit is contained in:
Anuken
2019-09-28 18:01:55 -04:00
parent a815763833
commit 2019196f65
2 changed files with 10 additions and 6 deletions

View File

@@ -202,11 +202,13 @@ public class JoinDialog extends FloatingDialog{
}else if(host.version > Version.build && Version.build != -1){ }else if(host.version > Version.build && Version.build != -1){
versionString = Core.bundle.get("server.outdated.client") + "\n" + versionString = Core.bundle.get("server.outdated.client") + "\n" +
Core.bundle.format("server.version", host.version, ""); Core.bundle.format("server.version", host.version, "");
}else if(host.version == Version.build && Version.type.equals(host.versionType)){
//not important
versionString = "";
}else{ }else{
versionString = Core.bundle.format("server.version", host.version, host.versionType); versionString = Core.bundle.format("server.version", host.version, host.versionType);
} }
content.table(t -> { content.table(t -> {
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true); t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
t.row(); t.row();

View File

@@ -7,14 +7,13 @@ import com.codedisaster.steamworks.SteamNetworking.*;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
import io.anuke.arc.function.*; import io.anuke.arc.function.*;
import io.anuke.arc.input.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.arc.util.pooling.*; import io.anuke.arc.util.pooling.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.Version; import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.ArcNetImpl.*; import io.anuke.mindustry.net.ArcNetImpl.*;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Net.*; import io.anuke.mindustry.net.Net.*;
import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.net.Packets.*;
@@ -302,6 +301,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
Log.info("found {0} matches {1}", matches, lobbyDoneCallback); Log.info("found {0} matches {1}", matches, lobbyDoneCallback);
if(lobbyDoneCallback != null){ if(lobbyDoneCallback != null){
Array<Host> hosts = new Array<>();
for(int i = 0; i < matches; i++){ for(int i = 0; i < matches; i++){
try{ try{
SteamID lobby = smat.getLobbyByIndex(i); SteamID lobby = smat.getLobbyByIndex(i);
@@ -316,13 +316,15 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
Gamemode.valueOf(smat.getLobbyData(lobby, "gamemode")), Gamemode.valueOf(smat.getLobbyData(lobby, "gamemode")),
smat.getLobbyMemberLimit(lobby) smat.getLobbyMemberLimit(lobby)
); );
hosts.add(out);
lobbyCallback.accept(out);
}catch(Exception e){ }catch(Exception e){
Log.err(e); Log.err(e);
} }
} }
hosts.sort(Structs.comparingInt(h -> -h.players));
hosts.each(lobbyCallback);
lobbyDoneCallback.run(); lobbyDoneCallback.run();
} }
} }
@@ -344,7 +346,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
currentLobby = steamID; currentLobby = steamID;
smat.setLobbyData(steamID, "name", player.name); 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, "version", Version.build + "");
smat.setLobbyData(steamID, "versionType", Version.type); smat.setLobbyData(steamID, "versionType", Version.type);
smat.setLobbyData(steamID, "wave", state.wave + ""); smat.setLobbyData(steamID, "wave", state.wave + "");