From 9cc9a9702b0a2fc6d03f84f6598c1947125fe376 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 8 Feb 2026 13:16:38 +0100 Subject: [PATCH] Codechange: add missing return/parameters to protocol implementation --- src/network/core/tcp_admin.h | 1 + src/network/core/tcp_game.h | 43 ++++++++++++++++++++ src/network/network_admin.cpp | 61 +++++++++++++++++++++++----- src/network/network_client.cpp | 51 +++++++++++++++++++---- src/network/network_server.cpp | 74 ++++++++++++++++++++++++++-------- 5 files changed, 198 insertions(+), 32 deletions(-) diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index b7dd63f72c..2ae518d4c6 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -516,6 +516,7 @@ protected: * The encryption uses the shared keys generated by the last AUTH_REQUEST key exchange. * 24 * uint8_t Nonce for encrypted connection. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p); diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index 7ce6646edb..05a577a8ae 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -147,12 +147,14 @@ protected: /** * Notification that the server is full. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_FULL(Packet &p); /** * Notification that the client trying to join is banned. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_BANNED(Packet &p); @@ -166,6 +168,7 @@ protected: * string Client's unique identifier (removed in 1.0). * * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet &p); @@ -173,12 +176,14 @@ protected: * The client made an error: * uint8_t Error code caused (see NetworkErrorCode). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet &p); /** * Request game information. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_GAME_INFO(Packet &p); @@ -186,6 +191,7 @@ protected: * Sends information about the game. * Serialized NetworkGameInfo. See game_info.h for details. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_GAME_INFO(Packet &p); @@ -196,6 +202,7 @@ protected: * string Name of the client. * string Public key of the client. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet &p); @@ -204,6 +211,7 @@ protected: * string Name of the client (max NETWORK_NAME_LENGTH). * uint8_t ID of the company to play as (1..MAX_COMPANIES, or COMPANY_SPECTATOR). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_IDENTIFY(Packet &p); @@ -213,6 +221,7 @@ protected: * 32 * uint8_t Public key of the server. * 24 * uint8_t Nonce for the key exchange. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_AUTH_REQUEST(Packet &p); @@ -222,6 +231,7 @@ protected: * 16 * uint8_t Message authentication code. * 8 * uint8_t Random message that got encoded and signed. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_AUTH_RESPONSE(Packet &p); @@ -230,6 +240,7 @@ protected: * The encryption uses the shared keys generated by the last AUTH_REQUEST key exchange. * 24 * uint8_t Nonce for encrypted connection. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_ENABLE_ENCRYPTION(Packet &p); @@ -237,12 +248,14 @@ protected: * The client is joined and ready to receive their map: * uint32_t Own client ID. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet &p); /** * Request the map from the server. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet &p); @@ -250,6 +263,7 @@ protected: * Notification that another client is currently receiving the map: * uint8_t Number of clients waiting in front of you. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet &p); @@ -257,6 +271,7 @@ protected: * Sends that the server will begin with sending the map to the client: * uint32_t Current frame. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet &p); @@ -264,6 +279,7 @@ protected: * Sends the size of the map to the client. * uint32_t Size of the (compressed) map (in bytes). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet &p); @@ -271,18 +287,21 @@ protected: * Sends the data of the map to the client: * Contains a part of the map (until max size of packet). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_MAP_DATA(Packet &p); /** * Sends that all data of the map are sent to the client: * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_MAP_DONE(Packet &p); /** * Tell the server that we are done receiving/loading the map. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_MAP_OK(Packet &p); @@ -290,6 +309,7 @@ protected: * A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: * uint32_t ID of the client that just joined the game. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet &p); @@ -301,6 +321,7 @@ protected: * uint32_t General seed 2 (dependent on compile settings, not default). * uint8_t Random token to validate the client is actually listening (only occasionally present). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet &p); @@ -310,6 +331,7 @@ protected: * uint32_t General seed 1. * uint32_t General seed 2 (dependent on compile settings, not default). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet &p); @@ -318,6 +340,7 @@ protected: * uint32_t Current frame counter of the client. * uint8_t The random token that the server sent in the PACKET_SERVER_FRAME packet. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet &p); @@ -329,6 +352,7 @@ protected: * The content differs per command and can change without notification. * uint8_t ID of the callback. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet &p); @@ -341,6 +365,7 @@ protected: * uint8_t ID of the callback. * uint32_t Frame of execution. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet &p); @@ -352,6 +377,7 @@ protected: * string Message (max NETWORK_CHAT_LENGTH). * uint64_t data (used e.g. for 'give money' actions). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet &p); @@ -362,6 +388,7 @@ protected: * string Message (max NETWORK_CHAT_LENGTH). * uint64_t data (used e.g. for 'give money' actions). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet &p); @@ -372,6 +399,7 @@ protected: * string Name of the user who sent the message. * string Message (max NETWORK_CHAT_LENGTH). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet &p); @@ -379,12 +407,14 @@ protected: * Gives the client a new name: * string New name of the client. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_SET_NAME(Packet &p); /** * The client is quitting the game. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_QUIT(Packet &p); @@ -392,6 +422,7 @@ protected: * The client made an error and is quitting the game. * uint8_t Error of the code caused (see NetworkErrorCode). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet &p); @@ -399,6 +430,7 @@ protected: * Notification that a client left the game: * uint32_t ID of the client. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet &p); @@ -407,18 +439,21 @@ protected: * uint32_t ID of the client that caused the error. * uint8_t Code of the error caused (see NetworkErrorCode). * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet &p); /** * Let the clients know that the server is closing. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_SHUTDOWN(Packet &p); /** * Let the clients know that the server is loading a new map. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_NEWGAME(Packet &p); @@ -427,6 +462,7 @@ protected: * uint16_t Colour code. * string Output of the RCon command * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_RCON(Packet &p); @@ -435,6 +471,7 @@ protected: * string RCon password. * string Command to be executed. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_RCON(Packet &p); @@ -444,12 +481,14 @@ protected: * uint32_t GRF ID * 16 * uint8_t MD5 checksum of the GRF * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet &p); /** * Tell the server that we have the required GRFs * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_NEWGRFS_CHECKED(Packet &p); @@ -458,6 +497,7 @@ protected: * uint32_t ID of the client. * uint8_t ID of the new company. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet &p); @@ -465,6 +505,7 @@ protected: * Request the server to move this client into another company: * uint8_t ID of the company the client wants to join. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_CLIENT_MOVE(Packet &p); @@ -473,6 +514,7 @@ protected: * uint8_t Maximum number of companies allowed. * uint8_t Maximum number of spectators allowed. * @param p The packet that was just received. + * @return The state the network should have. */ virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet &p); @@ -491,6 +533,7 @@ public: /** * Close the network connection due to the given status. * @param status The reason the connection got closed. + * @return The state the network should have. */ virtual NetworkRecvStatus CloseConnection(NetworkRecvStatus status) = 0; ~NetworkGameSocketHandler() override = default; diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index e45defaa69..2d4e153a32 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -128,6 +128,7 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler() /** * Send an error to the admin. * @param error The error to send. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode error) { @@ -146,7 +147,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode er return this->CloseConnection(true); } -/** Send the protocol version to the admin. */ +/** + * Send the protocol version to the admin. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendProtocol() { this->status = ADMIN_STATUS_ACTIVE; @@ -168,7 +172,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendProtocol() return this->SendWelcome(); } -/** Send a welcome message to the admin. */ +/** + * Send a welcome message to the admin. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendWelcome() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_WELCOME); @@ -189,7 +196,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendWelcome() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the admin we started a new game. */ +/** + * Tell the admin we started a new game. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendNewGame() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_NEWGAME); @@ -197,7 +207,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendNewGame() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the admin we're shutting down. */ +/** + * Tell the admin we're shutting down. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendShutdown() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_SHUTDOWN); @@ -205,7 +218,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendShutdown() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the admin the date. */ +/** + * Tell the admin the date. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendDate() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_DATE); @@ -219,6 +235,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendDate() /** * Tell the admin that a client joined. * @param client_id The client that joined. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientJoin(ClientID client_id) { @@ -234,6 +251,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientJoin(ClientID clien * Send an initial set of data from some client's information. * @param cs The socket of the client. * @param ci The information about the client. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci) { @@ -258,6 +276,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkC /** * Send an update for some client's information. * @param ci The information about a client. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientUpdate(const NetworkClientInfo *ci) { @@ -275,6 +294,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientUpdate(const Networ /** * Tell the admin that a client quit. * @param client_id The client that quit. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientQuit(ClientID client_id) { @@ -290,6 +310,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientQuit(ClientID clien * Tell the admin that a client made an error. * @param client_id The client that made the error. * @param error The error that was made. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientError(ClientID client_id, NetworkErrorCode error) { @@ -305,6 +326,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientError(ClientID clie /** * Tell the admin that a new company was founded. * @param company_id The company that was founded. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyNew(CompanyID company_id) { @@ -319,6 +341,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyNew(CompanyID comp /** * Send the admin some information about a company. * @param c The company to send the information about. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company *c) { @@ -342,6 +365,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company /** * Send an update about a company. * @param c The company to send the update of. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Company *c) { @@ -363,6 +387,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Compa * Tell the admin that a company got removed. * @param company_id The company that got removed. * @param acrr The reason for removal, e.g. bankruptcy or merger. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason acrr) { @@ -376,7 +401,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyRemove(CompanyID c return NETWORK_RECV_STATUS_OKAY; } -/** Send economic information of all companies. */ +/** + * Send economic information of all companies. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy() { for (const Company *company : Company::Iterate()) { @@ -407,7 +435,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy() return NETWORK_RECV_STATUS_OKAY; } -/** Send statistics about the companies. */ +/** + * Send statistics about the companies. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats() { /* Fetch the latest version of the stats. */ @@ -441,6 +472,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats() * @param client_id The origin of the chat message. * @param msg The actual message. * @param data Arbitrary extra data. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data) { @@ -459,6 +491,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action /** * Send a notification indicating the rcon command has completed. * @param command The original command sent. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(std::string_view command) { @@ -474,6 +507,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(std::string_view * Send the reply of an rcon command. * @param colour The colour of the text. * @param result The result of the command. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16_t colour, std::string_view result) { @@ -527,6 +561,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet &p) * Send console output of other clients. * @param origin The origin of the string. * @param string The string that's put on the console. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(std::string_view origin, std::string_view string) { @@ -548,6 +583,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(std::string_view /** * Send GameScript JSON output. * @param json The JSON string. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(std::string_view json) { @@ -559,7 +595,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(std::string_vi return NETWORK_RECV_STATUS_OKAY; } -/** Send ping-reply (pong) to admin **/ +/** + * Send ping-reply (pong) to admin. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32_t d1) { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_PONG); @@ -570,7 +609,10 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32_t d1) return NETWORK_RECV_STATUS_OKAY; } -/** Send the names of the commands. */ +/** + * Send the names of the commands. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_CMD_NAMES); @@ -604,6 +646,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() * Send a command for logging purposes. * @param client_id The client executing the command. * @param cp The command that would be executed. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID client_id, const CommandPacket &cp) { diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 076c708111..f0698ad3c5 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -282,7 +282,10 @@ NetworkJoinInfo _network_join; * Sending functions ************/ -/** Tell the server we would like to join. */ +/** + * Tell the server we would like to join. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin() { Debug(net, 9, "Client::SendJoin()"); @@ -301,6 +304,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendJoin() return NETWORK_RECV_STATUS_OKAY; } +/** + * Identify ourselves to the server. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendIdentify() { Debug(net, 9, "Client::SendIdentify()"); @@ -312,7 +319,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendIdentify() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the server we got all the NewGRFs. */ +/** + * Tell the server we got all the NewGRFs. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendNewGRFsOk() { Debug(net, 9, "Client::SendNewGRFsOk()"); @@ -324,6 +334,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendNewGRFsOk() /** * Set the game password as requested. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendAuthResponse() { @@ -336,7 +347,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendAuthResponse() return NETWORK_RECV_STATUS_OKAY; } -/** Request the map from the server. */ +/** + * Request the map from the server. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap() { Debug(net, 9, "Client::SendGetMap()"); @@ -349,7 +363,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendGetMap() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the server we received the complete map. */ +/** + * Tell the server we received the complete map. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendMapOk() { Debug(net, 9, "Client::SendMapOk()"); @@ -362,7 +379,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendMapOk() return NETWORK_RECV_STATUS_OKAY; } -/** Send an acknowledgement from the server's ticks. */ +/** + * Send an acknowledgement from the server's ticks. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendAck() { Debug(net, 9, "Client::SendAck()"); @@ -378,6 +398,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendAck() /** * Send a command to the server. * @param cp The command to send. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand(const CommandPacket &cp) { @@ -390,7 +411,15 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand(const CommandPacke return NETWORK_RECV_STATUS_OKAY; } -/** Send a chat-packet over the network */ +/** + * Send a chat-packet over the network. + * @param action The associated action. + * @param type The type of destination (all, team, client). + * @param dest The destination team/client. + * @param msg The actual message. + * @param data Optional arbitrary extra data. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data) { Debug(net, 9, "Client::SendChat(): action={}, type={}, dest={}", action, type, dest); @@ -407,7 +436,11 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, return NETWORK_RECV_STATUS_OKAY; } -/** Send an error-packet over the network */ +/** + * Send an error-packet over the network. + * @param errorno The numeric error. + * @return The new state the network. + */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendError(NetworkErrorCode errorno) { Debug(net, 9, "Client::SendError(): errorno={}", errorno); @@ -422,6 +455,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendError(NetworkErrorCode err /** * Tell the server that we like to change the name of the client. * @param name The new name. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetName(const std::string &name) { @@ -436,6 +470,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendSetName(const std::string /** * Tell the server we would like to quit. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendQuit() { @@ -451,6 +486,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendQuit() * Send a console command. * @param pass The password for the remote command. * @param command The actual command. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon(std::string_view pass, std::string_view command) { @@ -466,6 +502,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendRCon(std::string_view pass /** * Ask the server to move us. * @param company The company to move to. + * @return The new state the network. */ NetworkRecvStatus ClientNetworkGameSocketHandler::SendMove(CompanyID company) { diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 1dbd4e0d5c..133bf7e5b6 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -323,6 +323,7 @@ static void NetworkHandleCommandQueue(NetworkClientSocket *cs); /** * Send the client information about a client. * @param ci The client to send information about. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendClientInfo(NetworkClientInfo *ci) { @@ -340,7 +341,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendClientInfo(NetworkClientIn return NETWORK_RECV_STATUS_OKAY; } -/** Send the client information about the server. */ +/** + * Send the client information about the server. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfo() { Debug(net, 9, "client[{}] SendGameInfo()", this->client_id); @@ -357,6 +361,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfo() * Send an error to the client, and close its connection. * @param error The error to disconnect for. * @param reason In case of kicking a client, specifies the reason for kicking the client. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode error, std::string_view reason) { @@ -402,7 +407,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err return this->CloseConnection(NETWORK_RECV_STATUS_SERVER_ERROR); } -/** Send the check for the NewGRFs. */ +/** + * Send the check for the NewGRFs. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck() { Debug(net, 9, "client[{}] SendNewGRFCheck()", this->client_id); @@ -431,7 +439,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck() return NETWORK_RECV_STATUS_OKAY; } -/** Request the game password. */ +/** + * Request the game password. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendAuthRequest() { Debug(net, 9, "client[{}] SendAuthRequest()", this->client_id); @@ -456,7 +467,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendAuthRequest() return NETWORK_RECV_STATUS_OKAY; } -/** Notify the client that the authentication has completed and tell that for the remainder of this socket encryption is enabled. */ +/** + * Notify the client that the authentication has completed and tell that for the remainder of this socket encryption is enabled. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendEnableEncryption() { Debug(net, 9, "client[{}] SendEnableEncryption()", this->client_id); @@ -470,7 +484,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendEnableEncryption() return NETWORK_RECV_STATUS_OKAY; } -/** Send the client a welcome message with some basic information. */ +/** + * Send the client a welcome message with some basic information. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome() { Debug(net, 9, "client[{}] SendWelcome()", this->client_id); @@ -500,7 +517,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome() return this->SendClientInfo(NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER)); } -/** Tell the client that its put in a waiting queue. */ +/** + * Tell the client that its put in a waiting queue. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWait() { Debug(net, 9, "client[{}] SendWait()", this->client_id); @@ -548,7 +568,10 @@ void ServerNetworkGameSocketHandler::CheckNextClientToSendMap(NetworkClientSocke } } -/** This sends the map to the client */ +/** + * This sends the map to the client. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() { if (this->status < STATUS_AUTHORIZED) { @@ -601,6 +624,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap() /** * Tell that a client joined. * @param client_id The client that joined. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendJoin(ClientID client_id) { @@ -614,7 +638,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendJoin(ClientID client_id) return NETWORK_RECV_STATUS_OKAY; } -/** Tell the client that they may run to a particular frame. */ +/** + * Tell the client that they may run to a particular frame. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendFrame() { auto p = std::make_unique(this, PACKET_SERVER_FRAME); @@ -637,7 +664,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendFrame() return NETWORK_RECV_STATUS_OKAY; } -/** Request the client to sync. */ +/** + * Request the client to sync. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendSync() { Debug(net, 9, "client[{}] SendSync(), frame_counter={}, sync_seed_1={}", this->client_id, _frame_counter, _sync_seed_1); @@ -656,6 +686,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendSync() /** * Send a command to the client to execute. * @param cp The command to send. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand(const CommandPacket &cp) { @@ -678,6 +709,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand(const CommandPacke * @param self_send Whether we did send the message. * @param msg The actual message. * @param data Arbitrary extra data. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, std::string_view msg, int64_t data) { @@ -703,6 +735,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, * @param colour TextColour to use for the message. * @param user Name of the user who sent the message. * @param msg The actual message. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg) { @@ -725,6 +758,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(std::string_v * Tell the client another client quit with an error. * @param client_id The client that quit. * @param errorno The reason the client quit. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendErrorQuit(ClientID client_id, NetworkErrorCode errorno) { @@ -742,6 +776,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendErrorQuit(ClientID client_ /** * Tell the client another client quit. * @param client_id The client that quit. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendQuit(ClientID client_id) { @@ -755,7 +790,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendQuit(ClientID client_id) return NETWORK_RECV_STATUS_OKAY; } -/** Tell the client we're shutting down. */ +/** + * Tell the client we're shutting down. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendShutdown() { Debug(net, 9, "client[{}] SendShutdown()", this->client_id); @@ -765,7 +803,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendShutdown() return NETWORK_RECV_STATUS_OKAY; } -/** Tell the client we're starting a new game. */ +/** + * Tell the client we're starting a new game. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGame() { Debug(net, 9, "client[{}] SendNewGame()", this->client_id); @@ -779,6 +820,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGame() * Send the result of a console action. * @param colour The colour of the result. * @param command The command that was executed. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16_t colour, std::string_view command) { @@ -796,6 +838,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16_t colour * Tell that a client moved to another company. * @param client_id The client that moved. * @param company_id The company the client moved to. + * @return The new state the network. */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMove(ClientID client_id, CompanyID company_id) { @@ -809,7 +852,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMove(ClientID client_id, C return NETWORK_RECV_STATUS_OKAY; } -/** Send an update about the max company/spectator counts. */ +/** + * Send an update about the max company/spectator counts. + * @return The new state the network. + */ NetworkRecvStatus ServerNetworkGameSocketHandler::SendConfigUpdate() { Debug(net, 9, "client[{}] SendConfigUpdate()", this->client_id); @@ -1049,10 +1095,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet & return this->SendError(NETWORK_ERROR_NOT_EXPECTED); } -/** - * The client has done a command and wants us to handle it - * @param p the packet in which the command was sent - */ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet &p) { /* The client was never joined.. so this is impossible, right?