@@ -191,15 +191,15 @@ protected:
|
||||
* Try to join the server:
|
||||
* string OpenTTD revision (norev000 if no revision).
|
||||
* string Name of the client (max NETWORK_NAME_LENGTH).
|
||||
* uint8 ID of the company to play as (1..MAX_COMPANIES).
|
||||
* uint8 ID of the clients Language.
|
||||
* uint8_t ID of the company to play as (1..MAX_COMPANIES).
|
||||
* uint8_t ID of the clients Language.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p);
|
||||
|
||||
/**
|
||||
* The client made an error:
|
||||
* uint8 Error code caused (see NetworkErrorCode).
|
||||
* uint8_t Error code caused (see NetworkErrorCode).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p);
|
||||
@@ -226,9 +226,9 @@ protected:
|
||||
|
||||
/**
|
||||
* Send information about a client:
|
||||
* uint32 ID of the client (always unique on a server. 1 = server, 0 is invalid).
|
||||
* uint8 ID of the company the client is playing as (255 for spectators).
|
||||
* string Name of the client.
|
||||
* uint32_t ID of the client (always unique on a server. 1 = server, 0 is invalid).
|
||||
* uint8_t ID of the company the client is playing as (255 for spectators).
|
||||
* string Name of the client.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p);
|
||||
@@ -241,32 +241,32 @@ protected:
|
||||
|
||||
/**
|
||||
* Indication to the client that the server needs a company password:
|
||||
* uint32 Generation seed.
|
||||
* string Network ID of the server.
|
||||
* uint32_t Generation seed.
|
||||
* string Network ID of the server.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p);
|
||||
|
||||
/**
|
||||
* Send a password to the server to authorize:
|
||||
* uint8 Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* uint8_t Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p);
|
||||
|
||||
/**
|
||||
* Send a password to the server to authorize
|
||||
* uint8 Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* uint8_t Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p);
|
||||
|
||||
/**
|
||||
* Send a password to the server to authorize
|
||||
* uint8 Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* uint8_t Password type (see NetworkPasswordType).
|
||||
* string The password.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_SETTINGS_PASSWORD(Packet *p);
|
||||
@@ -280,37 +280,37 @@ protected:
|
||||
|
||||
/**
|
||||
* The client is joined and ready to receive their map:
|
||||
* uint32 Own client ID.
|
||||
* uint32 Generation seed.
|
||||
* string Network ID of the server.
|
||||
* uint32_t Own client ID.
|
||||
* uint32_t Generation seed.
|
||||
* string Network ID of the server.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p);
|
||||
|
||||
/**
|
||||
* Request the map from the server.
|
||||
* uint32 NewGRF version (release versions of OpenTTD only).
|
||||
* uint32_t NewGRF version (release versions of OpenTTD only).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p);
|
||||
|
||||
/**
|
||||
* Notification that another client is currently receiving the map:
|
||||
* uint8 Number of clients waiting in front of you.
|
||||
* uint8_t Number of clients waiting in front of you.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends that the server will begin with sending the map to the client:
|
||||
* uint32 Current frame.
|
||||
* uint32_t Current frame.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends the size of the map to the client.
|
||||
* uint32 Size of the (compressed) map (in bytes).
|
||||
* uint32_t Size of the (compressed) map (in bytes).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p);
|
||||
@@ -336,93 +336,93 @@ protected:
|
||||
|
||||
/**
|
||||
* A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO:
|
||||
* uint32 ID of the client that just joined the game.
|
||||
* uint32_t ID of the client that just joined the game.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends the current frame counter to the client:
|
||||
* uint32 Frame counter
|
||||
* uint32 Frame counter max (how far may the client walk before the server?)
|
||||
* uint32 General seed 1 (dependent on compile settings, not default).
|
||||
* uint32 General seed 2 (dependent on compile settings, not default).
|
||||
* uint8 Random token to validate the client is actually listening (only occasionally present).
|
||||
* uint32_t Frame counter
|
||||
* uint32_t Frame counter max (how far may the client walk before the server?)
|
||||
* uint32_t General seed 1 (dependent on compile settings, not default).
|
||||
* 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.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends a sync-check to the client:
|
||||
* uint32 Frame counter.
|
||||
* uint32 General seed 1.
|
||||
* uint32 General seed 2 (dependent on compile settings, not default).
|
||||
* uint32_t Frame counter.
|
||||
* uint32_t General seed 1.
|
||||
* uint32_t General seed 2 (dependent on compile settings, not default).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p);
|
||||
|
||||
/**
|
||||
* Tell the server we are done with this frame:
|
||||
* uint32 Current frame counter of the client.
|
||||
* uint8 The random token that the server sent in the PACKET_SERVER_FRAME packet.
|
||||
* 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.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet *p);
|
||||
|
||||
/**
|
||||
* Send a DoCommand to the Server:
|
||||
* uint8 ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32 ID of the command (see command.h).
|
||||
* uint32 P1 (free variables used in DoCommand).
|
||||
* uint32 P2
|
||||
* uint32 Tile where this is taking place.
|
||||
* string Text.
|
||||
* uint8 ID of the callback.
|
||||
* uint8_t ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32_t ID of the command (see command.h).
|
||||
* uint32_t P1 (free variables used in DoCommand).
|
||||
* uint32_t P2
|
||||
* uint32_t Tile where this is taking place.
|
||||
* string Text.
|
||||
* uint8_t ID of the callback.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends a DoCommand to the client:
|
||||
* uint8 ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32 ID of the command (see command.h).
|
||||
* uint32 P1 (free variable used in DoCommand).
|
||||
* uint32 P2.
|
||||
* uint32 Tile where this is taking place.
|
||||
* string Text.
|
||||
* uint8 ID of the callback.
|
||||
* uint32 Frame of execution.
|
||||
* uint8_t ID of the company (0..MAX_COMPANIES-1).
|
||||
* uint32_t ID of the command (see command.h).
|
||||
* uint32_t P1 (free variable used in DoCommand).
|
||||
* uint32_t P2.
|
||||
* uint32_t Tile where this is taking place.
|
||||
* string Text.
|
||||
* uint8_t ID of the callback.
|
||||
* uint32_t Frame of execution.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends a chat-packet to the server:
|
||||
* uint8 ID of the action (see NetworkAction).
|
||||
* uint8 ID of the destination type (see DestType).
|
||||
* uint32 ID of the client or company (destination of the chat).
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* uint64 data (used e.g. for 'give money' actions).
|
||||
* uint8_t ID of the action (see NetworkAction).
|
||||
* uint8_t ID of the destination type (see DestType).
|
||||
* uint32_t ID of the client or company (destination of the chat).
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* uint64_t data (used e.g. for 'give money' actions).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends a chat-packet to the client:
|
||||
* uint8 ID of the action (see NetworkAction).
|
||||
* uint32 ID of the client (origin of the chat).
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* uint64 data (used e.g. for 'give money' actions).
|
||||
* uint8_t ID of the action (see NetworkAction).
|
||||
* uint32_t ID of the client (origin of the chat).
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* uint64_t data (used e.g. for 'give money' actions).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p);
|
||||
|
||||
/**
|
||||
* Sends a chat-packet for external source to the client:
|
||||
* string Name of the source this message came from.
|
||||
* uint16 TextColour to use for the message.
|
||||
* string Name of the user who sent the messsage.
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* string Name of the source this message came from.
|
||||
* uint16_t TextColour to use for the message.
|
||||
* string Name of the user who sent the messsage.
|
||||
* string Message (max NETWORK_CHAT_LENGTH).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet *p);
|
||||
@@ -449,7 +449,7 @@ protected:
|
||||
|
||||
/**
|
||||
* The client made an error and is quitting the game.
|
||||
* uint8 Error of the code caused (see NetworkErrorCode).
|
||||
* uint8_t Error of the code caused (see NetworkErrorCode).
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p);
|
||||
@@ -460,15 +460,15 @@ protected:
|
||||
|
||||
/**
|
||||
* Notification that a client left the game:
|
||||
* uint32 ID of the client.
|
||||
* uint32_t ID of the client.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p);
|
||||
|
||||
/**
|
||||
* Inform all clients that one client made an error and thus has quit/been disconnected:
|
||||
* uint32 ID of the client that caused the error.
|
||||
* uint8 Code of the error caused (see NetworkErrorCode).
|
||||
* 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.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p);
|
||||
@@ -487,7 +487,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Send the result of an issues RCon command back to the client:
|
||||
* uint16 Colour code.
|
||||
* uint16_t Colour code.
|
||||
* string Output of the RCon command
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -503,9 +503,9 @@ protected:
|
||||
|
||||
/**
|
||||
* Sends information about all used GRFs to the client:
|
||||
* uint8 Amount of GRFs (the following data is repeated this many times, i.e. per GRF data).
|
||||
* uint32 GRF ID
|
||||
* 16 * uint8 MD5 checksum of the GRF
|
||||
* uint8_t Amount of GRFs (the following data is repeated this many times, i.e. per GRF data).
|
||||
* uint32_t GRF ID
|
||||
* 16 * uint8_t MD5 checksum of the GRF
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p);
|
||||
@@ -518,15 +518,15 @@ protected:
|
||||
|
||||
/**
|
||||
* Move a client from one company into another:
|
||||
* uint32 ID of the client.
|
||||
* uint8 ID of the new company.
|
||||
* uint32_t ID of the client.
|
||||
* uint8_t ID of the new company.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p);
|
||||
|
||||
/**
|
||||
* Request the server to move this client into another company:
|
||||
* uint8 ID of the company the client wants to join.
|
||||
* uint8_t ID of the company the client wants to join.
|
||||
* string Password, if the company is password protected.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
@@ -534,15 +534,15 @@ protected:
|
||||
|
||||
/**
|
||||
* Update the clients knowledge of which company is password protected:
|
||||
* uint16 Bitwise representation of each company
|
||||
* uint16_t Bitwise representation of each company
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p);
|
||||
|
||||
/**
|
||||
* Update the clients knowledge of the max settings:
|
||||
* uint8 Maximum number of companies allowed.
|
||||
* uint8 Maximum number of spectators allowed.
|
||||
* uint8_t Maximum number of companies allowed.
|
||||
* uint8_t Maximum number of spectators allowed.
|
||||
* @param p The packet that was just received.
|
||||
*/
|
||||
virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p);
|
||||
@@ -551,12 +551,12 @@ protected:
|
||||
|
||||
NetworkGameSocketHandler(SOCKET s);
|
||||
public:
|
||||
ClientID client_id; ///< Client identifier
|
||||
uint32 last_frame; ///< Last frame we have executed
|
||||
uint32 last_frame_server; ///< Last frame the server has executed
|
||||
CommandQueue incoming_queue; ///< The command-queue awaiting handling
|
||||
ClientID client_id; ///< Client identifier
|
||||
uint32_t last_frame; ///< Last frame we have executed
|
||||
uint32_t last_frame_server; ///< Last frame the server has executed
|
||||
CommandQueue incoming_queue; ///< The command-queue awaiting handling
|
||||
std::chrono::steady_clock::time_point last_packet; ///< Time we received the last frame.
|
||||
PacketGameType last_pkt_type;///< Last received packet type
|
||||
PacketGameType last_pkt_type; ///< Last received packet type
|
||||
|
||||
NetworkRecvStatus CloseConnection(bool error = true) override;
|
||||
|
||||
|
Reference in New Issue
Block a user