Fix #19112: Text boxes not updated with empty strings (#19207)

* fix #19112 text boxes not updated with empty strings

* Update changelog
This commit is contained in:
Josh Trzebiatowski 2023-01-23 15:20:27 -06:00 committed by GitHub
parent a13a6971a0
commit 54f263b704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 49 deletions

View File

@ -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.

View File

@ -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;

View File

@ -167,10 +167,8 @@ public:
}
void OnTextInput(WidgetIndex widgetIndex, std::string_view text) override
{
if (text.empty())
return;
std::string temp = static_cast<std::string>(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;

View File

@ -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()))