From b9458150e05fc19c4f13cb4c6e21c5acb591f82b Mon Sep 17 00:00:00 2001 From: Zwelf Date: Thu, 15 Jun 2023 16:09:31 +0200 Subject: [PATCH] Fix JoinVer and Join teehistorian chunks missing in some conditions vanilla 0.6 joins weren't recorded. Also after map change, for the existing players these Join chunks were missing. Just add these message for existing players now and add OnClientEngineJoin in all code paths with clients connecting. --- src/engine/server/server.cpp | 16 ++++++++++++++++ src/game/server/teehistorian.cpp | 2 +- src/test/teehistorian.cpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 9e27b5124..76237a507 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1062,6 +1062,9 @@ int CServer::ClientRejoinCallback(int ClientID, void *pUser) pThis->m_aClients[ClientID].Reset(); + pThis->GameServer()->OnClientEngineJoin(ClientID, pThis->m_aClients[ClientID].m_Sixup); + pThis->Antibot()->OnEngineClientJoin(ClientID, pThis->m_aClients[ClientID].m_Sixup); + pThis->SendMap(ClientID); return 0; @@ -1087,6 +1090,9 @@ int CServer::NewClientNoAuthCallback(int ClientID, void *pUser) pThis->m_aClients[ClientID].m_DDNetVersionSettled = false; pThis->m_aClients[ClientID].Reset(); + pThis->GameServer()->OnClientEngineJoin(ClientID, false); + pThis->Antibot()->OnEngineClientJoin(ClientID, false); + pThis->SendCapabilities(ClientID); pThis->SendMap(ClientID); #if defined(CONF_FAMILY_UNIX) @@ -2781,6 +2787,16 @@ int CServer::Run() break; } UpdateServerInfo(true); + for(int ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) + { + if(m_aClients[ClientID].m_State != CClient::STATE_CONNECTING) + continue; + + // When doing a map change, a new Teehistorian file is created. For players that are already + // on the server, no PlayerJoin event is produced in Teehistorian from the network engine. + // Record PlayerJoin events here to record the Sixup version and player join event. + GameServer()->OnClientEngineJoin(ClientID, m_aClients[ClientID].m_Sixup); + } } else { diff --git a/src/game/server/teehistorian.cpp b/src/game/server/teehistorian.cpp index 2b711466e..b56f0cf37 100644 --- a/src/game/server/teehistorian.cpp +++ b/src/game/server/teehistorian.cpp @@ -8,7 +8,7 @@ static const char TEEHISTORIAN_NAME[] = "teehistorian@ddnet.tw"; static const CUuid TEEHISTORIAN_UUID = CalculateUuid(TEEHISTORIAN_NAME); static const char TEEHISTORIAN_VERSION[] = "2"; -static const char TEEHISTORIAN_VERSION_MINOR[] = "4"; +static const char TEEHISTORIAN_VERSION_MINOR[] = "5"; #define UUID(id, name) static const CUuid UUID_##id = CalculateUuid(name); #include diff --git a/src/test/teehistorian.cpp b/src/test/teehistorian.cpp index 44750696b..846d5152c 100644 --- a/src/test/teehistorian.cpp +++ b/src/test/teehistorian.cpp @@ -101,7 +101,7 @@ protected: void Expect(const unsigned char *pOutput, size_t OutputSize) { static CUuid TEEHISTORIAN_UUID = CalculateUuid("teehistorian@ddnet.tw"); - static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"4\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; + static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"5\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; static const char PREFIX2[] = "\",\"server_name\":\"server name\",\"server_port\":\"8303\",\"game_type\":\"game type\",\"map_name\":\"Kobra 3 Solo\",\"map_size\":\"903514\",\"map_sha256\":\"0123456789012345678901234567890123456789012345678901234567890123\",\"map_crc\":\"eceaf25c\",\"prng_description\":\"test-prng:02468ace\",\"config\":{},\"tuning\":{},\"uuids\":["; static const char PREFIX3[] = "]}";