From 102672a797edef07922a11d101f26b2baabfd95b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 24 Jan 2016 21:52:02 -0500 Subject: [PATCH] NetPlayClient: Make is_connected private This is only queried, there's no need to expose it for writing. Even if it was written to, a data member shouldn't be part of your public API unless its part of a dumb object or trivial struct. --- Source/Core/Core/NetPlayClient.cpp | 7 ++----- Source/Core/Core/NetPlayClient.h | 5 ++++- Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index d20d1b77ef..1956596b90 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -30,7 +30,7 @@ NetPlayClient::~NetPlayClient() if (m_is_running.load()) StopGame(); - if (is_connected) + if (m_is_connected) { m_do_loop.store(false); m_thread.join(); @@ -76,8 +76,6 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlay m_target_buffer_size = 20; ClearBuffers(); - is_connected = false; - m_player_name = name; if (!traversal) @@ -235,7 +233,7 @@ bool NetPlayClient::Connect() m_dialog->Update(); - is_connected = true; + m_is_connected = true; return true; } @@ -629,7 +627,6 @@ std::vector NetPlayClient::GetPlayers() return players; } - // called from ---GUI--- thread void NetPlayClient::SendChatMessage(const std::string& msg) { diff --git a/Source/Core/Core/NetPlayClient.h b/Source/Core/Core/NetPlayClient.h index cbfd765846..72379701b4 100644 --- a/Source/Core/Core/NetPlayClient.h +++ b/Source/Core/Core/NetPlayClient.h @@ -56,7 +56,8 @@ public: void GetPlayerList(std::string& list, std::vector& pid_list); std::vector GetPlayers(); - bool is_connected; + // Called from the GUI thread. + bool IsConnected() const { return m_is_connected; } bool StartGame(const std::string &path); bool StopGame(); @@ -135,6 +136,8 @@ private: void Disconnect(); bool Connect(); + bool m_is_connected = false; + PlayerId m_pid; std::map m_players; std::string m_host_spec; diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp index ae0375bd71..72042bac2b 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp @@ -291,7 +291,7 @@ void NetPlaySetupFrame::MakeNetPlayDiag(int port, const std::string &game, bool GetTraversalServer(netplay_section, ¢ralServer); netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()), trav, centralServer, (u16) centralPort); - if (netplay_client->is_connected) + if (netplay_client->IsConnected()) { npd->Show(); Destroy();