OpenTTD Source: NetworkAdminSocketHandler Class Reference

OpenTTD Source 1.11.0-RC1

Public Member Functions | Protected Member Functions | Protected Attributes
NetworkAdminSocketHandler Class Reference

Main socket handler for admin related connections. More...

`#include <tcp_admin.h>`

Inheritance diagram for NetworkAdminSocketHandler:

## Public Member Functions
NetworkRecvStatus | CloseConnection (bool error=true) override
| Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped. More...
| NetworkAdminSocketHandler (SOCKET s)
| Create the admin handler for the given socket. More...
NetworkRecvStatus | ReceivePackets ()
| Do the actual receiving of packets. More...
AdminStatus | GetAdminStatus () const
| Get the status of the admin. More...
Public Member Functions inherited from NetworkTCPSocketHandler
bool | IsConnected () const
| Whether this socket is currently bound to a socket. More...
virtual void | SendPacket (Packet *packet)
| This function puts the packet in the send-queue and it is send as soon as possible. More...
SendPacketsState | SendPackets (bool closing_down=false)
| Sends all the buffered packets out for this client. More...
virtual Packet * | ReceivePacket ()
| Receives a packet for the given client. More...
bool | CanSendReceive ()
| Check whether this socket can send or receive something. More...
bool | HasSendQueue ()
| Whether there is something pending in the send queue. More...
| NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET)
| Construct a socket handler for a TCP connection. More...
Public Member Functions inherited from NetworkSocketHandler
| NetworkSocketHandler ()
| Create a new unbound socket.
virtual | ~NetworkSocketHandler ()
| Close the socket when destructing the socket handler.
virtual void | Close ()
| Really close the socket.
bool | HasClientQuit () const
| Whether the current client connected to the socket has quit. More...
void | Reopen ()
| Reopen the socket so we can send/receive stuff again.
void | SendGRFIdentifier (Packet *p, const GRFIdentifier *grf)
| Serializes the GRFIdentifier (GRF ID and MD5 checksum) to the packet. More...
void | ReceiveGRFIdentifier (Packet *p, GRFIdentifier *grf)
| Deserializes the GRFIdentifier (GRF ID and MD5 checksum) from the packet. More...
void | SendCompanyInformation (Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len=NETWORK_COMPANY_NAME_LENGTH)
| Package some generic company information into a packet. More...

