From c488ea907ce56e3d52e7bd02a082b2fd1fe1a205 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sat, 25 Dec 2021 00:39:08 +0000 Subject: fix a bug with launcher not showing servers --- NorthstarDedicatedTest/masterserver.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'NorthstarDedicatedTest') diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp index e9cf043a..69a27454 100644 --- a/NorthstarDedicatedTest/masterserver.cpp +++ b/NorthstarDedicatedTest/masterserver.cpp @@ -185,13 +185,11 @@ void MasterServerManager::RequestServerList() } // todo: verify json props are fine before adding to m_remoteServers - if (!serverObj.HasMember("id") || !serverObj["id"].IsString() || !serverObj.HasMember("name") || !serverObj["name"].IsString() || !serverObj.HasMember("description") || !serverObj["description"].IsString() || !serverObj.HasMember("map") || !serverObj["map"].IsString() || !serverObj.HasMember("playlist") || !serverObj["playlist"].IsString() - || !serverObj.HasMember("playerCount") || !serverObj["playerCount"].IsNumber() || !serverObj.HasMember("maxPlayers") || !serverObj["maxPlayers"].IsNumber() || !serverObj.HasMember("hasPassword") || !serverObj["hasPassword"].IsBool() || !serverObj.HasMember("modInfo") || !serverObj["modInfo"].HasMember("Mods") || !serverObj["modInfo"]["Mods"].IsArray() ) @@ -200,6 +198,12 @@ void MasterServerManager::RequestServerList() goto REQUEST_END_CLEANUP; } + int playerCount = 0; + if (!serverObj.HasMember("playerCount") || !serverObj["playerCount"].IsNumber()) + playerCount = 0; + else + playerCount = serverObj["playerCount"].GetInt(); + const char* id = serverObj["id"].GetString(); RemoteServerInfo* newServer = nullptr; @@ -210,7 +214,7 @@ void MasterServerManager::RequestServerList() // if server already exists, update info rather than adding to it if (!strncmp((const char*)server.id, id, 32)) { - server = RemoteServerInfo(id, serverObj["name"].GetString(), serverObj["description"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), serverObj["playerCount"].GetInt(), serverObj["maxPlayers"].GetInt(), serverObj["hasPassword"].IsTrue()); + server = RemoteServerInfo(id, serverObj["name"].GetString(), serverObj["description"].GetString(), serverObj["map"].GetString(), serverObj["playlist"].GetString(), playerCount, serverObj["maxPlayers"].GetInt(), serverObj["hasPassword"].IsTrue()); newServer = &server; createNewServerInfo = false; break; -- cgit v1.2.3