OpenTTD Source 20260421-master-gc2fbc6fdeb
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 <chrono>

Go to the source code of this file.

Data Structures

struct  IsEnumPacketType< PacketGameType >
 Mark PacketGameType as PacketType. More...
class  NetworkGameSocketHandler
 Base socket handler for all TCP sockets. More...

Typedefs

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

Enumerations

enum class  PacketGameType : uint8_t {
  ServerFull , ServerBanned , ClientJoin , ServerError ,
  ClientUnused , ServerUnused , ServerGameInfo , ClientGameInfo ,
  ServerNewGame , ServerShutdown , ServerAuthenticationRequest , ClientAuthenticationResponse ,
  ServerEnableEncryption , ClientIdentify , ServerCheckNewGRFs , ClientNewGRFsChecked ,
  ServerWelcome , ServerClientInfo , ClientGetMap , ServerWaitForMap ,
  ServerMapBegin , ServerMapSize , ServerMapData , ServerMapDone ,
  ClientMapOk , ServerClientJoined , ServerFrame , ClientAck ,
  ServerSync , ClientCommand , ServerCommand , ClientChat ,
  ServerChat , ServerExternalChat , ClientRemoteConsoleCommand , ServerRemoteConsoleCommand ,
  ClientMove , ServerMove , ClientSetName , ServerConfigurationUpdate ,
  ClientQuit , ServerQuit , ClientError , ServerErrorQuit
}
 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 137 of file tcp_game.h.

Enumeration Type Documentation

◆ PacketGameType

enum class PacketGameType : uint8_t
strong

Enum with all types of TCP packets.

For the exact meaning, look at NetworkGameSocketHandler.

Enumerator
ServerFull 

The server is full and has no place for you.

ServerBanned 

The server has banned you.

ClientJoin 

The client telling the server it wants to join.

ServerError 

Server sending an error message to the client.

ClientUnused 

Unused.

ServerUnused 

Unused.

ServerGameInfo 

Information about the server.

ClientGameInfo 

Request information about the server.

ServerNewGame 

The server is preparing to start a new game.

ServerShutdown 

The server is shutting down.

ServerAuthenticationRequest 

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

ClientAuthenticationResponse 

The client responds to the authentication request.

ServerEnableEncryption 

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

ClientIdentify 

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

ServerCheckNewGRFs 

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

ClientNewGRFsChecked 

Client acknowledges that it has all required NewGRFs.

ServerWelcome 

Server welcomes you and gives you your ClientID.

ServerClientInfo 

Server sends you information about a client.

ClientGetMap 

Client requests the actual map.

ServerWaitForMap 

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

ServerMapBegin 

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

ServerMapSize 

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

ServerMapData 

Server sends bits of the map to the client.

ServerMapDone 

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

ClientMapOk 

Client tells the server that it received the whole map.

ServerClientJoined 

Tells clients that a new client has joined.

ServerFrame 

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

ClientAck 

The client tells the server which frame it has executed.

ServerSync 

Server tells the client what the random state should be.

ClientCommand 

Client executed a command and sends it to the server.

ServerCommand 

Server distributes a command to (all) the clients.

ClientChat 

Client said something that should be distributed.

ServerChat 

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

ServerExternalChat 

Server distributing the message from external source.

ClientRemoteConsoleCommand 

Client asks the server to execute some command.

ServerRemoteConsoleCommand 

Response of the executed command on the server.

ClientMove 

A client would like to be moved to another company.

ServerMove 

Server tells everyone that someone is moved to another company.

ClientSetName 

A client changes its name.

ServerConfigurationUpdate 

Some network configuration important to the client changed.

ClientQuit 

A client tells the server it is going to quit.

ServerQuit 

A server tells that a client has quit.

ClientError 

A client reports an error to the server.

ServerErrorQuit 

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

Definition at line 22 of file tcp_game.h.