OpenTTD Source 20241224-master-gee860a5c8e
network_type.h File Reference

Types used for networking. More...

Go to the source code of this file.

Data Structures

struct  NetworkCompanyStats
 Simple calculated statistics of a company. More...
 
class  NetworkAuthorizedKeys
 Simple helper to (more easily) manage authorized keys. More...
 

Typedefs

typedef uint8_t ClientIndex
 Indices into the client tables.
 
typedef uint8_t AdminIndex
 Indices into the admin tables.
 

Enumerations

enum  NetworkVehicleType {
  NETWORK_VEH_TRAIN = 0 , NETWORK_VEH_LORRY , NETWORK_VEH_BUS , NETWORK_VEH_PLANE ,
  NETWORK_VEH_SHIP , NETWORK_VEH_END
}
 Vehicletypes in the order they are send in info packets. More...
 
enum  ServerGameType : uint8_t { SERVER_GAME_TYPE_LOCAL = 0 , SERVER_GAME_TYPE_PUBLIC , SERVER_GAME_TYPE_INVITE_ONLY }
 Game type the server can be using. More...
 
enum  ClientID : uint32_t { INVALID_CLIENT_ID = 0 , CLIENT_ID_SERVER = 1 , CLIENT_ID_FIRST = 2 }
 'Unique' identifier to be given to clients More...
 
enum  DestType : uint8_t { DESTTYPE_BROADCAST , DESTTYPE_TEAM , DESTTYPE_CLIENT }
 Destination of our chat messages. More...
 
enum  NetworkAction {
  NETWORK_ACTION_JOIN , NETWORK_ACTION_LEAVE , NETWORK_ACTION_SERVER_MESSAGE , NETWORK_ACTION_CHAT ,
  NETWORK_ACTION_CHAT_COMPANY , NETWORK_ACTION_CHAT_CLIENT , NETWORK_ACTION_GIVE_MONEY , NETWORK_ACTION_NAME_CHANGE ,
  NETWORK_ACTION_COMPANY_SPECTATOR , NETWORK_ACTION_COMPANY_JOIN , NETWORK_ACTION_COMPANY_NEW , NETWORK_ACTION_KICKED ,
  NETWORK_ACTION_EXTERNAL_CHAT
}
 Actions that can be used for NetworkTextMessage. More...
 
enum  NetworkErrorCode {
  NETWORK_ERROR_GENERAL , NETWORK_ERROR_DESYNC , NETWORK_ERROR_SAVEGAME_FAILED , NETWORK_ERROR_CONNECTION_LOST ,
  NETWORK_ERROR_ILLEGAL_PACKET , NETWORK_ERROR_NEWGRF_MISMATCH , NETWORK_ERROR_NOT_AUTHORIZED , NETWORK_ERROR_NOT_EXPECTED ,
  NETWORK_ERROR_WRONG_REVISION , NETWORK_ERROR_NAME_IN_USE , NETWORK_ERROR_WRONG_PASSWORD , NETWORK_ERROR_COMPANY_MISMATCH ,
  NETWORK_ERROR_KICKED , NETWORK_ERROR_CHEATER , NETWORK_ERROR_FULL , NETWORK_ERROR_TOO_MANY_COMMANDS ,
  NETWORK_ERROR_TIMEOUT_PASSWORD , NETWORK_ERROR_TIMEOUT_COMPUTER , NETWORK_ERROR_TIMEOUT_MAP , NETWORK_ERROR_TIMEOUT_JOIN ,
  NETWORK_ERROR_INVALID_CLIENT_NAME , NETWORK_ERROR_NOT_ON_ALLOW_LIST , NETWORK_ERROR_NO_AUTHENTICATION_METHOD_AVAILABLE , NETWORK_ERROR_END
}
 The error codes we send around in the protocols. More...
 

Variables

static const uint MAX_CLIENTS = 255
 How many clients can we have.
 
static const uint MAX_CLIENT_SLOTS = 256
 The number of slots; must be at least 1 more than MAX_CLIENTS.
 
static const AdminIndex MAX_ADMINS = 16
 Maximum number of allowed admins.
 
static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX
 An invalid admin marker.
 

Detailed Description

Types used for networking.

Definition in file network_type.h.

Typedef Documentation

◆ AdminIndex

typedef uint8_t AdminIndex

Indices into the admin tables.

Definition at line 59 of file network_type.h.

◆ ClientIndex

typedef uint8_t ClientIndex

Indices into the client tables.

Definition at line 56 of file network_type.h.

Enumeration Type Documentation

◆ ClientID

enum ClientID : uint32_t

'Unique' identifier to be given to clients

Enumerator
INVALID_CLIENT_ID 

Client is not part of anything.

CLIENT_ID_SERVER 

Servers always have this ID.

CLIENT_ID_FIRST 

The first client ID.

Definition at line 49 of file network_type.h.

◆ DestType

enum DestType : uint8_t

Destination of our chat messages.

Warning
The values of the enum items are part of the admin network API. Only append at the end.
Enumerator
DESTTYPE_BROADCAST 

Send message/notice to all clients (All)

DESTTYPE_TEAM 

Send message/notice to everyone playing the same company (Team)

DESTTYPE_CLIENT 

Send message/notice to only a certain client (Private)

Definition at line 79 of file network_type.h.

◆ NetworkAction

Actions that can be used for NetworkTextMessage.

Warning
The values of the enum items are part of the admin network API. Only append at the end.

Definition at line 90 of file network_type.h.

◆ NetworkErrorCode

The error codes we send around in the protocols.

Warning
The values of the enum items are part of the admin network API. Only append at the end.

Definition at line 110 of file network_type.h.

◆ NetworkVehicleType

Vehicletypes in the order they are send in info packets.

Definition at line 28 of file network_type.h.

◆ ServerGameType

enum ServerGameType : uint8_t

Game type the server can be using.

Used on the network protocol to communicate with Game Coordinator.

Definition at line 42 of file network_type.h.

Variable Documentation

◆ INVALID_ADMIN_ID

const AdminIndex INVALID_ADMIN_ID = UINT8_MAX
static

◆ MAX_ADMINS

const AdminIndex MAX_ADMINS = 16
static

Maximum number of allowed admins.

Definition at line 62 of file network_type.h.

Referenced by ServerNetworkAdminSocketHandler::AllowConnection().

◆ MAX_CLIENT_SLOTS

const uint MAX_CLIENT_SLOTS = 256
static

The number of slots; must be at least 1 more than MAX_CLIENTS.

It must furthermore be less than or equal to 256 as client indices (sent over the network) are 8 bits. It needs 1 more for the dedicated server.

Definition at line 23 of file network_type.h.

◆ MAX_CLIENTS