From c0d50c2ac1dc327c7511d819d993e8e9aa7332cd Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 4 May 2013 22:03:15 +1200 Subject: [PATCH] Remove server pinging. --- OpenRA.Game/Network/GameServer.cs | 28 ----------- .../Widgets/Logic/ServerBrowserLogic.cs | 47 +------------------ mods/ra/chrome/serverbrowser.yaml | 13 ----- 3 files changed, 1 insertion(+), 87 deletions(-) diff --git a/OpenRA.Game/Network/GameServer.cs b/OpenRA.Game/Network/GameServer.cs index d2cf4c918a..e355b325e3 100644 --- a/OpenRA.Game/Network/GameServer.cs +++ b/OpenRA.Game/Network/GameServer.cs @@ -67,33 +67,5 @@ namespace OpenRA.Network return UsefulMods.All(m => Game.CurrentMods.ContainsKey(m.Key) && AreVersionsCompatible(m.Value, Game.CurrentMods[m.Key].Version)); } - - public int Latency = -1; - bool hasBeenPinged; - public void Ping() - { - if (!hasBeenPinged) - { - hasBeenPinged = true; - var pingSender = new Ping(); - pingSender.PingCompleted += new PingCompletedEventHandler(pongRecieved); - AutoResetEvent waiter = new AutoResetEvent(false); - pingSender.SendAsync(Address.Split(':')[0], waiter); - } - } - - void pongRecieved(object sender, PingCompletedEventArgs e) - { - if (e.Cancelled || e.Error != null) - Latency = -1; - else - { - PingReply pong = e.Reply; - if (pong != null && pong.Status == IPStatus.Success) - Latency = (int)pong.RoundtripTime; - else - Latency = -1; - } - } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index 124375c205..462791e7f2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic Action OpenLobby; Action OnExit; - enum SearchStatus { Fetching, Failed, NoGames, Hidden, Pinging } + enum SearchStatus { Fetching, Failed, NoGames, Hidden } SearchStatus searchStatus = SearchStatus.Fetching; bool showWaiting = true; @@ -41,7 +41,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic case SearchStatus.Fetching: return "Fetching game list..."; case SearchStatus.Failed: return "Failed to contact master server."; case SearchStatus.NoGames: return "No games found."; - case SearchStatus.Pinging: return "Pinging compatible servers."; default: return ""; } } @@ -59,14 +58,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games)); - var pingButton = panel.GetOrNull("PING_BUTTON"); - if (pingButton != null) - { - pingButton.IsDisabled = () => searchStatus == SearchStatus.Pinging || - searchStatus == SearchStatus.Fetching || searchStatus == SearchStatus.Failed; - pingButton.OnClick = () => ServerList.Query(games => PingServerList(panel, games)); - } - var join = panel.Get("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => Join(currentServer); @@ -169,33 +160,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic return s.UsefulMods.Select(m => GenerateModLabel(m)).JoinWith("\n"); } - static string GetPing(GameServer s) - { - if (s.Latency > -1) - return "Ping: {0} ms".F(s.Latency); - else - return "Ping: ? ms"; - } - - void PingServerList(Widget panel, IEnumerable games) - { - searchStatus = SearchStatus.Pinging; - - foreach (var loop in games.Where(g => g.CanJoin())) - { - var game = loop; - - if (game == null) - continue; - - game.Ping(); - } - - searchStatus = SearchStatus.Hidden; - - RefreshServerList(panel, games); - } - bool Filtered(GameServer game) { if ((game.State == (int)ServerState.GameStarted) && !showStarted) @@ -274,13 +238,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic version.GetText = () => GenerateModsLabel(game); version.IsVisible = () => !game.CompatibleVersion(); - var ping = item.GetOrNull("PING"); - if (ping != null) - { - ping.GetText = () => GetPing(game); - ping.IsVisible = () => game.CompatibleVersion(); - } - if (!canJoin) { title.GetColor = () => Color.Gray; @@ -289,8 +246,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic state.GetColor = () => Color.Gray; ip.GetColor = () => Color.Gray; version.GetColor = () => Color.Gray; - if (ping != null) - ping.GetColor = () => Color.Gray; } if (!Filtered(game)) diff --git a/mods/ra/chrome/serverbrowser.yaml b/mods/ra/chrome/serverbrowser.yaml index 18ce40484d..3cb8de0884 100644 --- a/mods/ra/chrome/serverbrowser.yaml +++ b/mods/ra/chrome/serverbrowser.yaml @@ -95,12 +95,6 @@ Background@JOINSERVER_BG: Y:40 Align:Right Height:25 - Label@PING: - Width:140 - X:PARENT_RIGHT-150 - Y:40 - Align:Right - Height:25 Label@PROGRESS_LABEL: X:(PARENT_RIGHT - WIDTH) / 2 Y:PARENT_BOTTOM / 2 - HEIGHT @@ -115,13 +109,6 @@ Background@JOINSERVER_BG: Height:25 Text:Refresh Font:Bold - Button@PING_BUTTON: - X:140 - Y:PARENT_BOTTOM - 45 - Width:100 - Height:25 - Text:Ping - Font:Bold Button@JOIN_BUTTON: X:PARENT_RIGHT - 140 - 130 Y:PARENT_BOTTOM - 45