Fixed mission-related messages being logged as errors, connection errors when fetching server lists are shown as message boxes instead of logging into the debug console

This commit is contained in:
Regalis
2017-05-17 19:27:41 +03:00
parent 9c1a76707f
commit 7f96873256
4 changed files with 16 additions and 23 deletions
+1 -1
View File
@@ -244,7 +244,7 @@ namespace Barotrauma
string header = index < headers.Count ? headers[index] : ""; string header = index < headers.Count ? headers[index] : "";
string message = index < messages.Count ? messages[index] : ""; string message = index < messages.Count ? messages[index] : "";
GameServer.Log("Mission info: " + header + " - " + message, ServerLog.MessageType.Error); GameServer.Log("Mission info: " + header + " - " + message, ServerLog.MessageType.ServerMessage);
new GUIMessageBox(header, message); new GUIMessageBox(header, message);
} }
@@ -30,8 +30,8 @@ namespace Barotrauma
var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400); var missionMsg = new GUIMessageBox(mission.Name, mission.Description, 400, 400);
missionMsg.UserData = "missionstartmessage"; missionMsg.UserData = "missionstartmessage";
Networking.GameServer.Log("Mission: " + mission.Name, Networking.ServerLog.MessageType.Error); Networking.GameServer.Log("Mission: " + mission.Name, Networking.ServerLog.MessageType.ServerMessage);
Networking.GameServer.Log(mission.Description, Networking.ServerLog.MessageType.Error); Networking.GameServer.Log(mission.Description, Networking.ServerLog.MessageType.ServerMessage);
} }
} }
} }
@@ -1,9 +1,7 @@
using System; using System;
using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking; using Barotrauma.Networking;
using System.IO;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
+11 -16
View File
@@ -139,7 +139,6 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(masterServerData)) if (string.IsNullOrWhiteSpace(masterServerData))
{ {
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", "", serverList); new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", "", serverList);
return; return;
} }
@@ -206,15 +205,8 @@ namespace Barotrauma
var request = new RestRequest("masterserver2.php", Method.GET); var request = new RestRequest("masterserver2.php", Method.GET);
request.AddParameter("gamename", "barotrauma"); // adds to POST or URL querystring based on Method request.AddParameter("gamename", "barotrauma");
request.AddParameter("action", "listservers"); // adds to POST or URL querystring based on Method request.AddParameter("action", "listservers");
// easily add HTTP Headers
//request.AddHeader("header", "value");
//// add files to upload (works with compatible verbs)
//request.AddFile(path);
// execute the request // execute the request
masterServerResponded = false; masterServerResponded = false;
@@ -227,7 +219,7 @@ namespace Barotrauma
{ {
serverList.ClearChildren(); serverList.ClearChildren();
restRequestHandle.Abort(); restRequestHandle.Abort();
DebugConsole.ThrowError("Couldn't connect to master server (request timed out)"); new GUIMessageBox("Connection error", "Couldn't connect to master server (request timed out).");
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
@@ -236,7 +228,7 @@ namespace Barotrauma
if (masterServerResponse.ErrorException != null) if (masterServerResponse.ErrorException != null)
{ {
serverList.ClearChildren(); serverList.ClearChildren();
DebugConsole.ThrowError("Error while connecting to master server", masterServerResponse.ErrorException); new GUIMessageBox("Connection error", "Error while connecting to master server {" + masterServerResponse.ErrorException + "}");
} }
else if (masterServerResponse.StatusCode != System.Net.HttpStatusCode.OK) else if (masterServerResponse.StatusCode != System.Net.HttpStatusCode.OK)
{ {
@@ -245,14 +237,17 @@ namespace Barotrauma
switch (masterServerResponse.StatusCode) switch (masterServerResponse.StatusCode)
{ {
case System.Net.HttpStatusCode.NotFound: case System.Net.HttpStatusCode.NotFound:
DebugConsole.ThrowError("Error while connecting to master server (404 - \"" + NetConfig.MasterServerUrl + "\" not found)"); new GUIMessageBox("Connection error",
"Error while connecting to master server (404 - \"" + NetConfig.MasterServerUrl + "\" not found)");
break; break;
case System.Net.HttpStatusCode.ServiceUnavailable: case System.Net.HttpStatusCode.ServiceUnavailable:
DebugConsole.ThrowError("Error while connecting to master server (505 - Service Unavailable)"); new GUIMessageBox("Connection error",
DebugConsole.ThrowError("The master server may be down for maintenance or temporarily overloaded. Please try again after in a few moments."); "Error while connecting to master server (505 - Service Unavailable) " +
"The master server may be down for maintenance or temporarily overloaded. Please try again after in a few moments.");
break; break;
default: default:
DebugConsole.ThrowError("Error while connecting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")"); new GUIMessageBox("Connection error",
"Error while connecting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")");
break; break;
} }
} }