OpenTTD Source 20260311-master-g511d3794ce
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

using ClientPoolID = PoolID<uint16_t, struct ClientPoolIDTag, MAX_CLIENTS + 1 , 0xFFFF>
 Indices into the client related pools.
using AdminID = PoolID<uint8_t, struct AdminIDTag, 16, 0xFF>
 Indices into the admin tables.

Enumerations

enum class  NetworkVehicleType : uint8_t {
  Train = 0 , Truck , Bus , Aircraft ,
  Ship , End
}
 Vehicletypes in the order they are send in info packets. More...
enum class  ServerGameType : uint8_t { Local = 0 , Public , InviteOnly }
 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 : uint8_t {
  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 class  NetworkErrorCode : uint8_t {
  General , Desync , SavegameFailed , ConnectionLost ,
  IllegalPacket , NewGRFMismatch , NotAuthorized , NotExpected ,
  WrongRevision , NameInUse , WrongPassword , CompanyMismatch ,
  Kicked , Cheater , ServerFull , TooManyCommands ,
  TimeoutPassword , TimeoutComputer , TimeoutMap , TimeoutJoin ,
  InvalidClientName , NotOnAllowList , NoAuthenticationMethodAvailable
}
 The error codes we send around in the protocols. More...

Variables

static const uint MAX_CLIENTS = 255
 How many clients can we have.

Detailed Description

Types used for networking.

Definition in file network_type.h.

Typedef Documentation

◆ AdminID

using AdminID = PoolID<uint8_t, struct AdminIDTag, 16, 0xFF>

Indices into the admin tables.

Definition at line 53 of file network_type.h.

◆ ClientPoolID

using ClientPoolID = PoolID<uint16_t, struct ClientPoolIDTag, MAX_CLIENTS + 1 , 0xFFFF>

Indices into the client related pools.

Definition at line 50 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 43 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 69 of file network_type.h.

◆ NetworkAction

enum NetworkAction : uint8_t

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 80 of file network_type.h.

◆ NetworkErrorCode

enum class NetworkErrorCode : uint8_t
strong

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.
Enumerator
General 

Fallback error code in case nothing matches.

Desync 

Client tells that they desynced.

SavegameFailed 

Client tells they could not load the savegame.

ConnectionLost 

Connection to the client was lost.

IllegalPacket 

A packet was received that has invalid content.

NewGRFMismatch 

Client does not have the right NewGRFs.

NotAuthorized 

The client tried to do something there are not authorized to.

NotExpected 

The request/packet was not expected in the current state.

WrongRevision 

The client is using the wrong revision.

NameInUse 

The client has a duplicate name (and we couldn't make it unique).

WrongPassword 

The client entered a wrong password.

CompanyMismatch 

The client was impersonating another company.

Kicked 

The client got kicked.

Cheater 

The client is trying control companies in a way they are not supposed to.

ServerFull 

The server is full.

TooManyCommands 

The client has sent too many commands in a short time.

TimeoutPassword 

The client has timed out providing a password.

TimeoutComputer 

The client has timed out because the computer could not keep up with the server.

TimeoutMap 

The client has timed out because it took too long to download the map.

TimeoutJoin 

The client has timed out because getting up to speed with the server failed.

InvalidClientName 

The client tried to set an invalid name.

NotOnAllowList 

The client is not on the allow list.

NoAuthenticationMethodAvailable 

The client and server could not find a common authentication method.

Definition at line 100 of file network_type.h.

◆ NetworkVehicleType

enum class NetworkVehicleType : uint8_t
strong

Vehicletypes in the order they are send in info packets.

Enumerator
Train 

A train.

Truck 

A road vehicle that stops at truck stops.

Bus 

A road vehicle that stops at bus stops.

Aircraft 

An airplane or helicopter.

Ship 

A ship.

End 

End marker for array sizes.

Definition at line 22 of file network_type.h.

◆ ServerGameType

enum class ServerGameType : uint8_t
strong

Game type the server can be using.

Used on the network protocol to communicate with Game Coordinator.

Enumerator
Local 

Do not communicate with the game coordinator.

Public 

The game is publicly accessible.

InviteOnly 

The game can be accessed if you know the invite code.

Definition at line 36 of file network_type.h.

Variable Documentation

◆ MAX_CLIENTS