From fdb5828d626932653d8f3628f567d2f9cfae83d2 Mon Sep 17 00:00:00 2001 From: Michael M Date: Thu, 10 Aug 2017 12:47:27 -0700 Subject: [PATCH] Qt MainWindow: clean up Netplay settings logic --- Source/Core/DolphinQt2/MainWindow.cpp | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 6797c6296b..b906b2801d 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -663,9 +663,8 @@ bool MainWindow::NetPlayJoin() } // Settings - std::string host_ip, traversal_host, nickname; - int host_port, traversal_port; - bool is_traversal; + std::string host_ip; + u16 host_port; if (Settings::Instance().GetNetPlayServer() != nullptr) { host_ip = "127.0.0.1"; @@ -677,12 +676,12 @@ bool MainWindow::NetPlayJoin() host_port = Config::Get(Config::NETPLAY_HOST_PORT); } - std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); - is_traversal = traversal_choice == "traversal"; + const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); + const bool is_traversal = traversal_choice == "traversal"; - traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); - traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); - nickname = Config::Get(Config::NETPLAY_NICKNAME); + 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); // Create Client Settings::Instance().ResetNetPlayClient( @@ -721,19 +720,14 @@ bool MainWindow::NetPlayHost(const QString& game_id) } // Settings - std::string traversal_host, nickname; - int host_port, traversal_port; - bool is_traversal, use_upnp; + u16 host_port = Config::Get(Config::NETPLAY_HOST_PORT); + const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); + const bool is_traversal = traversal_choice == "traversal"; + const bool use_upnp = Config::Get(Config::NETPLAY_USE_UPNP); - host_port = Config::Get(Config::NETPLAY_HOST_PORT); - std::string traversal_choice; - traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); - is_traversal = traversal_choice == "traversal"; - use_upnp = Config::Get(Config::NETPLAY_USE_UPNP); - - traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); - traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); - nickname = Config::Get(Config::NETPLAY_NICKNAME); + 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); if (is_traversal) host_port = Config::Get(Config::NETPLAY_LISTEN_PORT);