OpenTTD Source: src/network/network_admin.cpp File Reference

OpenTTD Source 12.0-beta1

Functions | Variables
network_admin.cpp File Reference
`#include "../stdafx.h"`
`#include "../strings_func.h"`
`#include "../date_func.h"`
`#include "core/game_info.h"`
`#include "network_admin.h"`
`#include "network_base.h"`
`#include "network_server.h"`
`#include "../command_func.h"`
`#include "../company_base.h"`
`#include "../console_func.h"`
`#include "../core/pool_func.hpp"`
`#include "../map_func.h"`
`#include "../rev.h"`
`#include "../game/game.hpp"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
static const std::chrono::seconds | ADMIN_AUTHORISATION_TIMEOUT (10)
| The timeout for authorisation of the client.
void | NetworkAdminClientInfo (const NetworkClientSocket *cs, bool new_client)
| Notify the admin network of a new client (if they did opt in for the respective update). More...
void | NetworkAdminClientUpdate (const NetworkClientInfo *ci)
| Notify the admin network of a client update (if they did opt in for the respective update). More...
void | NetworkAdminClientQuit (ClientID client_id)
| Notify the admin network that a client quit (if they have opt in for the respective update). More...
void | NetworkAdminClientError (ClientID client_id, NetworkErrorCode error_code)
| Notify the admin network of a client error (if they have opt in for the respective update). More...
void | NetworkAdminCompanyInfo (const Company *company, bool new_company)
| Notify the admin network of company details. More...
void | NetworkAdminCompanyUpdate (const Company *company)
| Notify the admin network of company updates. More...
void | NetworkAdminCompanyRemove (CompanyID company_id, AdminCompanyRemoveReason bcrr)
| Notify the admin network of a company to be removed (including the reason why). More...
void | NetworkAdminChat (NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data, bool from_admin)
| Send chat to the admin network (if they did opt in for the respective update).
void | NetworkServerSendAdminRcon (AdminIndex admin_index, TextColour colour_code, const std::string_view string)
| Pass the rcon reply to the admin. More...
void | NetworkAdminConsole (const std::string_view origin, const std::string_view string)
| Send console to the admin network (if they did opt in for the respective update). More...
void | NetworkAdminGameScript (const std::string_view json)
| Send GameScript JSON to the admin network (if they did opt in for the respective update). More...
void | NetworkAdminCmdLogging (const NetworkClientSocket *owner, const CommandPacket *cp)
| Distribute CommandPacket details over the admin network for logging purposes. More...
void | NetworkAdminUpdate (AdminUpdateFrequency freq)
| Send (push) updates to the admin network as they have registered for these updates. More...

## Variables
AdminIndex | _redirect_console_to_admin = INVALID_ADMIN_ID
| Redirection of the (remote) console to the admin.
byte | _network_admins_connected = 0
| The amount of admins connected.
NetworkAdminSocketPool | _networkadminsocket_pool ("NetworkAdminSocket")
| The pool with sockets/clients.
static const AdminUpdateFrequency | _admin_update_type_frequencies []
| Frequencies, which may be registered for a certain update type. More...

## Detailed Description

Server part of the admin network protocol.

Definition in file network_admin.cpp.

## Function Documentation

## ◆ NetworkAdminClientError()

void NetworkAdminClientError | ( | ClientID | client_id,
|  | NetworkErrorCode | error_code
| ) |  |

Notify the admin network of a client error (if they have opt in for the respective update).

Parameters

  client_id | the client that made the error.
  error_code | the error that was caused.

Definition at line 838 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminClientInfo()

void NetworkAdminClientInfo | ( | const NetworkClientSocket * | cs,
|  | bool | new_client
| ) |  |

Notify the admin network of a new client (if they did opt in for the respective update).

Parameters

  cs | the client info.
  new_client | if this is a new client, send the respective packet too.

Definition at line 795 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminClientQuit()

void NetworkAdminClientQuit | ( | ClientID | client_id | ) |

Notify the admin network that a client quit (if they have opt in for the respective update).

Parameters

  client_id | of the client that quit.

Definition at line 824 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminClientUpdate()

void NetworkAdminClientUpdate | ( | const NetworkClientInfo * | ci | ) |

Notify the admin network of a client update (if they did opt in for the respective update).

Parameters

  ci | the client info.

Definition at line 811 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CLIENT_INFO, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by NetworkUpdateClientInfo().

## ◆ NetworkAdminCmdLogging()

void NetworkAdminCmdLogging | ( | const NetworkClientSocket * | owner,
|  | const CommandPacket * | cp
| ) |  |

Distribute CommandPacket details over the admin network for logging purposes.

Parameters

  owner | The owner of the CommandPacket (who sent us the CommandPacket).
  cp | The CommandPacket to be distributed.

Definition at line 954 of file network_admin.cpp.

References _network_own_client_id, ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CMD_LOGGING, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminCompanyInfo()

void NetworkAdminCompanyInfo | ( | const Company * | company,
|  | bool | new_company
| ) |  |

Notify the admin network of company details.

Parameters

  company | the company of which details will be sent into the admin network.
  new_company | whether this is a new company or not.

Definition at line 852 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_COMPANY_INFO, Debug, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by NetworkServerNewCompany().

## ◆ NetworkAdminCompanyRemove()

void NetworkAdminCompanyRemove | ( | CompanyID | company_id,
|  | AdminCompanyRemoveReason | bcrr
| ) |  |

Notify the admin network of a company to be removed (including the reason why).

Parameters

  company_id | ID of the company that got removed.
  bcrr | the reason why the company got removed (e.g. bankruptcy).

Definition at line 889 of file network_admin.cpp.

References ServerNetworkAdminSocketHandler::IterateActive().

Referenced by CompanyAdminRemove().

## ◆ NetworkAdminCompanyUpdate()

void NetworkAdminCompanyUpdate | ( | const Company * | company | ) |

Notify the admin network of company updates.

Parameters

  company | company of which updates are going to be sent into the admin network.

Definition at line 873 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_COMPANY_INFO, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by CompanyAdminUpdate(), and NetworkServerUpdateCompanyPassworded().

## ◆ NetworkAdminConsole()

void NetworkAdminConsole | ( | const std::string_view | origin,
|  | const std::string_view | string
| ) |  |

Send console to the admin network (if they did opt in for the respective update).

Parameters

  origin | the origin of the message.
  string | the message as printed on the console.

Definition at line 927 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_CONSOLE, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminGameScript()

void NetworkAdminGameScript | ( | const std::string_view | json | ) |

Send GameScript JSON to the admin network (if they did opt in for the respective update).

Parameters

  json | The JSON data as received from the GameScript.

Definition at line 940 of file network_admin.cpp.

References ADMIN_FREQUENCY_AUTOMATIC, ADMIN_UPDATE_GAMESCRIPT, and ServerNetworkAdminSocketHandler::IterateActive().

## ◆ NetworkAdminUpdate()

void NetworkAdminUpdate | ( | AdminUpdateFrequency | freq | ) |

Send (push) updates to the admin network as they have registered for these updates.

Parameters

  freq | the frequency to be processed.

Definition at line 979 of file network_admin.cpp.

References ADMIN_UPDATE_COMPANY_ECONOMY, ADMIN_UPDATE_COMPANY_STATS, ADMIN_UPDATE_DATE, ADMIN_UPDATE_END, and ServerNetworkAdminSocketHandler::IterateActive().

Referenced by NetworkServerDailyLoop(), NetworkServerMonthlyLoop(), and NetworkServerYearlyLoop().

## ◆ NetworkServerSendAdminRcon()

void NetworkServerSendAdminRcon | ( | AdminIndex | admin_index,
|  | TextColour | colour_code,
|  | const std::string_view | string
| ) |  |

Pass the rcon reply to the admin.

Parameters

  admin_index | The admin to give the reply.
  colour_code | The colour of the string.
  string | The string to show.

Definition at line 917 of file network_admin.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_networkadminsocket_pool >::Get().

Referenced by IConsolePrint().

## Variable Documentation

## ◆ _admin_update_type_frequencies

const AdminUpdateFrequency _admin_update_type_frequencies[]
| static

Initial value:
= {
ADMIN_FREQUENCY_POLL | ADMIN_FREQUENCY_DAILY | ADMIN_FREQUENCY_WEEKLY | ADMIN_FREQUENCY_MONTHLY | ADMIN_FREQUENCY_QUARTERLY | ADMIN_FREQUENCY_ANUALLY,
ADMIN_FREQUENCY_POLL | ADMIN_FREQUENCY_AUTOMATIC,
ADMIN_FREQUENCY_POLL | ADMIN_FREQUENCY_AUTOMATIC,
ADMIN_FREQUENCY_POLL | ADMIN_FREQUENCY_WEEKLY | ADMIN_FREQUENCY_MONTHLY | ADMIN_FREQUENCY_QUARTERLY | ADMIN_FREQUENCY_ANUALLY,
ADMIN_FREQUENCY_POLL | ADMIN_FREQUENCY_WEEKLY | ADMIN_FREQUENCY_MONTHLY | ADMIN_FREQUENCY_QUARTERLY | ADMIN_FREQUENCY_ANUALLY,
ADMIN_FREQUENCY_AUTOMATIC,
ADMIN_FREQUENCY_AUTOMATIC,
ADMIN_FREQUENCY_POLL,
ADMIN_FREQUENCY_AUTOMATIC,
ADMIN_FREQUENCY_AUTOMATIC,
}

Frequencies, which may be registered for a certain update type.

Definition at line 45 of file network_admin.cpp.

Referenced by ServerNetworkAdminSocketHandler::SendProtocol().

ADMIN_FREQUENCY_DAILY
@ ADMIN_FREQUENCY_DAILY
The admin gets information about this on a daily basis.
Definition: tcp_admin.h:91
ADMIN_FREQUENCY_MONTHLY
@ ADMIN_FREQUENCY_MONTHLY
The admin gets information about this on a monthly basis.
Definition: tcp_admin.h:93
ADMIN_FREQUENCY_QUARTERLY
@ ADMIN_FREQUENCY_QUARTERLY
The admin gets information about this on a quarterly basis.
Definition: tcp_admin.h:94
ADMIN_FREQUENCY_POLL
@ ADMIN_FREQUENCY_POLL
The admin can poll this.
Definition: tcp_admin.h:90
ADMIN_FREQUENCY_ANUALLY
@ ADMIN_FREQUENCY_ANUALLY
The admin gets information about this on a yearly basis.
Definition: tcp_admin.h:95
ADMIN_FREQUENCY_AUTOMATIC
@ ADMIN_FREQUENCY_AUTOMATIC
The admin gets information about this when it changes.
Definition: tcp_admin.h:96
ADMIN_FREQUENCY_WEEKLY
@ ADMIN_FREQUENCY_WEEKLY
The admin gets information about this on a weekly basis.
Definition: tcp_admin.h:92