Skip to content

Commit

Permalink
Merge pull request dolphin-emu#8604 from Techjar/netplay-index-direct
Browse files Browse the repository at this point in the history
Core/NetPlayServer: Fix session not being added to index on direct connection type
  • Loading branch information
leoetlino authored Mar 15, 2020
2 parents d297080 + 06a9f6e commit 466c079
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
12 changes: 3 additions & 9 deletions Source/Core/Core/NetPlayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ NetPlayServer::~NetPlayServer()
}

// 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)
: m_dialog(dialog)
{
//--use server time
if (enet_initialize() != 0)
Expand Down Expand Up @@ -209,11 +210,9 @@ void NetPlayServer::SetupIndex()

session.EncryptID(Config::Get(Config::NETPLAY_INDEX_PASSWORD));

bool success = m_index.Add(session);
if (m_dialog != nullptr)
{
bool success = m_index.Add(session);
m_dialog->OnIndexAdded(success, success ? "" : m_index.GetLastError());
}

m_index.SetErrorCallback([this] {
if (m_dialog != nullptr)
Expand Down Expand Up @@ -1933,11 +1932,6 @@ u16 NetPlayServer::GetPort() const
return m_server->address.port;
}

void NetPlayServer::SetNetPlayUI(NetPlayUI* dialog)
{
m_dialog = dialog;
}

// called from ---GUI--- thread
std::unordered_set<std::string> NetPlayServer::GetInterfaceSet() const
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/NetPlayServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class NetPlayServer : public TraversalClientClient
void SendChunkedToClients(sf::Packet&& packet, PlayerId skip_pid = 0,
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();

bool ChangeGame(const std::string& game);
Expand Down Expand Up @@ -67,7 +68,6 @@ class NetPlayServer : public TraversalClientClient

u16 GetPort() const;

void SetNetPlayUI(NetPlayUI* dialog);
std::unordered_set<std::string> GetInterfaceSet() const;
std::string GetInterfaceHost(const std::string& inter) const;

Expand Down
5 changes: 1 addition & 4 deletions Source/Core/DolphinQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,6 @@ bool MainWindow::NetPlayJoin()
return false;
}

if (server != nullptr)
server->SetNetPlayUI(m_netplay_dialog);

m_netplay_setup_dialog->close();
m_netplay_dialog->show(nickname, is_traversal);

Expand Down Expand Up @@ -1378,7 +1375,7 @@ bool MainWindow::NetPlayHost(const QString& game_id)

// Create Server
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}));

if (!Settings::Instance().GetNetPlayServer()->is_connected)
Expand Down

0 comments on commit 466c079

Please sign in to comment.