Merge pull request #8604 from Techjar/netplay-index-direct

Core/NetPlayServer: Fix session not being added to index on direct connection type
This commit is contained in:
Léo Lam 2020-03-15 22:22:00 +01:00 committed by GitHub
commit 466c079bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 15 deletions

View File

@ -101,8 +101,9 @@ NetPlayServer::~NetPlayServer()
} }
// called from ---GUI--- thread // called from ---GUI--- thread
NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayServer::NetPlayServer(const u16 port, const bool forward_port, NetPlayUI* dialog,
const NetTraversalConfig& traversal_config) const NetTraversalConfig& traversal_config)
: m_dialog(dialog)
{ {
//--use server time //--use server time
if (enet_initialize() != 0) if (enet_initialize() != 0)
@ -209,11 +210,9 @@ void NetPlayServer::SetupIndex()
session.EncryptID(Config::Get(Config::NETPLAY_INDEX_PASSWORD)); session.EncryptID(Config::Get(Config::NETPLAY_INDEX_PASSWORD));
bool success = m_index.Add(session);
if (m_dialog != nullptr) if (m_dialog != nullptr)
{
bool success = m_index.Add(session);
m_dialog->OnIndexAdded(success, success ? "" : m_index.GetLastError()); m_dialog->OnIndexAdded(success, success ? "" : m_index.GetLastError());
}
m_index.SetErrorCallback([this] { m_index.SetErrorCallback([this] {
if (m_dialog != nullptr) if (m_dialog != nullptr)
@ -1933,11 +1932,6 @@ u16 NetPlayServer::GetPort() const
return m_server->address.port; return m_server->address.port;
} }
void NetPlayServer::SetNetPlayUI(NetPlayUI* dialog)
{
m_dialog = dialog;
}
// called from ---GUI--- thread // called from ---GUI--- thread
std::unordered_set<std::string> NetPlayServer::GetInterfaceSet() const std::unordered_set<std::string> NetPlayServer::GetInterfaceSet() const
{ {

View File

@ -39,7 +39,8 @@ public:
void SendChunkedToClients(sf::Packet&& packet, PlayerId skip_pid = 0, void SendChunkedToClients(sf::Packet&& packet, PlayerId skip_pid = 0,
const std::string& title = ""); const std::string& title = "");
NetPlayServer(u16 port, bool forward_port, const NetTraversalConfig& traversal_config); NetPlayServer(u16 port, bool forward_port, NetPlayUI* dialog,
const NetTraversalConfig& traversal_config);
~NetPlayServer(); ~NetPlayServer();
bool ChangeGame(const std::string& game); bool ChangeGame(const std::string& game);
@ -67,7 +68,6 @@ public:
u16 GetPort() const; u16 GetPort() const;
void SetNetPlayUI(NetPlayUI* dialog);
std::unordered_set<std::string> GetInterfaceSet() const; std::unordered_set<std::string> GetInterfaceSet() const;
std::string GetInterfaceHost(const std::string& inter) const; std::string GetInterfaceHost(const std::string& inter) const;

View File

@ -1338,9 +1338,6 @@ bool MainWindow::NetPlayJoin()
return false; return false;
} }
if (server != nullptr)
server->SetNetPlayUI(m_netplay_dialog);
m_netplay_setup_dialog->close(); m_netplay_setup_dialog->close();
m_netplay_dialog->show(nickname, is_traversal); m_netplay_dialog->show(nickname, is_traversal);
@ -1378,7 +1375,7 @@ bool MainWindow::NetPlayHost(const QString& game_id)
// Create Server // Create Server
Settings::Instance().ResetNetPlayServer(new NetPlay::NetPlayServer( Settings::Instance().ResetNetPlayServer(new NetPlay::NetPlayServer(
host_port, use_upnp, host_port, use_upnp, m_netplay_dialog,
NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port})); NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port}));
if (!Settings::Instance().GetNetPlayServer()->is_connected) if (!Settings::Instance().GetNetPlayServer()->is_connected)