diff options
author | rubidium42 <rubidium@openttd.org> | 2021-04-22 08:01:52 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-04-24 08:02:54 +0200 |
commit | bfb0ab3e2f5a5a09b4bf7f5584199425ffb1de50 (patch) | |
tree | 47f3e37e8d3a46096964ad32aa642b3f20ab24ea /src/network/network_gui.cpp | |
parent | 5202869f0fec5512211988b35b1ee4b29a33686d (diff) | |
download | openttd-bfb0ab3e2f5a5a09b4bf7f5584199425ffb1de50.tar.xz |
Feature: [Network] Ensure players fill in a name instead of defaulting to "Player"
Diffstat (limited to 'src/network/network_gui.cpp')
-rw-r--r-- | src/network/network_gui.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 15cf24f49..dd25ad5bc 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -808,11 +808,9 @@ public: } case WID_NG_CLIENT: - 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)); - } + /* Validation of the name will happen once the user tries to join or start a game, as getting + * error messages while typing (e.g. when you clear the name) defeats the purpose of the check. */ + strecpy(_settings_client.network.client_name, this->name_editbox.text.buf, lastof(_settings_client.network.client_name)); break; } } @@ -1245,6 +1243,8 @@ static WindowDesc _network_start_server_window_desc( static void ShowNetworkStartServerWindow() { + if (!NetworkValidateClientName()) return; + DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME); DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY); @@ -1537,6 +1537,8 @@ static WindowDesc _network_lobby_window_desc( */ static void ShowNetworkLobbyWindow(NetworkGameList *ngl) { + if (!NetworkValidateClientName()) return; + DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START); DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME); |