From a5e869ccd0656059c3a60f9a42074cd00a2697e3 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 17:39:59 +0300 Subject: [PATCH] (cae84e234) Translate Lidgren's "no response from remote host" error message --- .../Source/Networking/GameClient.cs | 16 +++++-- .../Source/Screens/ServerListScreen.cs | 16 ------- .../BarotraumaShared/Source/GameSettings.cs | 48 +++++++++++++++++++ .../NetConnection.Handshake.cs | 4 +- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 5807af85a..9215d7d70 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -903,7 +903,7 @@ namespace Barotrauma.Networking connected = false; ConnectToServer(serverIP); } - else + if (clientID == myID) { string msg = ""; if (disconnectReason == DisconnectReason.Unknown) @@ -921,8 +921,18 @@ namespace Barotrauma.Networking msg += TextManager.GetServerMessage(splitMsg[i]); } } - var msgBox = new GUIMessageBox(TextManager.Get(allowReconnect ? "ConnectionLost" : "CouldNotConnectToServer"), msg); - msgBox.Buttons[0].OnClicked += ReturnToServerList; + + if (msg == NetConnection.NoResponseMessage) + { + //display a generic "could not connect" popup if the message is Lidgren's "failed to establish connection" + var msgBox = new GUIMessageBox(TextManager.Get("ConnectionFailed"), TextManager.Get(allowReconnect ? "ConnectionLost" : "CouldNotConnectToServer")); + msgBox.Buttons[0].OnClicked += ReturnToServerList; + } + else + { + var msgBox = new GUIMessageBox(TextManager.Get(allowReconnect ? "ConnectionLost" : "CouldNotConnectToServer"), msg); + msgBox.Buttons[0].OnClicked += ReturnToServerList; + } } } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 1f146ab06..0344ba7c1 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -218,22 +218,6 @@ namespace Barotrauma return true; } - private bool RefreshJoinButtonState(GUIComponent component, object obj) - { - if (obj == null || waitingForRefresh) { return false; } - - if (!string.IsNullOrWhiteSpace(clientNameBox.Text) && !string.IsNullOrWhiteSpace(ipBox.Text)) - { - joinButton.Enabled = true; - } - else - { - joinButton.Enabled = false; - } - - return true; - } - private bool SelectServer(GUIComponent component, object obj) { if (obj == null || waitingForRefresh) { return false; } diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 9c026094d..9a3654bc8 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -821,6 +821,54 @@ namespace Barotrauma VoiceSetting = voiceSetting; } } + if (!SelectedContentPackages.Any()) + { + var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage); + if (availablePackage != null) + { + SelectedContentPackages.Add(availablePackage); + } + } + + //save to get rid of the invalid selected packages in the config file + if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); } + } + #endregion + + #region Save DefaultConfig + private void SaveNewDefaultConfig() + { + XDocument doc = new XDocument(); + + if (doc.Root == null) + { + doc.Add(new XElement("config")); + } + + doc.Root.Add( + new XAttribute("language", TextManager.Language), + new XAttribute("masterserverurl", MasterServerUrl), + new XAttribute("autocheckupdates", AutoCheckUpdates), + new XAttribute("musicvolume", musicVolume), + new XAttribute("soundvolume", soundVolume), + new XAttribute("voicechatvolume", voiceChatVolume), + new XAttribute("verboselogging", VerboseLogging), + new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), + new XAttribute("enablesplashscreen", EnableSplashScreen), + new XAttribute("usesteammatchmaking", useSteamMatchmaking), + new XAttribute("quickstartsub", QuickStartSubmarineName), + new XAttribute("requiresteamauthentication", requireSteamAuthentication), + new XAttribute("aimassistamount", aimAssistAmount)); + + if (!ShowUserStatisticsPrompt) + { + doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics)); + } + + if (WasGameUpdated) + { + doc.Root.Add(new XAttribute("wasgameupdated", true)); + } useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking); requireSteamAuthentication = doc.Root.GetAttributeBool("requiresteamauthentication", requireSteamAuthentication); diff --git a/Libraries/Lidgren.Network/NetConnection.Handshake.cs b/Libraries/Lidgren.Network/NetConnection.Handshake.cs index c84605741..d19787100 100644 --- a/Libraries/Lidgren.Network/NetConnection.Handshake.cs +++ b/Libraries/Lidgren.Network/NetConnection.Handshake.cs @@ -11,6 +11,8 @@ namespace Lidgren.Network { public partial class NetConnection { + public const string NoResponseMessage = "Failed to establish connection - no response from remote host"; + internal bool m_connectRequested; internal bool m_disconnectRequested; internal bool m_disconnectReqSendBye; @@ -69,7 +71,7 @@ namespace Lidgren.Network if (m_handshakeAttempts >= m_peerConfiguration.m_maximumHandshakeAttempts) { // failed to connect - ExecuteDisconnect("Failed to establish connection - no response from remote host", true); + ExecuteDisconnect(NoResponseMessage, true); return; }