From a8cadc21ebdd0438e82846222e0bf480ff1d28f6 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 5 Sep 2015 18:05:29 +0200 Subject: [PATCH] Last one I hope --- src/game/server/ddracechat.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index 987e2575c..305524543 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -622,16 +622,28 @@ void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData) int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID); const char* pCode = pResult->GetString(0); - char aCountry[4]; + char aCountry[5]; if(str_length(pCode) > 3 && pCode[0] >= 'A' && pCode[0] <= 'Z' && pCode[1] >= 'A' - && pCode[1] <= 'Z' && pCode[2] >= 'A' && pCode[2] <= 'Z' && pCode[3] == ' ') + && pCode[1] <= 'Z' && pCode[2] >= 'A' && pCode[2] <= 'Z') { - str_copy(aCountry, pCode, 4); - pCode = pCode + 4; + if(pCode[3] == ' ') + { + str_copy(aCountry, pCode, 4); + pCode = pCode + 4; + } + else if(str_length(pCode) > 4 && pCode[4] == ' ') + { + str_copy(aCountry, pCode, 5); + pCode = pCode + 5; + } + else + { + str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry)); + } } else { - str_copy(aCountry, g_Config.m_SvSqlServerName, 4); + str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry)); } pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry);