Merge pull request #8534 from JosJuice/netplay-index-empty-strings

Properly check for missing netplay session name/region
This commit is contained in:
Anthony 2019-12-25 21:52:22 -08:00 committed by GitHub
commit 0755f92979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -169,8 +169,11 @@ static void ClearPeerPlayerId(ENetPeer* peer)
void NetPlayServer::SetupIndex()
{
if (!Config::Get(Config::NETPLAY_USE_INDEX))
if (!Config::Get(Config::NETPLAY_USE_INDEX) || Config::Get(Config::NETPLAY_INDEX_NAME).empty() ||
Config::Get(Config::NETPLAY_INDEX_REGION).empty())
{
return;
}
NetPlaySession session;

View File

@ -227,6 +227,14 @@ void NetPlaySetupDialog::ConnectWidgets()
connect(m_host_chunked_upload_limit_box,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&NetPlaySetupDialog::SaveSettings);
connect(m_host_server_browser, &QCheckBox::toggled, this, &NetPlaySetupDialog::SaveSettings);
connect(m_host_server_name, &QLineEdit::textChanged, this, &NetPlaySetupDialog::SaveSettings);
connect(m_host_server_password, &QLineEdit::textChanged, this, &NetPlaySetupDialog::SaveSettings);
connect(m_host_server_region,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&NetPlaySetupDialog::SaveSettings);
#ifdef USE_UPNP
connect(m_host_upnp, &QCheckBox::stateChanged, this, &NetPlaySetupDialog::SaveSettings);
#endif
@ -328,6 +336,14 @@ void NetPlaySetupDialog::accept()
return;
}
if (m_host_server_browser->isChecked() &&
m_host_server_region->currentData().toString().isEmpty())
{
ModalMessageBox::critical(this, tr("Error"),
tr("You must provide a region for your session!"));
return;
}
emit Host(items[0]->text());
}
}