NetPlayServer: const correctness

This commit is contained in:
Lioncash 2017-03-19 09:14:03 -04:00
parent 025eac9062
commit 35c230a418
2 changed files with 14 additions and 14 deletions

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;