OpenTTD Source  20241108-master-g80f628063a
tcp_game.h File Reference

Basic functions to receive and send TCP packets for game purposes. More...

#include "os_abstraction.h"
#include "tcp.h"
#include "../network_type.h"
#include "../../core/pool_type.hpp"
#include <chrono>

Go to the source code of this file.

Data Structures

class  NetworkGameSocketHandler
 Base socket handler for all TCP sockets. More...
 

Typedefs

using CommandQueue = std::vector< CommandPacket >
 A "queue" of CommandPackets. More...
 

Enumerations

enum  PacketGameType : uint8_t {
  PACKET_SERVER_FULL , PACKET_SERVER_BANNED , PACKET_CLIENT_JOIN , PACKET_SERVER_ERROR ,
  PACKET_CLIENT_UNUSED , PACKET_SERVER_UNUSED , PACKET_SERVER_GAME_INFO , PACKET_CLIENT_GAME_INFO ,
  PACKET_SERVER_NEWGAME , PACKET_SERVER_SHUTDOWN , PACKET_SERVER_AUTH_REQUEST , PACKET_CLIENT_AUTH_RESPONSE ,
  PACKET_SERVER_ENABLE_ENCRYPTION , PACKET_CLIENT_IDENTIFY , PACKET_SERVER_CHECK_NEWGRFS , PACKET_CLIENT_NEWGRFS_CHECKED ,
  PACKET_SERVER_WELCOME , PACKET_SERVER_CLIENT_INFO , PACKET_CLIENT_GETMAP , PACKET_SERVER_WAIT ,
  PACKET_SERVER_MAP_BEGIN , PACKET_SERVER_MAP_SIZE , PACKET_SERVER_MAP_DATA , PACKET_SERVER_MAP_DONE ,
  PACKET_CLIENT_MAP_OK , PACKET_SERVER_JOIN , PACKET_SERVER_FRAME , PACKET_CLIENT_ACK ,
  PACKET_SERVER_SYNC , PACKET_CLIENT_COMMAND , PACKET_SERVER_COMMAND , PACKET_CLIENT_CHAT ,
  PACKET_SERVER_CHAT , PACKET_SERVER_EXTERNAL_CHAT , PACKET_CLIENT_RCON , PACKET_SERVER_RCON ,
  PACKET_CLIENT_MOVE , PACKET_SERVER_MOVE , PACKET_CLIENT_SET_NAME , PACKET_SERVER_CONFIG_UPDATE ,
  PACKET_CLIENT_QUIT , PACKET_SERVER_QUIT , PACKET_CLIENT_ERROR , PACKET_SERVER_ERROR_QUIT ,
  PACKET_END
}
 Enum with all types of TCP packets. More...
 

Detailed Description

Basic functions to receive and send TCP packets for game purposes.

Definition in file tcp_game.h.

Typedef Documentation

◆ CommandQueue

using CommandQueue = std::vector<CommandPacket>

A "queue" of CommandPackets.

Not a std::queue because, when paused, some commands remain on the queue. In other words, you do not always pop the first element from this queue.

Definition at line 138 of file tcp_game.h.

Enumeration Type Documentation

◆ PacketGameType

enum PacketGameType : uint8_t

Enum with all types of TCP packets.

For the exact meaning, look at NetworkGameSocketHandler.

Enumerator
PACKET_SERVER_FULL 

The server is full and has no place for you.

PACKET_SERVER_BANNED 

The server has banned you.

PACKET_CLIENT_JOIN 

The client telling the server it wants to join.

PACKET_SERVER_ERROR 

Server sending an error message to the client.

PACKET_CLIENT_UNUSED 

Unused.

PACKET_SERVER_UNUSED 

Unused.

PACKET_SERVER_GAME_INFO 

Information about the server.

PACKET_CLIENT_GAME_INFO 

Request information about the server.

PACKET_SERVER_NEWGAME 

The server is preparing to start a new game.

PACKET_SERVER_SHUTDOWN 

The server is shutting down.

PACKET_SERVER_AUTH_REQUEST 

The server requests the client to authenticate using a number of methods.

PACKET_CLIENT_AUTH_RESPONSE 

The client responds to the authentication request.

PACKET_SERVER_ENABLE_ENCRYPTION 

The server tells that authentication has completed and requests to enable encryption with the keys of the last PACKET_CLIENT_AUTH_RESPONSE.

PACKET_CLIENT_IDENTIFY 

Client telling the server the client's name and requested company.

PACKET_SERVER_CHECK_NEWGRFS 

Server sends NewGRF IDs and MD5 checksums for the client to check.

PACKET_CLIENT_NEWGRFS_CHECKED 

Client acknowledges that it has all required NewGRFs.

PACKET_SERVER_WELCOME 

Server welcomes you and gives you your ClientID.

PACKET_SERVER_CLIENT_INFO 

Server sends you information about a client.

PACKET_CLIENT_GETMAP 

Client requests the actual map.

PACKET_SERVER_WAIT 

Server tells the client there are some people waiting for the map as well.

PACKET_SERVER_MAP_BEGIN 

Server tells the client that it is beginning to send the map.

PACKET_SERVER_MAP_SIZE 

Server tells the client what the (compressed) size of the map is.

PACKET_SERVER_MAP_DATA 

Server sends bits of the map to the client.

PACKET_SERVER_MAP_DONE 

Server tells it has just sent the last bits of the map to the client.

PACKET_CLIENT_MAP_OK 

Client tells the server that it received the whole map.

PACKET_SERVER_JOIN 

Tells clients that a new client has joined.

PACKET_SERVER_FRAME 

Server tells the client what frame it is in, and thus to where the client may progress.

PACKET_CLIENT_ACK 

The client tells the server which frame it has executed.

PACKET_SERVER_SYNC 

Server tells the client what the random state should be.

PACKET_CLIENT_COMMAND 

Client executed a command and sends it to the server.

PACKET_SERVER_COMMAND 

Server distributes a command to (all) the clients.

PACKET_CLIENT_CHAT 

Client said something that should be distributed.

PACKET_SERVER_CHAT 

Server distributing the message of a client (or itself).

PACKET_SERVER_EXTERNAL_CHAT 

Server distributing the message from external source.

PACKET_CLIENT_RCON 

Client asks the server to execute some command.

PACKET_SERVER_RCON 

Response of the executed command on the server.

PACKET_CLIENT_MOVE 

A client would like to be moved to another company.

PACKET_SERVER_MOVE 

Server tells everyone that someone is moved to another company.

PACKET_CLIENT_SET_NAME 

A client changes its name.

PACKET_SERVER_CONFIG_UPDATE 

Some network configuration important to the client changed.

PACKET_CLIENT_QUIT 

A client tells the server it is going to quit.

PACKET_SERVER_QUIT 

A server tells that a client has quit.

PACKET_CLIENT_ERROR 

A client reports an error to the server.

PACKET_SERVER_ERROR_QUIT 

A server tells that a client has hit an error and did quit.

PACKET_END 

Must ALWAYS be on the end of this list!! (period)

Definition at line 25 of file tcp_game.h.