Fix invalid server-assigned utf8 names with (1) prefix (fixes #3269)

This commit is contained in:
def 2020-11-09 15:38:55 +01:00
parent 32736f0a0f
commit 225787ea39

View file

@ -394,7 +394,9 @@ bool CServer::SetClientNameImpl(int ClientID, const char *pNameRequest, bool Set
// auto rename
for(int i = 1;; i++)
{
str_format(aNameTry, sizeof(aNameTry), "(%d)%s", i, aTrimmedName);
char aNameTryBrokenEnd[MAX_NAME_LENGTH];
str_format(aNameTryBrokenEnd, sizeof(aNameTryBrokenEnd), "(%d)%s", i, aTrimmedName);
str_utf8_copy(aNameTry, aNameTryBrokenEnd, sizeof(aNameTry));
if(IsClientNameAvailable(ClientID, aNameTry))
break;
}