Skip to content

Commit

Permalink
Merge pull request dolphin-emu#7221 from Techjar/netplay-config-junk
Browse files Browse the repository at this point in the history
Fix NetPlay using some config values wrongly
  • Loading branch information
spycrab authored Jul 6, 2018
2 parents bfb7af4 + eeff5e0 commit 059880b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Source/Core/DolphinQt2/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,9 @@ bool MainWindow::NetPlayJoin()
}

// Settings
const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
const bool is_traversal = traversal_choice == "traversal";

std::string host_ip;
u16 host_port;
if (Settings::Instance().GetNetPlayServer() != nullptr)
Expand All @@ -1073,13 +1076,11 @@ bool MainWindow::NetPlayJoin()
}
else
{
host_ip = Config::Get(Config::NETPLAY_HOST_CODE);
host_port = Config::Get(Config::NETPLAY_HOST_PORT);
host_ip = is_traversal ? Config::Get(Config::NETPLAY_HOST_CODE) :
Config::Get(Config::NETPLAY_ADDRESS);
host_port = Config::Get(Config::NETPLAY_CONNECT_PORT);
}

const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
const bool is_traversal = traversal_choice == "traversal";

const std::string traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER);
const u16 traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT);
const std::string nickname = Config::Get(Config::NETPLAY_NICKNAME);
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/DolphinQt2/NetPlay/NetPlaySetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ void NetPlaySetupDialog::ConnectWidgets()
void NetPlaySetupDialog::SaveSettings()
{
Config::SetBaseOrCurrent(Config::NETPLAY_NICKNAME, m_nickname_edit->text().toStdString());
Config::SetBaseOrCurrent(Config::NETPLAY_HOST_CODE, m_ip_edit->text().toStdString());
Config::SetBaseOrCurrent(m_connection_type->currentIndex() == 0 ? Config::NETPLAY_ADDRESS :
Config::NETPLAY_HOST_CODE,
m_ip_edit->text().toStdString());
Config::SetBaseOrCurrent(Config::NETPLAY_CONNECT_PORT,
static_cast<u16>(m_connect_port_box->value()));
Config::SetBaseOrCurrent(Config::NETPLAY_HOST_PORT, static_cast<u16>(m_host_port_box->value()));
Expand Down Expand Up @@ -211,7 +213,8 @@ void NetPlaySetupDialog::OnConnectionTypeChanged(int index)

m_reset_traversal_button->setHidden(index == 0);

std::string address = Config::Get(Config::NETPLAY_HOST_CODE);
std::string address =
index == 0 ? Config::Get(Config::NETPLAY_ADDRESS) : Config::Get(Config::NETPLAY_HOST_CODE);

m_ip_label->setText(index == 0 ? tr("IP Address:") : tr("Host Code:"));
m_ip_edit->setText(QString::fromStdString(address));
Expand Down

0 comments on commit 059880b

Please sign in to comment.