From f74ebfe3e812fd1811200a2b76f12dc40086998a Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 29 Feb 2024 00:21:38 +0300 Subject: [PATCH] fix map name being updated before `OnMapChange(...)` call --- src/engine/server/server.cpp | 9 +++++---- src/game/server/score.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index ef2bf1e8c..ccf3bf05d 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2504,11 +2504,12 @@ void CServer::PumpNetwork(bool PacketWaiting) const char *CServer::GetMapName() const { // get the name of the map without his path - const char *pMapShortName = &Config()->m_SvMap[0]; - for(int i = 0; i < str_length(Config()->m_SvMap) - 1; i++) + const char *pMapName = m_aCurrentMap; + const char *pMapShortName = pMapName; + for(int i = 0; i < str_length(pMapName) - 1; i++) { - if(Config()->m_SvMap[i] == '/' || Config()->m_SvMap[i] == '\\') - pMapShortName = &Config()->m_SvMap[i + 1]; + if(pMapName[i] == '/' || pMapName[i] == '\\') + pMapShortName = &pMapName[i + 1]; } return pMapShortName; } diff --git a/src/game/server/score.cpp b/src/game/server/score.cpp index cfba75da6..0e1225d64 100644 --- a/src/game/server/score.cpp +++ b/src/game/server/score.cpp @@ -300,7 +300,7 @@ void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer, bool auto Tmp = std::make_unique(SaveResult); str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode)); - str_copy(Tmp->m_aMap, g_Config.m_SvMap, sizeof(Tmp->m_aMap)); + str_copy(Tmp->m_aMap, this->Server()->GetMapName(), sizeof(Tmp->m_aMap)); str_copy(Tmp->m_aServer, pServer, sizeof(Tmp->m_aServer)); str_copy(Tmp->m_aClientName, this->Server()->ClientName(ClientID), sizeof(Tmp->m_aClientName)); Tmp->m_aGeneratedCode[0] = '\0';