diff options
author | peter1138 <peter1138@openttd.org> | 2019-03-24 16:24:06 +0000 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2019-03-24 17:38:42 +0000 |
commit | 07de9d6c3f48b6a3b92e11d553aca145546c62ef (patch) | |
tree | fab2b0d98265ea5f0ca535ce3be68c57bf4c32ee | |
parent | b1fb3f4fb8c389d36ba670558a169578f7d142e2 (diff) | |
download | openttd-07de9d6c3f48b6a3b92e11d553aca145546c62ef.tar.xz |
Codechange: Use override keyword in networking classes.
-rw-r--r-- | src/network/core/tcp.h | 2 | ||||
-rw-r--r-- | src/network/core/tcp_admin.h | 2 | ||||
-rw-r--r-- | src/network/core/tcp_content.h | 2 | ||||
-rw-r--r-- | src/network/core/tcp_game.h | 2 | ||||
-rw-r--r-- | src/network/core/tcp_http.h | 6 | ||||
-rw-r--r-- | src/network/core/udp.h | 4 | ||||
-rw-r--r-- | src/network/network.cpp | 8 | ||||
-rw-r--r-- | src/network/network_admin.h | 16 | ||||
-rw-r--r-- | src/network/network_client.h | 56 | ||||
-rw-r--r-- | src/network/network_content.cpp | 4 | ||||
-rw-r--r-- | src/network/network_content.h | 20 | ||||
-rw-r--r-- | src/network/network_content_gui.cpp | 4 | ||||
-rw-r--r-- | src/network/network_server.h | 36 | ||||
-rw-r--r-- | src/network/network_udp.cpp | 18 |
14 files changed, 90 insertions, 90 deletions
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index 00642c2dd..243ec042d 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -40,7 +40,7 @@ public: */ bool IsConnected() const { return this->sock != INVALID_SOCKET; } - virtual NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; virtual void SendPacket(Packet *packet); SendPacketsState SendPackets(bool closing_down = false); diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 497c24b48..7bcc87840 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -481,7 +481,7 @@ protected: NetworkRecvStatus HandlePacket(Packet *p); public: - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; NetworkAdminSocketHandler(SOCKET s); ~NetworkAdminSocketHandler(); diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index c359fb667..689de7a01 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -98,7 +98,7 @@ struct ContentInfo { class NetworkContentSocketHandler : public NetworkTCPSocketHandler { protected: NetworkAddress client_addr; ///< The address we're connected to. - virtual void Close(); + void Close() override; bool ReceiveInvalidPacket(PacketContentType type); diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index c41ad4dc1..b392cf717 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -522,7 +522,7 @@ public: CommandQueue incoming_queue; ///< The command-queue awaiting handling uint last_packet; ///< Time we received the last frame. - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; /** * Close the network connection due to the given status. diff --git a/src/network/core/tcp_http.h b/src/network/core/tcp_http.h index ec969264b..5a5cdd9f2 100644 --- a/src/network/core/tcp_http.h +++ b/src/network/core/tcp_http.h @@ -60,7 +60,7 @@ public: return this->sock != INVALID_SOCKET; } - virtual NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; NetworkHTTPSocketHandler(SOCKET sock, HTTPCallback *callback, const char *host, const char *url, const char *data, int depth); @@ -106,13 +106,13 @@ public: free(this->url); } - virtual void OnFailure() + void OnFailure() override { this->callback->OnFailure(); free(this->data); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { new NetworkHTTPSocketHandler(s, this->callback, this->address.GetHostname(), this->url, this->data, this->depth); /* We've relinquished control of data now. */ diff --git a/src/network/core/udp.h b/src/network/core/udp.h index 2f77a94df..fab232492 100644 --- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -52,7 +52,7 @@ protected: /** The opened sockets. */ SocketList sockets; - NetworkRecvStatus CloseConnection(bool error = true); + NetworkRecvStatus CloseConnection(bool error = true) override; void ReceiveInvalidPacket(PacketUDPType, NetworkAddress *client_addr); @@ -235,7 +235,7 @@ public: virtual ~NetworkUDPSocketHandler() { this->Close(); } bool Listen(); - void Close(); + void Close() override; void SendPacket(Packet *p, NetworkAddress *recv, bool all = false, bool broadcast = false); void ReceivePackets(); diff --git a/src/network/network.cpp b/src/network/network.cpp index ea770e500..e437f4df0 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -576,12 +576,12 @@ class TCPQueryConnecter : TCPConnecter { public: TCPQueryConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { NetworkDisconnect(); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { _networking = true; new ClientNetworkGameSocketHandler(s); @@ -659,12 +659,12 @@ class TCPClientConnecter : TCPConnecter { public: TCPClientConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { NetworkError(STR_NETWORK_ERROR_NOCONNECTION); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { _networking = true; new ClientNetworkGameSocketHandler(s); diff --git a/src/network/network_admin.h b/src/network/network_admin.h index 6d06d5b9f..6ea373e8e 100644 --- a/src/network/network_admin.h +++ b/src/network/network_admin.h @@ -26,14 +26,14 @@ extern NetworkAdminSocketPool _networkadminsocket_pool; /** Class for handling the server side of the game connection. */ class ServerNetworkAdminSocketHandler : public NetworkAdminSocketPool::PoolItem<&_networkadminsocket_pool>, public NetworkAdminSocketHandler, public TCPListenHandler<ServerNetworkAdminSocketHandler, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_BANNED> { protected: - virtual NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_POLL(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_RCON(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p); - virtual NetworkRecvStatus Receive_ADMIN_PING(Packet *p); + NetworkRecvStatus Receive_ADMIN_JOIN(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_QUIT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_UPDATE_FREQUENCY(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_POLL(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_CHAT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_RCON(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_GAMESCRIPT(Packet *p) override; + NetworkRecvStatus Receive_ADMIN_PING(Packet *p) override; NetworkRecvStatus SendProtocol(); NetworkRecvStatus SendPong(uint32 d1); diff --git a/src/network/network_client.h b/src/network/network_client.h index 5e9988d9a..d0a9d07b1 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -42,33 +42,33 @@ protected: friend void NetworkClose(bool close_admins); static ClientNetworkGameSocketHandler *my_client; ///< This is us! - virtual NetworkRecvStatus Receive_SERVER_FULL(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_RCON(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p); - virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p); + NetworkRecvStatus Receive_SERVER_FULL(Packet *p) override; + NetworkRecvStatus Receive_SERVER_BANNED(Packet *p) override; + NetworkRecvStatus Receive_SERVER_ERROR(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMPANY_INFO(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEED_GAME_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_WAIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_JOIN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_FRAME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_SYNC(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CHAT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_QUIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p) override; + NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet *p) override; + NetworkRecvStatus Receive_SERVER_NEWGAME(Packet *p) override; + NetworkRecvStatus Receive_SERVER_RCON(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p) override; + NetworkRecvStatus Receive_SERVER_MOVE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p) override; + NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p) override; static NetworkRecvStatus SendNewGRFsOk(); static NetworkRecvStatus SendGetMap(); @@ -78,7 +78,7 @@ public: ClientNetworkGameSocketHandler(SOCKET s); ~ClientNetworkGameSocketHandler(); - NetworkRecvStatus CloseConnection(NetworkRecvStatus status); + NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override; void ClientError(NetworkRecvStatus res); static NetworkRecvStatus SendCompanyInformationQuery(); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 1a80c5d99..786f1c04a 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -724,13 +724,13 @@ public: */ NetworkContentConnecter(const NetworkAddress &address) : TCPConnecter(address) {} - virtual void OnFailure() + void OnFailure() override { _network_content_client.isConnecting = false; _network_content_client.OnConnect(false); } - virtual void OnConnect(SOCKET s) + void OnConnect(SOCKET s) override { assert(_network_content_client.sock == INVALID_SOCKET); _network_content_client.isConnecting = false; diff --git a/src/network/network_content.h b/src/network/network_content.h index b1e9dd66b..7a96a73c0 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -80,20 +80,20 @@ protected: friend class NetworkContentConnecter; - virtual bool Receive_SERVER_INFO(Packet *p); - virtual bool Receive_SERVER_CONTENT(Packet *p); + bool Receive_SERVER_INFO(Packet *p) override; + bool Receive_SERVER_CONTENT(Packet *p) override; ContentInfo *GetContent(ContentID cid); void DownloadContentInfo(ContentID cid); - void OnConnect(bool success); - void OnDisconnect(); - void OnReceiveContentInfo(const ContentInfo *ci); - void OnDownloadProgress(const ContentInfo *ci, int bytes); - void OnDownloadComplete(ContentID cid); + void OnConnect(bool success) override; + void OnDisconnect() override; + void OnReceiveContentInfo(const ContentInfo *ci) override; + void OnDownloadProgress(const ContentInfo *ci, int bytes) override; + void OnDownloadComplete(ContentID cid) override; - void OnFailure(); - void OnReceiveData(const char *data, size_t length); + void OnFailure() override; + void OnReceiveData(const char *data, size_t length) override; bool BeforeDownload(); void AfterDownload(); @@ -109,7 +109,7 @@ public: void Connect(); void SendReceive(); - void Close(); + void Close() override; void RequestContentList(ContentType type); void RequestContentList(uint count, const ContentID *content_ids); diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 49ecf2b24..406c6aa05 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -115,7 +115,7 @@ BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow( _network_content_client.RemoveCallback(this); } -/* virtual */ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const +void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const { if (widget != WID_NCDS_BACKGROUND) return; @@ -144,7 +144,7 @@ BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow( DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER); } -/* virtual */ void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes) +void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes) { if (ci->id != this->cur_id) { strecpy(this->name, ci->filename, lastof(this->name)); diff --git a/src/network/network_server.h b/src/network/network_server.h index 1cd8feb67..f35192a11 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -26,22 +26,22 @@ extern NetworkClientSocketPool _networkclientsocket_pool; /** Class for handling the server side of the game connection. */ class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler<ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED> { protected: - virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMPANY_INFO(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_RCON(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p); - virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p); + NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMPANY_INFO(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_ACK(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_SET_PASSWORD(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_QUIT(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_RCON(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet *p) override; + NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p) override; NetworkRecvStatus SendCompanyInfo(); NetworkRecvStatus SendNewGRFCheck(); @@ -79,8 +79,8 @@ public: ServerNetworkGameSocketHandler(SOCKET s); ~ServerNetworkGameSocketHandler(); - virtual Packet *ReceivePacket(); - NetworkRecvStatus CloseConnection(NetworkRecvStatus status); + virtual Packet *ReceivePacket() override; + NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override; void GetClientName(char *client_name, const char *last) const; NetworkRecvStatus SendMap(); diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 289b07520..cee230c88 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -117,8 +117,8 @@ void NetworkUDPQueryServer(NetworkAddress address, bool manually) /** Helper class for connecting to the master server. */ class MasterNetworkUDPSocketHandler : public NetworkUDPSocketHandler { protected: - virtual void Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr); - virtual void Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr); + void Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr) override; + void Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr) override; public: /** * Create the socket. @@ -148,9 +148,9 @@ void MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, Networ /** Helper class for handling all server side communication. */ class ServerNetworkUDPSocketHandler : public NetworkUDPSocketHandler { protected: - virtual void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr); - virtual void Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr); - virtual void Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr); + void Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr) override; + void Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr) override; + void Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr) override; public: /** * Create the socket. @@ -324,10 +324,10 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, Networ /** Helper class for handling all client side communication. */ class ClientNetworkUDPSocketHandler : public NetworkUDPSocketHandler { protected: - virtual void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr); - virtual void Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr); - virtual void Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr); - virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config); + void Receive_SERVER_RESPONSE(Packet *p, NetworkAddress *client_addr) override; + void Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr) override; + void Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr) override; + void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) override; public: virtual ~ClientNetworkUDPSocketHandler() {} }; |