From d0c3d190e1b453caa12e972586232ec41eb17334 Mon Sep 17 00:00:00 2001 From: Koncord Date: Mon, 24 Apr 2017 20:22:42 +0800 Subject: [PATCH] [Server] Send players list to master server --- apps/openmw-mp/MasterClient.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/MasterClient.cpp b/apps/openmw-mp/MasterClient.cpp index 5ba5cf5b5..c4a97bbe2 100644 --- a/apps/openmw-mp/MasterClient.cpp +++ b/apps/openmw-mp/MasterClient.cpp @@ -178,11 +178,33 @@ void MasterClient::Thread() queryData.SetPassword((int) Networking::get().isPassworded()); queryData.SetVersion(TES3MP_VERSION); + auto *players = Players::getPlayers(); while (sRun) { - SetPlayers((int) Players::getPlayers()->size()); + SetPlayers((int) players->size()); + + auto pIt = players->begin(); + for (int i = 0; pIt != players->end(); i++, pIt++) + { + if (queryData.players[i] != pIt->second->npc.mName) + { + updated = true; + break; + } + } + if (updated) + { + if (pIt != players->end()) + { + queryData.players.clear(); + transform(players->begin(), players->end(), back_inserter(queryData.players), [](auto pair) + { + return pair.second->npc.mName; + }); + } Send(PacketMasterAnnounce::FUNCTION_ANNOUNCE); + } else Send(PacketMasterAnnounce::FUNCTION_KEEP); RakSleep(timeout);