aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/masterserver/masterserver.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-11-20 23:54:07 +0000
committerGitHub <noreply@github.com>2023-11-21 00:54:07 +0100
commit86c20013c85fd70370044d4a13e45436fb5f7069 (patch)
tree38ac6ba514970b9141cb8a7d193b2a8ae7d007ad /NorthstarDLL/masterserver/masterserver.cpp
parent407bcc764731cae00e29c6a00d23ec01fb588d0b (diff)
downloadNorthstarLauncher-86c20013c85fd70370044d4a13e45436fb5f7069.tar.gz
NorthstarLauncher-86c20013c85fd70370044d4a13e45436fb5f7069.zip
Don't log masterserver registration errors in the lobby (#543)
The main purpose of this PR is to not flood the console with errors that aren't really errors, thus preventing various tickets or misleading users.
Diffstat (limited to 'NorthstarDLL/masterserver/masterserver.cpp')
-rw-r--r--NorthstarDLL/masterserver/masterserver.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/NorthstarDLL/masterserver/masterserver.cpp b/NorthstarDLL/masterserver/masterserver.cpp
index 64f172c9..21b76f73 100644
--- a/NorthstarDLL/masterserver/masterserver.cpp
+++ b/NorthstarDLL/masterserver/masterserver.cpp
@@ -8,6 +8,7 @@
#include "shared/misccommands.h"
#include "util/version.h"
#include "server/auth/bansystem.h"
+#include "dedicated/dedicated.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
@@ -1128,7 +1129,9 @@ void MasterServerPresenceReporter::RunFrame(double flCurrentTime, const ServerPr
if (m_nNumRegistrationAttempts >= MAX_REGISTRATION_ATTEMPTS)
{
- spdlog::error("Reached max ms server registration attempts.");
+ spdlog::log(
+ IsDedicatedServer() ? spdlog::level::level_enum::err : spdlog::level::level_enum::warn,
+ "Reached max ms server registration attempts.");
}
}
else if (updateServerFuture.valid())
@@ -1181,7 +1184,7 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
addServerFuture = std::async(
std::launch::async,
- [threadedPresence, modInfo, hostname]
+ [threadedPresence, modInfo, hostname, pServerPresence]
{
CURL* curl = curl_easy_init();
SetCommonHttpClientOptions(curl);
@@ -1209,6 +1212,11 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
return data;
};
+ // don't log errors if we wouldn't actually show up in the server list anyway (stop tickets)
+ // except for dedis, for which this error logging is actually pretty important
+ bool shouldLogError = IsDedicatedServer() || (!strstr(pServerPresence->m_MapName, "mp_lobby") &&
+ strstr(pServerPresence->m_PlaylistName, "private_match"));
+
curl_mime_data(part, modInfo.c_str(), modInfo.size());
curl_mime_name(part, "modinfo");
curl_mime_filename(part, "modinfo.json");
@@ -1258,22 +1266,27 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
// No retry.
if (serverAddedJson.HasParseError())
{
- spdlog::error(
- "Failed reading masterserver authentication response: encountered parse error \"{}\"",
- rapidjson::GetParseError_En(serverAddedJson.GetParseError()));
+ if (shouldLogError)
+ spdlog::error(
+ "Failed reading masterserver authentication response: encountered parse error \"{}\"",
+ rapidjson::GetParseError_En(serverAddedJson.GetParseError()));
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}
if (!serverAddedJson.IsObject())
{
- spdlog::error("Failed reading masterserver authentication response: root object is not an object");
+ if (shouldLogError)
+ spdlog::error("Failed reading masterserver authentication response: root object is not an object");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}
if (serverAddedJson.HasMember("error"))
{
- spdlog::error("Failed reading masterserver response: got fastify error response");
- spdlog::error(readBuffer);
+ if (shouldLogError)
+ {
+ spdlog::error("Failed reading masterserver response: got fastify error response");
+ spdlog::error(readBuffer);
+ }
// If this is DUPLICATE_SERVER, we'll retry adding the server every 20 seconds.
// The master server will only update its internal server list and clean up dead servers on certain events.
@@ -1282,7 +1295,8 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
if (serverAddedJson["error"].HasMember("enum") &&
strcmp(serverAddedJson["error"]["enum"].GetString(), "DUPLICATE_SERVER") == 0)
{
- spdlog::error("Cooling down while the master server cleans the dead server entry, if any.");
+ if (shouldLogError)
+ spdlog::error("Cooling down while the master server cleans the dead server entry, if any.");
return ReturnCleanup(MasterServerReportPresenceResult::FailedDuplicateServer);
}
@@ -1292,14 +1306,16 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
if (!serverAddedJson["success"].IsTrue())
{
- spdlog::error("Adding server to masterserver failed: \"success\" is not true");
+ if (shouldLogError)
+ spdlog::error("Adding server to masterserver failed: \"success\" is not true");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}
if (!serverAddedJson.HasMember("id") || !serverAddedJson["id"].IsString() ||
!serverAddedJson.HasMember("serverAuthToken") || !serverAddedJson["serverAuthToken"].IsString())
{
- spdlog::error("Failed reading masterserver response: malformed json object");
+ if (shouldLogError)
+ spdlog::error("Failed reading masterserver response: malformed json object");
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoRetry);
}
@@ -1311,7 +1327,8 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
}
else
{
- spdlog::error("Failed adding self to server list: error {}", curl_easy_strerror(result));
+ if (shouldLogError)
+ spdlog::error("Failed adding self to server list: error {}", curl_easy_strerror(result));
return ReturnCleanup(MasterServerReportPresenceResult::FailedNoConnect);
}
});