Merge pull request #385 from H-M-H/faking_bugfix

FIRST trim the name and THEN compare it to others !
This commit is contained in:
Dennis Felsing 2015-12-16 20:20:29 +01:00
commit 8d63d0d536

View file

@ -333,7 +333,12 @@ int CServer::TrySetClientName(int ClientID, const char *pName)
if(!aTrimmedName[0])
return -1;
// make sure that two clients doesn't have the same name
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "'%s' -> '%s'", pName, aTrimmedName);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
pName = aTrimmedName;
// make sure that two clients don't have the same name
for(int i = 0; i < MAX_CLIENTS; i++)
if(i != ClientID && m_aClients[i].m_State >= CClient::STATE_READY)
{
@ -341,11 +346,6 @@ int CServer::TrySetClientName(int ClientID, const char *pName)
return -1;
}
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "'%s' -> '%s'", pName, aTrimmedName);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
pName = aTrimmedName;
// set the client name
str_copy(m_aClients[ClientID].m_aName, pName, MAX_NAME_LENGTH);
return 0;