Codechange: [Network] Introduce function to validate the client name

This commit is contained in:
rubidium42
2021-04-22 07:01:46 +02:00
committed by rubidium42
parent dc0efd5f2e
commit b14f412117
4 changed files with 17 additions and 3 deletions

View File

@@ -1250,6 +1250,20 @@ void NetworkClientsToSpectators(CompanyID cid)
cur_company.Restore();
}
/**
* Check whether the given client name is deemed valid for use in network games.
* An empty name (null or '') is not valid as that is essentially no name at all.
* A name starting with white space is not valid for tab completion purposes.
* @param client_name The client name to check for validity.
* @return True iff the name is valid.
*/
bool NetworkIsValidClientName(const char *client_name)
{
if (StrEmpty(client_name)) return false;
if (*client_name == ' ') return false;
return true;
}
/**
* Send the server our name.
*/