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.
This commit is contained in:
parent
d9f87b8030
commit
102672a797
|
@ -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<const Player*> NetPlayClient::GetPlayers()
|
|||
return players;
|
||||
}
|
||||
|
||||
|
||||
// called from ---GUI--- thread
|
||||
void NetPlayClient::SendChatMessage(const std::string& msg)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,8 @@ public:
|
|||
void GetPlayerList(std::string& list, std::vector<int>& pid_list);
|
||||
std::vector<const Player*> 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<PlayerId, Player> m_players;
|
||||
std::string m_host_spec;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue