Merge pull request #5111 from lioncash/const
NetPlayServer/NetPlayClient: const correctness
This commit is contained in:
commit
cba585c82d
|
@ -560,7 +560,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetPlayClient::Send(sf::Packet& packet)
|
void NetPlayClient::Send(const sf::Packet& packet)
|
||||||
{
|
{
|
||||||
ENetPacket* epac =
|
ENetPacket* epac =
|
||||||
enet_packet_create(packet.getData(), packet.getDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
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
|
// not our pad
|
||||||
if (m_pad_map[ingame_pad] != m_local_player->pid)
|
if (m_pad_map[ingame_pad] != m_local_player->pid)
|
||||||
|
@ -1168,7 +1168,7 @@ int NetPlayClient::InGamePadToLocalPad(int ingame_pad)
|
||||||
return local_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.
|
// Figure out which in-game pad maps to which local pad.
|
||||||
// The logic we have here is that the local slots always
|
// The logic we have here is that the local slots always
|
||||||
|
|
|
@ -93,8 +93,8 @@ public:
|
||||||
bool IsFirstInGamePad(int ingame_pad) const;
|
bool IsFirstInGamePad(int ingame_pad) const;
|
||||||
int NumLocalPads() const;
|
int NumLocalPads() const;
|
||||||
|
|
||||||
int InGamePadToLocalPad(int ingame_pad);
|
int InGamePadToLocalPad(int ingame_pad) const;
|
||||||
int LocalPadToInGamePad(int localPad);
|
int LocalPadToInGamePad(int localPad) const;
|
||||||
|
|
||||||
static void SendTimeBase();
|
static void SendTimeBase();
|
||||||
bool DoAllPlayersHaveGame();
|
bool DoAllPlayersHaveGame();
|
||||||
|
@ -156,7 +156,7 @@ private:
|
||||||
void SendPadState(int in_game_pad, const GCPadStatus& np);
|
void SendPadState(int in_game_pad, const GCPadStatus& np);
|
||||||
void SendWiimoteState(int in_game_pad, const NetWiimote& nw);
|
void SendWiimoteState(int in_game_pad, const NetWiimote& nw);
|
||||||
unsigned int OnData(sf::Packet& packet);
|
unsigned int OnData(sf::Packet& packet);
|
||||||
void Send(sf::Packet& packet);
|
void Send(const sf::Packet& packet);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
bool Connect();
|
bool Connect();
|
||||||
void ComputeMD5(const std::string& file_identifier);
|
void ComputeMD5(const std::string& file_identifier);
|
||||||
|
|
|
@ -342,7 +342,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from ---NETPLAY--- thread
|
// called from ---NETPLAY--- thread
|
||||||
unsigned int NetPlayServer::OnDisconnect(Client& player)
|
unsigned int NetPlayServer::OnDisconnect(const Client& player)
|
||||||
{
|
{
|
||||||
PlayerId pid = player.pid;
|
PlayerId pid = player.pid;
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ bool NetPlayServer::StartGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from multiple threads
|
// 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)
|
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 =
|
ENetPacket* epac =
|
||||||
enet_packet_create(packet.getData(), packet.getDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
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;
|
return m_server->address.port;
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ void NetPlayServer::SetNetPlayUI(NetPlayUI* dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from ---GUI--- thread
|
// 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;
|
std::unordered_set<std::string> result;
|
||||||
auto lst = GetInterfaceListInternal();
|
auto lst = GetInterfaceListInternal();
|
||||||
|
@ -874,7 +874,7 @@ std::unordered_set<std::string> NetPlayServer::GetInterfaceSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from ---GUI--- thread
|
// called from ---GUI--- thread
|
||||||
std::string NetPlayServer::GetInterfaceHost(const std::string& inter)
|
std::string NetPlayServer::GetInterfaceHost(const std::string& inter) const
|
||||||
{
|
{
|
||||||
char buf[16];
|
char buf[16];
|
||||||
sprintf(buf, ":%d", GetPort());
|
sprintf(buf, ":%d", GetPort());
|
||||||
|
@ -890,7 +890,7 @@ std::string NetPlayServer::GetInterfaceHost(const std::string& inter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from ---GUI--- thread
|
// 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;
|
std::vector<std::pair<std::string, std::string>> result;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
|
@ -50,11 +50,11 @@ public:
|
||||||
|
|
||||||
void KickPlayer(PlayerId player);
|
void KickPlayer(PlayerId player);
|
||||||
|
|
||||||
u16 GetPort();
|
u16 GetPort() const;
|
||||||
|
|
||||||
void SetNetPlayUI(NetPlayUI* dialog);
|
void SetNetPlayUI(NetPlayUI* dialog);
|
||||||
std::unordered_set<std::string> GetInterfaceSet();
|
std::unordered_set<std::string> GetInterfaceSet() const;
|
||||||
std::string GetInterfaceHost(const std::string& inter);
|
std::string GetInterfaceHost(const std::string& inter) const;
|
||||||
|
|
||||||
bool is_connected = false;
|
bool is_connected = false;
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ private:
|
||||||
bool operator==(const Client& other) const { return this == &other; }
|
bool operator==(const Client& other) const { return this == &other; }
|
||||||
};
|
};
|
||||||
|
|
||||||
void SendToClients(sf::Packet& packet, const PlayerId skip_pid = 0);
|
void SendToClients(const sf::Packet& packet, const PlayerId skip_pid = 0);
|
||||||
void Send(ENetPeer* socket, sf::Packet& packet);
|
void Send(ENetPeer* socket, const sf::Packet& packet);
|
||||||
unsigned int OnConnect(ENetPeer* socket);
|
unsigned int OnConnect(ENetPeer* socket);
|
||||||
unsigned int OnDisconnect(Client& player);
|
unsigned int OnDisconnect(const Client& player);
|
||||||
unsigned int OnData(sf::Packet& packet, Client& player);
|
unsigned int OnData(sf::Packet& packet, Client& player);
|
||||||
|
|
||||||
void OnTraversalStateChanged() override;
|
void OnTraversalStateChanged() override;
|
||||||
|
@ -89,7 +89,7 @@ private:
|
||||||
void OnConnectFailed(u8) override {}
|
void OnConnectFailed(u8) override {}
|
||||||
void UpdatePadMapping();
|
void UpdatePadMapping();
|
||||||
void UpdateWiimoteMapping();
|
void UpdateWiimoteMapping();
|
||||||
std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal();
|
std::vector<std::pair<std::string, std::string>> GetInterfaceListInternal() const;
|
||||||
|
|
||||||
NetSettings m_settings;
|
NetSettings m_settings;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue