Merge pull request #5111 from lioncash/const

NetPlayServer/NetPlayClient: const correctness
This commit is contained in:
Matthew Parlane 2017-03-20 13:02:42 +13:00 committed by GitHub
commit cba585c82d
4 changed files with 20 additions and 20 deletions

View File

@ -560,7 +560,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
return 0;
}
void NetPlayClient::Send(sf::Packet& packet)
void NetPlayClient::Send(const sf::Packet& packet)
{
ENetPacket* epac =
enet_packet_create(packet.getData(), packet.getDataSize(), ENET_PACKET_FLAG_RELIABLE);
@ -1150,7 +1150,7 @@ int NetPlayClient::NumLocalPads() const
}));
}
int NetPlayClient::InGamePadToLocalPad(int ingame_pad)
int NetPlayClient::InGamePadToLocalPad(int ingame_pad) const
{
// not our pad
if (m_pad_map[ingame_pad] != m_local_player->pid)
@ -1168,7 +1168,7 @@ int NetPlayClient::InGamePadToLocalPad(int ingame_pad)
return local_pad;
}
int NetPlayClient::LocalPadToInGamePad(int local_pad)
int NetPlayClient::LocalPadToInGamePad(int local_pad) const
{
// Figure out which in-game pad maps to which local pad.
// The logic we have here is that the local slots always

View File

@ -93,8 +93,8 @@ public:
bool IsFirstInGamePad(int ingame_pad) const;
int NumLocalPads() const;
int InGamePadToLocalPad(int ingame_pad);
int LocalPadToInGamePad(int localPad);
int InGamePadToLocalPad(int ingame_pad) const;
int LocalPadToInGamePad(int localPad) const;
static void SendTimeBase();
bool DoAllPlayersHaveGame();
@ -156,7 +156,7 @@ private:
void SendPadState(int in_game_pad, const GCPadStatus& np);
void SendWiimoteState(int in_game_pad, const NetWiimote& nw);
unsigned int OnData(sf::Packet& packet);
void Send(sf::Packet& packet);
void Send(const sf::Packet& packet);
void Disconnect();
bool Connect();
void ComputeMD5(const std::string& file_identifier);

View File

@ -342,7 +342,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket)
}
// called from ---NETPLAY--- thread
unsigned int NetPlayServer::OnDisconnect(Client& player)
unsigned int NetPlayServer::OnDisconnect(const Client& player)
{
PlayerId pid = player.pid;
@ -823,7 +823,7 @@ bool NetPlayServer::StartGame()
}
// called from multiple threads
void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid)
void NetPlayServer::SendToClients(const sf::Packet& packet, const PlayerId skip_pid)
{
for (auto& p : m_players)
{
@ -834,7 +834,7 @@ void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid)
}
}
void NetPlayServer::Send(ENetPeer* socket, sf::Packet& packet)
void NetPlayServer::Send(ENetPeer* socket, const sf::Packet& packet)
{
ENetPacket* epac =
enet_packet_create(packet.getData(), packet.getDataSize(), ENET_PACKET_FLAG_RELIABLE);
@ -853,7 +853,7 @@ void NetPlayServer::KickPlayer(PlayerId player)
}
}
u16 NetPlayServer::GetPort()
u16 NetPlayServer::GetPort() const
{
return m_server->address.port;
}
@ -864,7 +864,7 @@ void NetPlayServer::SetNetPlayUI(NetPlayUI* dialog)
}
// called from ---GUI--- thread
std::unordered_set<std::string> NetPlayServer::GetInterfaceSet()
std::unordered_set<std::string> NetPlayServer::GetInterfaceSet() const
{
std::unordered_set<std::string> result;
auto lst = GetInterfaceListInternal();
@ -874,7 +874,7 @@ std::unordered_set<std::string> NetPlayServer::GetInterfaceSet()
}
// called from ---GUI--- thread
std::string NetPlayServer::GetInterfaceHost(const std::string& inter)
std::string NetPlayServer::GetInterfaceHost(const std::string& inter) const
{
char buf[16];
sprintf(buf, ":%d", GetPort());
@ -890,7 +890,7 @@ std::string NetPlayServer::GetInterfaceHost(const std::string& inter)
}
// called from ---GUI--- thread
std::vector<std::pair<std::string, std::string>> NetPlayServer::GetInterfaceListInternal()
std::vector<std::pair<std::string, std::string>> NetPlayServer::GetInterfaceListInternal() const
{
std::vector<std::pair<std::string, std::string>> result;
#if defined(_WIN32)

View File

@ -50,11 +50,11 @@ public:
void KickPlayer(PlayerId player);
u16 GetPort();
u16 GetPort() const;
void SetNetPlayUI(NetPlayUI* dialog);
std::unordered_set<std::string> GetInterfaceSet();
std::string GetInterfaceHost(const std::string& inter);
std::unordered_set<std::string> GetInterfaceSet() const;
std::string GetInterfaceHost(const std::string& inter) const;
bool is_connected = false;
@ -78,10 +78,10 @@ private:
bool operator==(const Client& other) const { return this == &other; }
};
void SendToClients(sf::Packet& packet, const PlayerId skip_pid = 0);
void Send(ENetPeer* socket, sf::Packet& packet);
void SendToClients(const sf::Packet& packet, const PlayerId skip_pid = 0);
void Send(ENetPeer* socket, const sf::Packet& packet);
unsigned int OnConnect(ENetPeer* socket);
unsigned int OnDisconnect(Client& player);
unsigned int OnDisconnect(const Client& player);
unsigned int OnData(sf::Packet& packet, Client& player);
void OnTraversalStateChanged() override;
@ -89,7 +89,7 @@ private:
void OnConnectFailed(u8) override {}
void UpdatePadMapping();
void UpdateWiimoteMapping();
std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal();
std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal() const;
NetSettings m_settings;