## Protected Member Functions
NetworkRecvStatus | ReceiveInvalidPacket (PacketAdminType type)
| Helper for logging receiving invalid packets. More...
virtual NetworkRecvStatus | Receive_ADMIN_JOIN (Packet *p)
| Join the admin network: string Password the server is expecting for this network. More...
virtual NetworkRecvStatus | Receive_ADMIN_QUIT (Packet *p)
| Notification to the server that this admin is quitting. More...
virtual NetworkRecvStatus | Receive_ADMIN_UPDATE_FREQUENCY (Packet *p)
| Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16 Update type (see AdminUpdateType). More...
virtual NetworkRecvStatus | Receive_ADMIN_POLL (Packet *p)
| Poll the server for certain updates, an invalid poll (e.g. More...
virtual NetworkRecvStatus | Receive_ADMIN_CHAT (Packet *p)
| Send chat as the server: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction). More...
virtual NetworkRecvStatus | Receive_ADMIN_RCON (Packet *p)
| Execute a command on the servers console: string Command to be executed. More...
virtual NetworkRecvStatus | Receive_ADMIN_GAMESCRIPT (Packet *p)
| Send a JSON string to the current active GameScript. More...
virtual NetworkRecvStatus | Receive_ADMIN_PING (Packet *p)
| Ping the server, requiring the server to reply with a pong packet. More...
virtual NetworkRecvStatus | Receive_SERVER_FULL (Packet *p)
| The server is full (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_BANNED (Packet *p)
| The source IP address is banned (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_ERROR (Packet *p)
| An error was caused by this admin connection (connection gets closed). More...
virtual NetworkRecvStatus | Receive_SERVER_PROTOCOL (Packet *p)
| Inform a just joined admin about the protocol specifics: uint8 Protocol version. More...
virtual NetworkRecvStatus | Receive_SERVER_WELCOME (Packet *p)
| Welcome a connected admin to the game: string Name of the Server (e.g. More...
virtual NetworkRecvStatus | Receive_SERVER_NEWGAME (Packet *p)
| Notification about a newgame. More...
virtual NetworkRecvStatus | Receive_SERVER_SHUTDOWN (Packet *p)
| Notification about the server shutting down. More...
virtual NetworkRecvStatus | Receive_SERVER_DATE (Packet *p)
| Send the current date of the game: uint32 Current game date. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_JOIN (Packet *p)
| Notification of a new client: uint32 ID of the new client. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_INFO (Packet *p)
| Client information of a specific client: uint32 ID of the client. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_UPDATE (Packet *p)
| Client update details on a specific client (e.g. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_QUIT (Packet *p)
| Notification about a client leaving the game. More...
virtual NetworkRecvStatus | Receive_SERVER_CLIENT_ERROR (Packet *p)
| Notification about a client error (and thus the clients disconnection). More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_NEW (Packet *p)
| Notification of a new company: uint8 ID of the new company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_INFO (Packet *p)
| Company information on a specific company: uint8 ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_UPDATE (Packet *p)
| Company information of a specific company: uint8 ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_REMOVE (Packet *p)
| Notification about a removed company (e.g. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_ECONOMY (Packet *p)
| Economy update of a specific company: uint8 ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_COMPANY_STATS (Packet *p)
| Company statistics on stations and vehicles: uint8 ID of the company. More...
virtual NetworkRecvStatus | Receive_SERVER_CHAT (Packet *p)
| Send chat from the game into the admin network: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction). More...
virtual NetworkRecvStatus | Receive_SERVER_RCON (Packet *p)
| Result of an rcon command: uint16 Colour as it would be used on the server or a client. More...
virtual NetworkRecvStatus | Receive_SERVER_CONSOLE (Packet *p)
| Send what would be printed on the server's console also into the admin network. More...
virtual NetworkRecvStatus | Receive_SERVER_CMD_NAMES (Packet *p)
| Send DoCommand names to the bot upon request only. More...
virtual NetworkRecvStatus | Receive_SERVER_CMD_LOGGING (Packet *p)
| Send incoming command packets to the admin network. More...
virtual NetworkRecvStatus | Receive_SERVER_PONG (Packet *p)
| Send a ping-reply (pong) to the admin that sent us the ping packet. More...
virtual NetworkRecvStatus | Receive_SERVER_RCON_END (Packet *p)
| Notify the admin connection that the rcon command has finished. More...
NetworkRecvStatus | HandlePacket (Packet *p)
| Handle the given packet, i.e. More...

## Protected Attributes
char | admin_name [NETWORK_CLIENT_NAME_LENGTH]
| Name of the admin.
char | admin_version [NETWORK_REVISION_LENGTH]
| Version string of the admin.
AdminStatus | status
| Status of this admin.

## Additional Inherited Members
Data Fields inherited from NetworkTCPSocketHandler
SOCKET | sock
| The socket currently connected to.
bool | writable
| Can we write to this socket?

## Detailed Description

Main socket handler for admin related connections.

Definition at line 110 of file tcp_admin.h.

## Constructor & Destructor Documentation

## ◆ NetworkAdminSocketHandler()

NetworkAdminSocketHandler::NetworkAdminSocketHandler | ( | SOCKET | s | ) |

Create the admin handler for the given socket.

Parameters

  s | The socket to communicate over.

Definition at line 30 of file tcp_admin.cpp.

References admin_name, admin_version, and NetworkTCPSocketHandler::sock.

## Member Function Documentation

## ◆ CloseConnection()

NetworkRecvStatus NetworkAdminSocketHandler::CloseConnection | ( | bool | error = `true` | ) |
| overridevirtual

Close the current connection; for TCP this will be mostly equivalent to Close(), but for UDP it just means the packet has to be dropped.

Parameters

  error | Whether we quit under an error condition or not.

Returns
  new status of the connection.

Reimplemented from NetworkTCPSocketHandler.

Definition at line 41 of file tcp_admin.cpp.

References NETWORK_RECV_STATUS_CONN_LOST.

Referenced by HandlePacket(), and ServerNetworkAdminSocketHandler::Receive_ADMIN_QUIT().

## ◆ GetAdminStatus()

AdminStatus NetworkAdminSocketHandler::GetAdminStatus | ( |  | ) | const
| inline

Get the status of the admin.

Returns
  The status of the admin.

Definition at line 493 of file tcp_admin.h.

References status.

## ◆ HandlePacket()

NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket | ( | Packet * | p | ) |
| protected

Handle the given packet, i.e.

pass it to the right parser receive command.

Parameters

  p | the packet to handle.

Returns
  NetworkRecvStatus of handling.

Definition at line 52 of file tcp_admin.cpp.

References admin_name, ADMIN_PACKET_ADMIN_CHAT, ADMIN_PACKET_ADMIN_GAMESCRIPT, ADMIN_PACKET_ADMIN_JOIN, ADMIN_PACKET_ADMIN_PING, ADMIN_PACKET_ADMIN_POLL, ADMIN_PACKET_ADMIN_QUIT, ADMIN_PACKET_ADMIN_RCON, ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY, ADMIN_PACKET_SERVER_BANNED, ADMIN_PACKET_SERVER_CHAT, ADMIN_PACKET_SERVER_CLIENT_ERROR, ADMIN_PACKET_SERVER_CLIENT_INFO, ADMIN_PACKET_SERVER_CLIENT_JOIN, ADMIN_PACKET_SERVER_CLIENT_QUIT, ADMIN_PACKET_SERVER_CLIENT_UPDATE, ADMIN_PACKET_SERVER_CMD_LOGGING, ADMIN_PACKET_SERVER_CMD_NAMES, ADMIN_PACKET_SERVER_COMPANY_ECONOMY, ADMIN_PACKET_SERVER_COMPANY_INFO, ADMIN_PACKET_SERVER_COMPANY_NEW, ADMIN_PACKET_SERVER_COMPANY_REMOVE, ADMIN_PACKET_SERVER_COMPANY_STATS, ADMIN_PACKET_SERVER_COMPANY_UPDATE, ADMIN_PACKET_SERVER_CONSOLE, ADMIN_PACKET_SERVER_DATE, ADMIN_PACKET_SERVER_ERROR, ADMIN_PACKET_SERVER_FULL, ADMIN_PACKET_SERVER_NEWGAME, ADMIN_PACKET_SERVER_PONG, ADMIN_PACKET_SERVER_PROTOCOL, ADMIN_PACKET_SERVER_RCON, ADMIN_PACKET_SERVER_RCON_END, ADMIN_PACKET_SERVER_SHUTDOWN, ADMIN_PACKET_SERVER_WELCOME, admin_version, CloseConnection(), DEBUG, NetworkSocketHandler::HasClientQuit(), INVALID_ADMIN_PACKET, NETWORK_RECV_STATUS_MALFORMED_PACKET, Receive_ADMIN_CHAT(), Receive_ADMIN_GAMESCRIPT(), Receive_ADMIN_JOIN(), Receive_ADMIN_PING(), Receive_ADMIN_POLL(), Receive_ADMIN_QUIT(), Receive_ADMIN_RCON(), Receive_ADMIN_UPDATE_FREQUENCY(), Receive_SERVER_BANNED(), Receive_SERVER_CHAT(), Receive_SERVER_CLIENT_ERROR(), Receive_SERVER_CLIENT_INFO(), Receive_SERVER_CLIENT_JOIN(), Receive_SERVER_CLIENT_QUIT(), Receive_SERVER_CLIENT_UPDATE(), Receive_SERVER_CMD_LOGGING(), Receive_SERVER_CMD_NAMES(), Receive_SERVER_COMPANY_ECONOMY(), Receive_SERVER_COMPANY_INFO(), Receive_SERVER_COMPANY_NEW(), Receive_SERVER_COMPANY_REMOVE(), Receive_SERVER_COMPANY_STATS(), Receive_SERVER_COMPANY_UPDATE(), Receive_SERVER_CONSOLE(), Receive_SERVER_DATE(), Receive_SERVER_ERROR(), Receive_SERVER_FULL(), Receive_SERVER_NEWGAME(), Receive_SERVER_PONG(), Receive_SERVER_PROTOCOL(), Receive_SERVER_RCON(), Receive_SERVER_RCON_END(), Receive_SERVER_SHUTDOWN(), Receive_SERVER_WELCOME(), and Packet::Recv_uint8().

Referenced by ReceivePackets().

## ◆ Receive_ADMIN_CHAT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_CHAT | ( | Packet * | p | ) |
| protectedvirtual

Send chat as the server: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).

uint8 Destination type such as DESTTYPE_BROADCAST (see DestType). uint32 ID of the destination such as company or client id. string Message.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 140 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_CHAT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_GAMESCRIPT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT | ( | Packet * | p | ) |
| protectedvirtual

Send a JSON string to the current active GameScript.

json JSON string for the GameScript.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 142 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_GAMESCRIPT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_JOIN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_JOIN | ( | Packet * | p | ) |
| protectedvirtual

Join the admin network: string Password the server is expecting for this network.

string Name of the application being used to connect. string Version string of the application being used to connect.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 136 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_JOIN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_PING()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_PING | ( | Packet * | p | ) |
| protectedvirtual

Ping the server, requiring the server to reply with a pong packet.

uint32 Integer value to pass to the server, which is quoted in the reply.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 143 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_PING, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_POLL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_POLL | ( | Packet * | p | ) |
| protectedvirtual

Poll the server for certain updates, an invalid poll (e.g.

not existent id) gets silently dropped: uint8 AdminUpdateType the server should answer for, only if AdminUpdateFrequency ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md. uint32 ID relevant to the packet type, e.g.

- the client ID for ADMIN_UPDATE_CLIENT_INFO. Use UINT32_MAX to show all clients.
- the company ID for ADMIN_UPDATE_COMPANY_INFO. Use UINT32_MAX to show all companies.
  Parameters

    p | The packet that was just received.

  Returns
    The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 139 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_POLL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_QUIT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_QUIT | ( | Packet * | p | ) |
| protectedvirtual

Notification to the server that this admin is quitting.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 137 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_QUIT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_RCON()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_RCON | ( | Packet * | p | ) |
| protectedvirtual

Execute a command on the servers console: string Command to be executed.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 141 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_RCON, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_ADMIN_UPDATE_FREQUENCY()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY | ( | Packet * | p | ) |
| protectedvirtual

Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): uint16 Update type (see AdminUpdateType).

Note integer type - see "Certain Packet Information" in docs/admin_network.md. uint16 Update frequency (see AdminUpdateFrequency), setting ADMIN_FREQUENCY_POLL is always ignored.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Reimplemented in ServerNetworkAdminSocketHandler.

Definition at line 138 of file tcp_admin.cpp.

References ADMIN_PACKET_ADMIN_UPDATE_FREQUENCY, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_BANNED()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_BANNED | ( | Packet * | p | ) |
| protectedvirtual

The source IP address is banned (connection gets closed).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 146 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_BANNED, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CHAT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CHAT | ( | Packet * | p | ) |
| protectedvirtual

Send chat from the game into the admin network: uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see NetworkAction).

uint8 Destination type such as DESTTYPE_BROADCAST (see DestType). uint32 ID of the client who sent this message. string Message. uint64 Money (only when it is a 'give money' action).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 165 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CHAT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_ERROR()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_ERROR | ( | Packet * | p | ) |
| protectedvirtual

Notification about a client error (and thus the clients disconnection).

uint32 ID of the client that made the error. uint8 Error the client made (see NetworkErrorCode).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 158 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_ERROR, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_INFO()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_INFO | ( | Packet * | p | ) |
| protectedvirtual

Client information of a specific client: uint32 ID of the client.

string Network address of the client. string Name of the client. uint8 Language of the client. uint32 Date the client joined the game. uint8 ID of the company the client is playing as (255 for spectators).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 155 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_INFO, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_JOIN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_JOIN | ( | Packet * | p | ) |
| protectedvirtual

Notification of a new client: uint32 ID of the new client.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 154 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_JOIN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_QUIT()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_QUIT | ( | Packet * | p | ) |
| protectedvirtual

Notification about a client leaving the game.

uint32 ID of the client that just left.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 157 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_QUIT, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CLIENT_UPDATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CLIENT_UPDATE | ( | Packet * | p | ) |
| protectedvirtual

Client update details on a specific client (e.g.

after rename or move): uint32 ID of the client. string Name of the client. uint8 ID of the company the client is playing as (255 for spectators).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 156 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CLIENT_UPDATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CMD_LOGGING()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING | ( | Packet * | p | ) |
| protectedvirtual

Send incoming command packets to the admin network.

This is for logging purposes only.

NOTICE: Data provided with this packet is not stable and will not be treated as such. Do not rely on IDs or names to be constant across different versions / revisions of OpenTTD. Data provided in this packet is for logging purposes only.

uint32 ID of the client sending the command. uint8 ID of the company (0..MAX_COMPANIES-1). uint16 ID of the command. uint32 P1 (variable data passed to the command). uint32 P2 (variable data passed to the command). uint32 Tile where this is taking place. string Text passed to the command. uint32 Frame of execution.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 169 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CMD_LOGGING, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CMD_NAMES()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES | ( | Packet * | p | ) |
| protectedvirtual

Send DoCommand names to the bot upon request only.

Multiple of these packets can follow each other in order to provide all known DoCommand names.

NOTICE: Data provided with this packet is not stable and will not be treated as such. Do not rely on IDs or names to be constant across different versions / revisions of OpenTTD. Data provided in this packet is for logging purposes only.

These three fields are repeated until the packet is full: bool Data to follow. uint16 ID of the DoCommand. string Name of DoCommand.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 168 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CMD_NAMES, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_ECONOMY()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_ECONOMY | ( | Packet * | p | ) |
| protectedvirtual

Economy update of a specific company: uint8 ID of the company.

uint64 Money. uint64 Loan. int64 Income. uint16 Delivered cargo (this quarter). uint64 Company value (last quarter). uint16 Performance (last quarter). uint16 Delivered cargo (last quarter). uint64 Company value (previous quarter). uint16 Performance (previous quarter). uint16 Delivered cargo (previous quarter).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 163 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_ECONOMY, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_INFO()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_INFO | ( | Packet * | p | ) |
| protectedvirtual

Company information on a specific company: uint8 ID of the company.

string Name of the company. string Name of the companies manager. uint8 Main company colour. bool Company is password protected. uint32 Year the company was inaugurated. bool Company is an AI.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 160 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_INFO, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_NEW()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_NEW | ( | Packet * | p | ) |
| protectedvirtual

Notification of a new company: uint8 ID of the new company.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 159 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_NEW, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_REMOVE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_REMOVE | ( | Packet * | p | ) |
| protectedvirtual

Notification about a removed company (e.g.

due to bankruptcy). uint8 ID of the company. uint8 Reason for being removed (see AdminCompanyRemoveReason).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 162 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_REMOVE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_STATS()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_STATS | ( | Packet * | p | ) |
| protectedvirtual

Company statistics on stations and vehicles: uint8 ID of the company.

uint16 Number of trains. uint16 Number of lorries. uint16 Number of busses. uint16 Number of planes. uint16 Number of ships. uint16 Number of train stations. uint16 Number of lorry stations. uint16 Number of bus stops. uint16 Number of airports and heliports. uint16 Number of harbours.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 164 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_STATS, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_COMPANY_UPDATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_COMPANY_UPDATE | ( | Packet * | p | ) |
| protectedvirtual

Company information of a specific company: uint8 ID of the company.

string Name of the company. string Name of the companies manager. uint8 Main company colour. bool Company is password protected. uint8 Quarters of bankruptcy. uint8 Owner of share 1. uint8 Owner of share 2. uint8 Owner of share 3. uint8 Owner of share 4.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 161 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_COMPANY_UPDATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_CONSOLE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE | ( | Packet * | p | ) |
| protectedvirtual

Send what would be printed on the server's console also into the admin network.

string The origin of the text, e.g. "console" for console, or "net" for network related (debug) messages. string Text as found on the console of the server.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 167 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_CONSOLE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_DATE()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_DATE | ( | Packet * | p | ) |
| protectedvirtual

Send the current date of the game: uint32 Current game date.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 153 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_DATE, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_ERROR()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_ERROR | ( | Packet * | p | ) |
| protectedvirtual

An error was caused by this admin connection (connection gets closed).

uint8 NetworkErrorCode the error caused.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 147 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_ERROR, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_FULL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_FULL | ( | Packet * | p | ) |
| protectedvirtual

The server is full (connection gets closed).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 145 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_FULL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_NEWGAME()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_NEWGAME | ( | Packet * | p | ) |
| protectedvirtual

Notification about a newgame.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 150 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_NEWGAME, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_PONG()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG | ( | Packet * | p | ) |
| protectedvirtual

Send a ping-reply (pong) to the admin that sent us the ping packet.

uint32 Integer identifier - should be the same as read from the admins ping packet.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 171 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_PONG, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_PROTOCOL()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PROTOCOL | ( | Packet * | p | ) |
| protectedvirtual

Inform a just joined admin about the protocol specifics: uint8 Protocol version.

bool Further protocol data follows (repeats through all update packet types). uint16 Update packet type. uint16 Frequencies allowed for this update packet (bitwise).

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 148 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_PROTOCOL, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_RCON()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON | ( | Packet * | p | ) |
| protectedvirtual

Result of an rcon command: uint16 Colour as it would be used on the server or a client.

string Output of the executed command.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 166 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_RCON, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_RCON_END()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END | ( | Packet * | p | ) |
| protectedvirtual

Notify the admin connection that the rcon command has finished.

string The command as requested by the admin connection.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 170 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_RCON_END, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_SHUTDOWN()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_SHUTDOWN | ( | Packet * | p | ) |
| protectedvirtual

Notification about the server shutting down.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 151 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_SHUTDOWN, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ Receive_SERVER_WELCOME()

NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_WELCOME | ( | Packet * | p | ) |
| protectedvirtual

Welcome a connected admin to the game: string Name of the Server (e.g.

as advertised to master server). string OpenTTD version string. bool Server is dedicated. string Name of the Map. uint32 Random seed of the Map. uint8 Landscape of the Map. uint32 Start date of the Map. uint16 Map width. uint16 Map height.

Parameters

  p | The packet that was just received.

Returns
  The state the network should have.

Definition at line 149 of file tcp_admin.cpp.

References ADMIN_PACKET_SERVER_WELCOME, and ReceiveInvalidPacket().

Referenced by HandlePacket().

## ◆ ReceiveInvalidPacket()

NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket | ( | PacketAdminType | type | ) |
| protected

Helper for logging receiving invalid packets.

Parameters

  type | The received packet type.

Returns
  The status the network should have, in this case: "malformed packet error".

Definition at line 130 of file tcp_admin.cpp.

References admin_name, admin_version, DEBUG, and NETWORK_RECV_STATUS_MALFORMED_PACKET.

Referenced by Receive_ADMIN_CHAT(), Receive_ADMIN_GAMESCRIPT(), Receive_ADMIN_JOIN(), Receive_ADMIN_PING(), Receive_ADMIN_POLL(), Receive_ADMIN_QUIT(), Receive_ADMIN_RCON(), Receive_ADMIN_UPDATE_FREQUENCY(), Receive_SERVER_BANNED(), Receive_SERVER_CHAT(), Receive_SERVER_CLIENT_ERROR(), Receive_SERVER_CLIENT_INFO(), Receive_SERVER_CLIENT_JOIN(), Receive_SERVER_CLIENT_QUIT(), Receive_SERVER_CLIENT_UPDATE(), Receive_SERVER_CMD_LOGGING(), Receive_SERVER_CMD_NAMES(), Receive_SERVER_COMPANY_ECONOMY(), Receive_SERVER_COMPANY_INFO(), Receive_SERVER_COMPANY_NEW(), Receive_SERVER_COMPANY_REMOVE(), Receive_SERVER_COMPANY_STATS(), Receive_SERVER_COMPANY_UPDATE(), Receive_SERVER_CONSOLE(), Receive_SERVER_DATE(), Receive_SERVER_ERROR(), Receive_SERVER_FULL(), Receive_SERVER_NEWGAME(), Receive_SERVER_PONG(), Receive_SERVER_PROTOCOL(), Receive_SERVER_RCON(), Receive_SERVER_RCON_END(), Receive_SERVER_SHUTDOWN(), and Receive_SERVER_WELCOME().

## ◆ ReceivePackets()

NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets | ( |  | ) |

Do the actual receiving of packets.

As long as HandlePacket returns OKAY packets are handled. Upon failure, or no more packets to process the last result of HandlePacket is returned.

Returns
  NetworkRecvStatus of the last handled packet.

Definition at line 113 of file tcp_admin.cpp.

References HandlePacket(), NETWORK_RECV_STATUS_OKAY, and NetworkTCPSocketHandler::ReceivePacket().

The documentation for this class was generated from the following files:

- src/network/core/tcp_admin.h
- src/network/core/tcp_admin.cpp