diff --git a/distribution/changelog.txt b/distribution/changelog.txt index f5b30ce64f..26d17a558b 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -23,6 +23,7 @@ - Fix: [#19026] Park loan is clamped to a 32-bit integer. - Fix: [#19091] [Plugin] Remote plugins in multiplayer servers do not unload properly. - Fix: [#19112] Clearing the last character in the Object Selection filter does not properly reset it. +- Fix: [#19112] Text boxes not updated with empty strings in Track List, Server List, and Start Server windows. - Fix: [#19114] [Plugin] GameActionResult does not comply to API specification. - Fix: [#19136] SV6 saves with experimental RCT1 paths not imported correctly. diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 5912539732..9779876085 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -305,7 +305,7 @@ static void WindowServerListScrollMouseover(WindowBase* w, int32_t scrollIndex, static void WindowServerListTextinput(WindowBase* w, WidgetIndex widgetIndex, char* text) { - if (text == nullptr || text[0] == 0) + if (text == nullptr) return; switch (widgetIndex) @@ -314,12 +314,9 @@ static void WindowServerListTextinput(WindowBase* w, WidgetIndex widgetIndex, ch if (strcmp(_playerName, text) == 0) return; - std::fill_n(_playerName, sizeof(_playerName), 0x00); - if (text[0] != '\0') - { - SafeStrCpy(_playerName, text, sizeof(_playerName)); - } + SafeStrCpy(_playerName, text, sizeof(_playerName)); + // Don't allow empty player names if (_playerName[0] != '\0') { gConfigNetwork.PlayerName = _playerName; diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index fbe8bd8e3c..a027e680ae 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -167,10 +167,8 @@ public: } void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override { - if (text.empty()) - return; - std::string temp = static_cast(text); + int tempPort = 0; switch (widgetIndex) { @@ -178,27 +176,25 @@ public: if (strcmp(_port, temp.c_str()) == 0) return; - std::fill_n(_port, sizeof(_port), 0x00); - if (text[0] != '\0') + SafeStrCpy(_port, temp.c_str(), sizeof(_port)); + + // Don't allow negative/zero for port number + tempPort = atoi(_port); + if (tempPort > 0) { - SafeStrCpy(_port, temp.c_str(), sizeof(_port)); + gConfigNetwork.DefaultPort = tempPort; + ConfigSaveDefault(); } - gConfigNetwork.DefaultPort = atoi(_port); - ConfigSaveDefault(); - - WidgetInvalidate(*this, WIDX_NAME_INPUT); + WidgetInvalidate(*this, WIDX_PORT_INPUT); break; case WIDX_NAME_INPUT: if (strcmp(_name, temp.c_str()) == 0) return; - std::fill_n(_name, sizeof(_name), 0x00); - if (text[0] != '\0') - { - SafeStrCpy(_name, temp.c_str(), sizeof(_name)); - } + SafeStrCpy(_name, temp.c_str(), sizeof(_name)); + // Don't allow empty server names if (_name[0] != '\0') { gConfigNetwork.ServerName = _name; @@ -211,17 +207,9 @@ public: if (strcmp(_description, temp.c_str()) == 0) return; - std::fill_n(_description, sizeof(_description), 0x00); - if (text[0] != '\0') - { - SafeStrCpy(_description, temp.c_str(), sizeof(_description)); - } - - if (_description[0] != '\0') - { - gConfigNetwork.ServerDescription = _description; - ConfigSaveDefault(); - } + SafeStrCpy(_description, temp.c_str(), sizeof(_description)); + gConfigNetwork.ServerDescription = _description; + ConfigSaveDefault(); WidgetInvalidate(*this, WIDX_DESCRIPTION_INPUT); break; @@ -229,17 +217,9 @@ public: if (strcmp(_greeting, temp.c_str()) == 0) return; - std::fill_n(_greeting, sizeof(_greeting), 0x00); - if (text[0] != '\0') - { - SafeStrCpy(_greeting, temp.c_str(), sizeof(_greeting)); - } - - if (_greeting[0] != '\0') - { - gConfigNetwork.ServerGreeting = _greeting; - ConfigSaveDefault(); - } + SafeStrCpy(_greeting, temp.c_str(), sizeof(_greeting)); + gConfigNetwork.ServerGreeting = _greeting; + ConfigSaveDefault(); WidgetInvalidate(*this, WIDX_GREETING_INPUT); break; @@ -247,11 +227,7 @@ public: if (strcmp(_password, temp.c_str()) == 0) return; - std::fill_n(_password, sizeof(_password), 0x00); - if (text[0] != '\0') - { - SafeStrCpy(_password, temp.c_str(), sizeof(_password)); - } + SafeStrCpy(_password, temp.c_str(), sizeof(_password)); WidgetInvalidate(*this, WIDX_PASSWORD_INPUT); break; diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 29f323f95f..09e9c06810 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -344,7 +344,7 @@ public: void OnTextInput(const WidgetIndex widgetIndex, std::string_view text) override { - if (widgetIndex != WIDX_FILTER_STRING || text.empty()) + if (widgetIndex != WIDX_FILTER_STRING) return; if (String::Equals(_filterString, std::string(text).c_str()))