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

@@ -808,8 +808,7 @@ public:
}
case WID_NG_CLIENT:
/* Make sure the name does not start with a space, so TAB completion works */
if (!StrEmpty(this->name_editbox.text.buf) && this->name_editbox.text.buf[0] != ' ') {
if (NetworkIsValidClientName(this->name_editbox.text.buf)) {
strecpy(_settings_client.network.client_name, this->name_editbox.text.buf, lastof(_settings_client.network.client_name));
} else {
strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));