diff options
author | rubidium42 <rubidium@openttd.org> | 2021-04-22 07:01:46 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-04-24 08:02:54 +0200 |
commit | b14f4121170cb75aba785efc9e73a364c232301b (patch) | |
tree | b46c1a7aa88fd305a6803cd0c14da8d5d02ae7a6 /src/network/network_client.cpp | |
parent | dc0efd5f2efac29e40264881553f779e206d0cc4 (diff) | |
download | openttd-b14f4121170cb75aba785efc9e73a364c232301b.tar.xz |
Codechange: [Network] Introduce function to validate the client name
Diffstat (limited to 'src/network/network_client.cpp')
-rw-r--r-- | src/network/network_client.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 5858859cb..a12215bbc 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -1251,6 +1251,20 @@ void NetworkClientsToSpectators(CompanyID cid) } /** + * 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. */ void NetworkUpdateClientName() |