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

OpenTTD Source 15.3

Data Structures | Functions | Variables
network_server.cpp File Reference

Server part of the network protocol. More...

`#include "../stdafx.h"`
`#include "../strings_func.h"`
`#include "core/network_game_info.h"`
`#include "network_admin.h"`
`#include "network_server.h"`
`#include "network_udp.h"`
`#include "network_base.h"`
`#include "../console_func.h"`
`#include "../company_base.h"`
`#include "../command_func.h"`
`#include "../saveload/saveload.h"`
`#include "../saveload/saveload_filter.h"`
`#include "../station_base.h"`
`#include "../genworld.h"`
`#include "../company_func.h"`
`#include "../company_gui.h"`
`#include "../company_cmd.h"`
`#include "../roadveh.h"`
`#include "../order_backup.h"`
`#include "../core/pool_func.hpp"`
`#include "../core/random_func.hpp"`
`#include "../rev.h"`
`#include "../timer/timer.h"`
`#include "../timer/timer_game_calendar.h"`
`#include "../timer/timer_game_economy.h"`
`#include "../timer/timer_game_realtime.h"`
`#include <mutex>`
`#include <condition_variable>`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | PacketWriter
| Writing a savegame directly to a number of packets. More...

## Functions
static NetworkAuthenticationDefaultPasswordProvider | _password_provider (_settings_client.network.server_password)
| Provides the password validation for the game's password.
static NetworkAuthenticationDefaultAuthorizedKeyHandler | _authorized_key_handler (_settings_client.network.server_authorized_keys)
| Provides the authorized key handling for the game authentication.
static NetworkAuthenticationDefaultAuthorizedKeyHandler | _rcon_authorized_key_handler (_settings_client.network.rcon_authorized_keys)
| Provides the authorized key validation for rcon.
static void | NetworkHandleCommandQueue (NetworkClientSocket *cs)
| Handle the command-queue of a socket.
static NetworkErrorCode | GetErrorForAuthenticationMethod (NetworkAuthenticationMethod method)
void | NetworkServerSendChat (NetworkAction action, DestType desttype, int dest, std::string_view msg, ClientID from_id, int64_t data, bool from_admin)
| Send an actual chat message.
void | NetworkServerSendExternalChat (std::string_view source, TextColour colour, std::string_view user, std::string_view msg)
| Send a chat message from external source.
NetworkCompanyStatsArray | NetworkGetCompanyStats ()
| Get the company stats.
void | NetworkUpdateClientInfo (ClientID client_id)
| Send updated client info of a particular client.
static void | NetworkAutoCleanCompanies ()
| Remove companies that have not been used depending on the `autoclean_companies` setting and values for `autoclean_protected`, which removes any company, and `autoclean_novehicles`, which removes companies without vehicles.
bool | NetworkMakeClientNameUnique (std::string &name)
| Check whether a name is unique, and otherwise try to make it unique.
bool | NetworkServerChangeClientName (ClientID client_id, const std::string &new_name)
| Change the client name of the given client.
void | NetworkServer_Tick (bool send_frame)
| This is called every tick if this is a _network_server.
static void | NetworkRestartMap ()
| Helper function to restart the map.
void | ChangeNetworkRestartTime (bool reset)
| Reset the automatic network restart time interval.
static void | NetworkCheckRestartMapYear ()
| Check if we want to restart the map based on the year.
void | NetworkServerShowStatusToConsole ()
| Show the status message of all clients on the console.
void | NetworkServerSendConfigUpdate ()
| Send Config Update.
void | NetworkServerUpdateGameInfo ()
| Update the server's NetworkServerGameInfo due to changes in settings.
void | NetworkServerDoMove (ClientID client_id, CompanyID company_id)
| Handle the tid-bits of moving a client from one company to another.
void | NetworkServerSendRcon (ClientID client_id, TextColour colour_code, std::string_view string)
| Send an rcon reply to the client.
void | NetworkServerKickClient (ClientID client_id, std::string_view reason)
| Kick a single client.
uint | NetworkServerKickOrBanIP (ClientID client_id, bool ban, std::string_view reason)
| Ban, or kick, everyone joined from the given client's IP.
uint | NetworkServerKickOrBanIP (std::string_view ip, bool ban, std::string_view reason)
| Kick or ban someone based on an IP address.
bool | NetworkCompanyHasClients (CompanyID company)
| Check whether a particular company has clients.
void | NetworkPrintClients ()
| Print all the clients to the console.
std::string_view | NetworkGetPublicKeyOfClient (ClientID client_id)
| Get the public key of the client with the given id.
void | NetworkServerNewCompany (const Company *c, NetworkClientInfo *ci)
| Perform all the server specific administration of a new company.

## Variables
static ClientID | _network_client_id = CLIENT_ID_FIRST
| The identifier counter for new clients (is never decreased)
NetworkClientSocketPool | _networkclientsocket_pool ("NetworkClientSocket")
| Make very sure the preconditions given in network_type.h are actually followed.
static IntervalTimer< TimerGameRealtime > | _network_restart_map_timer ({std::chrono::hours::zero(), TimerGameRealtime::UNPAUSED}, [](auto) { if(!_network_server) return;if(_settings_client.network.restart_hours==0) return;Debug(net, 3, "Auto-restarting map: {} hours played", _settings_client.network.restart_hours);NetworkRestartMap();})
| Timer to restart a network server automatically based on real-time hours played.
static const IntervalTimer< TimerGameCalendar > | _calendar_network_yearly ({ TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE }, [](auto) { if(!_network_server) return;NetworkCheckRestartMapYear();})
| Calendar yearly "callback".
static const IntervalTimer< TimerGameEconomy > | _economy_network_yearly ({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::NONE}, [](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Annually);})
| Economy yearly "callback".
static const IntervalTimer< TimerGameEconomy > | _network_quarterly ({TimerGameEconomy::QUARTER, TimerGameEconomy::Priority::NONE}, [](auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Quarterly);})
| Quarterly "callback".
static const IntervalTimer< TimerGameEconomy > | _network_monthly ({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::NONE}, [](auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Monthly);})
| Economy monthly "callback".
static const IntervalTimer< TimerGameEconomy > | _network_weekly ({TimerGameEconomy::WEEK, TimerGameEconomy::Priority::NONE}, [](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Weekly);})
| Economy weekly "callback".
static const IntervalTimer< TimerGameEconomy > | _economy_network_daily ({TimerGameEconomy::DAY, TimerGameEconomy::Priority::NONE}, [](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Daily);})
| Daily "callback".

## Detailed Description

Server part of the network protocol.

Definition in file network_server.cpp.

## Function Documentation

## ◆ ChangeNetworkRestartTime()

void ChangeNetworkRestartTime | ( | bool | reset | ) |

Reset the automatic network restart time interval.

Parameters

  reset | Whether to reset the timer to zero.

Definition at line 1847 of file network_server.cpp.

References _network_restart_map_timer, _network_server, _settings_client, ClientSettings::network, NetworkSettings::restart_hours, IntervalTimer< TTimerType >::SetInterval(), and TimerGameRealtime::UNPAUSED.

Referenced by NetworkOnGameStart().

## ◆ GetErrorForAuthenticationMethod()

static NetworkErrorCode GetErrorForAuthenticationMethod | ( | NetworkAuthenticationMethod | method | ) |
| static

Definition at line 932 of file network_server.cpp.

## ◆ NetworkAutoCleanCompanies()

static void NetworkAutoCleanCompanies | ( |  | ) |
| static

Remove companies that have not been used depending on the `autoclean_companies` setting and values for `autoclean_protected`, which removes any company, and `autoclean_novehicles`, which removes companies without vehicles.

Definition at line 1551 of file network_server.cpp.

References _network_dedicated, _settings_client, NetworkSettings::autoclean_companies, NetworkSettings::autoclean_novehicles, NetworkSettings::autoclean_protected, CC_INFO, CCA_DELETE, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, CRR_AUTOCLEAN, NetworkClientInfo::GetByClientID(), IConsolePrint(), INVALID_CLIENT_ID, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkclientinfo_pool >::Iterate(), ClientSettings::network, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

## ◆ NetworkCheckRestartMapYear()

static void NetworkCheckRestartMapYear | ( |  | ) |
| static

Check if we want to restart the map based on the year.

Definition at line 1855 of file network_server.cpp.

References _settings_client, Debug, ClientSettings::network, NetworkRestartMap(), NetworkSettings::restart_game_year, and TimerGameCalendar::year.

## ◆ NetworkCompanyHasClients()

bool NetworkCompanyHasClients | ( | CompanyID | company | ) |

Check whether a particular company has clients.

Parameters

  company | The company to check.

Returns
  True if at least one client is joined to the company.

Definition at line 2090 of file network_server.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkclientinfo_pool >::Iterate().

Referenced by AdminCompanyResetCallback(), and NetworkClientListWindow::OnClickCompanyAdmin().

## ◆ NetworkGetCompanyStats()

NetworkCompanyStatsArray NetworkGetCompanyStats | ( |  | ) |

Get the company stats.

Definition at line 1491 of file network_server.cpp.

References Airport, BusStop, Dock, SpecializedVehicle< T, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), NetworkCompanyStats::num_station, Train, TruckStop, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by ServerNetworkAdminSocketHandler::SendCompanyStats().

## ◆ NetworkGetPublicKeyOfClient()

std::string_view NetworkGetPublicKeyOfClient | ( | ClientID | client_id | ) |

Get the public key of the client with the given id.

Parameters

  client_id | The id of the client.

Returns
  View of the public key, which is empty when the client does not exist.

Definition at line 2138 of file network_server.cpp.

## ◆ NetworkHandleCommandQueue()

static void NetworkHandleCommandQueue | ( | NetworkClientSocket * | cs | ) |
| static

Handle the command-queue of a socket.

Parameters

  cs | The socket to handle the queue for.

Definition at line 1669 of file network_server.cpp.

Referenced by NetworkServer_Tick(), and ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK().

## ◆ NetworkMakeClientNameUnique()

bool NetworkMakeClientNameUnique | ( | std::string & | name | ) |

Check whether a name is unique, and otherwise try to make it unique.

Parameters

  new_name | The name to check/modify.

Returns
  True if an unique name was achieved.

Definition at line 1608 of file network_server.cpp.

References CLIENT_ID_SERVER, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkclientinfo_pool >::Iterate(), MAX_CLIENTS, and NETWORK_CLIENT_NAME_LENGTH.

Referenced by NetworkUpdateClientName(), ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(), and ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME().

## ◆ NetworkPrintClients()

void NetworkPrintClients | ( |  | ) |

Print all the clients to the console.

Definition at line 2115 of file network_server.cpp.

References _network_server, CC_INFO, CLIENT_ID_SERVER, IConsolePrint(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkclientinfo_pool >::Iterate().

## ◆ NetworkRestartMap()

static void NetworkRestartMap | ( |  | ) |
| static

Helper function to restart the map.

Definition at line 1813 of file network_server.cpp.

References _file_to_saveload, _settings_newgame, _switch_mode, FiosType::abstract, FT_HEIGHTMAP, FT_SAVEGAME, FT_SCENARIO, FileToSaveLoad::ftype, GameSettings::game_creation, GENERATE_NEW_SEED, GameCreationSettings::generation_seed, SM_LOAD_GAME, SM_NEWGAME, and SM_START_HEIGHTMAP.

Referenced by NetworkCheckRestartMapYear().

## ◆ NetworkServer_Tick()

void NetworkServer_Tick | ( | bool | send_frame | ) |

This is called every tick if this is a _network_server.

Parameters

  send_frame | Whether to send the frame to the clients.

Definition at line 1679 of file network_server.cpp.

References _frame_counter, _last_sync_frame, _settings_client, NetworkSettings::bytes_per_frame, NetworkSettings::bytes_per_frame_burst, CC_WARNING, Ticks::DAY_TICKS, IConsolePrint(), NetworkSettings::max_download_time, NetworkSettings::max_init_time, NetworkSettings::max_join_time, NetworkSettings::max_lag_time, NetworkSettings::max_password_time, MILLISECONDS_PER_TICK, ClientSettings::network, NetworkHandleCommandQueue(), and NetworkSettings::sync_freq.

## ◆ NetworkServerChangeClientName()

bool NetworkServerChangeClientName | ( | ClientID | client_id,
|  | const std::string & | new_name
| ) |  |

Change the client name of the given client.

Parameters

  client_id | the client to change the name of
  new_name | the new name for the client

Returns
  true iff the name was changed

Definition at line 1647 of file network_server.cpp.

References CC_DEFAULT, NetworkClientInfo::client_name, NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_networkclientinfo_pool >::Iterate(), and NetworkUpdateClientInfo().

## ◆ NetworkServerDoMove()

void NetworkServerDoMove | ( | ClientID | client_id,
|  | CompanyID | company_id
| ) |  |

Handle the tid-bits of moving a client from one company to another.

Parameters

  client_id | id of the client we want to move.
  company_id | id of the company we want to move the client to.

Returns
  void

Definition at line 1976 of file network_server.cpp.

References _network_dedicated, CLIENT_ID_SERVER, NetworkClientInfo::client_playas, COMPANY_SPECTATOR, DESTTYPE_BROADCAST, NetworkClientInfo::GetByClientID(), GetString(), InvalidateWindowData(), NetworkServerSendChat(), NetworkUpdateClientInfo(), SetLocalCompany(), and WC_CLIENT_LIST.

Referenced by MenuClickCompany(), CompanyWindow::OnClick(), NetworkClientListWindow::OnClickCompanyJoin(), and ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE().

## ◆ NetworkServerKickClient()

void NetworkServerKickClient | ( | ClientID | client_id,
|  | std::string_view | reason
| ) |  |

Kick a single client.

Parameters

  client_id | The client to kick.
  reason | In case of kicking a client, specifies the reason for kicking the client.

Definition at line 2029 of file network_server.cpp.

References CLIENT_ID_SERVER.

Referenced by AdminClientKickCallback(), and NetworkServerKickOrBanIP().

## ◆ NetworkServerKickOrBanIP() [1/2]

uint NetworkServerKickOrBanIP | ( | ClientID | client_id,
|  | bool | ban,
|  | std::string_view | reason
| ) |  |

Ban, or kick, everyone joined from the given client's IP.

Parameters

  client_id | The client to check for.
  ban | Whether to ban or kick.
  reason | In case of kicking a client, specifies the reason for kicking the client.

Definition at line 2041 of file network_server.cpp.

References NetworkServerKickOrBanIP().

Referenced by AdminClientBanCallback(), and NetworkServerKickOrBanIP().

## ◆ NetworkServerKickOrBanIP() [2/2]

uint NetworkServerKickOrBanIP | ( | std::string_view | ip,
|  | bool | ban,
|  | std::string_view | reason
| ) |  |

Kick or ban someone based on an IP address.

Parameters

  ip | The IP address/range to ban/kick.
  ban | Whether to ban or just kick.
  reason | In case of kicking a client, specifies the reason for kicking the client.

Definition at line 2052 of file network_server.cpp.

References _network_ban_list, _redirect_console_to_client, CLIENT_ID_SERVER, and NetworkServerKickClient().

## ◆ NetworkServerNewCompany()

void NetworkServerNewCompany | ( | const Company * | c,
|  | NetworkClientInfo * | ci
| ) |  |

Perform all the server specific administration of a new company.

Parameters

  c | The newly created company; can't be nullptr.
  ci | The client information of the client that made the company; can be nullptr.

Definition at line 2150 of file network_server.cpp.

References _network_server, CALCA_ADD, NetworkClientInfo::client_id, NetworkClientInfo::client_name, NetworkClientInfo::client_playas, DESTTYPE_BROADCAST, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, NetworkServerSendChat(), NetworkUpdateClientInfo(), and NetworkClientInfo::public_key.

Referenced by CmdCompanyCtrl(), and NetworkOnGameStart().

## ◆ NetworkServerSendChat()

void NetworkServerSendChat | ( | NetworkAction | action,
|  | DestType | desttype,
|  | int | dest,
|  | std::string_view | msg,
|  | ClientID | from_id,
|  | int64_t | data,
|  | bool | from_admin
| ) |  |

Send an actual chat message.

Parameters

  action | The action that's performed.
  desttype | The type of destination.
  dest | The actual destination index.
  msg | The actual message.
  from_id | The origin of the message.
  data | Arbitrary data.
  from_admin | Whether the origin is an admin or not.

Definition at line 1252 of file network_server.cpp.

References _local_company, _settings_client, NetworkClientInfo::client_id, CLIENT_ID_SERVER, NetworkClientInfo::client_name, NetworkClientInfo::client_playas, Debug, DESTTYPE_BROADCAST, DESTTYPE_CLIENT, DESTTYPE_TEAM, NetworkClientInfo::GetByClientID(), GetDrawStringCompanyColour(), GetString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), ClientSettings::network, NetworkAdminChat(), NetworkSettings::server_admin_chat, and ServerNetworkGameSocketHandler::STATUS_AUTHORIZED.

Referenced by NetworkServerDoMove(), NetworkServerNewCompany(), ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(), ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(), ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(), and SendChat().

## ◆ NetworkServerSendConfigUpdate()

void NetworkServerSendConfigUpdate | ( |  | ) |

Send Config Update.

Definition at line 1957 of file network_server.cpp.

Referenced by UpdateClientConfigValues().

## ◆ NetworkServerSendExternalChat()

void NetworkServerSendExternalChat | ( | std::string_view | source,
|  | TextColour | colour,
|  | std::string_view | user,
|  | std::string_view | msg
| ) |  |

Send a chat message from external source.

Parameters

  source | Name of the source this message came from.
  colour | TextColour to use for the message.
  user | Name of the user who sent the message.
  msg | The actual message.

Definition at line 1369 of file network_server.cpp.

References ServerNetworkGameSocketHandler::STATUS_AUTHORIZED.

Referenced by ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT().

## ◆ NetworkServerSendRcon()

void NetworkServerSendRcon | ( | ClientID | client_id,
|  | TextColour | colour_code,
|  | std::string_view | string
| ) |  |

Send an rcon reply to the client.

Parameters

  client_id | The identifier of the client.
  colour_code | The colour of the text.
  string | The actual reply.

Definition at line 2019 of file network_server.cpp.

Referenced by IConsolePrint().

## ◆ NetworkServerShowStatusToConsole()

void NetworkServerShowStatusToConsole | ( |  | ) |

Show the status message of all clients on the console.

Definition at line 1925 of file network_server.cpp.

References CC_INFO, NetworkClientInfo::client_name, NetworkClientInfo::client_playas, IConsolePrint(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), and lengthof.

## ◆ NetworkServerUpdateGameInfo()

void NetworkServerUpdateGameInfo | ( |  | ) |

Update the server's NetworkServerGameInfo due to changes in settings.

Definition at line 1965 of file network_server.cpp.

References _network_server.

Referenced by NetworkOnGameStart(), and UpdateClientConfigValues().

## ◆ NetworkUpdateClientInfo()

void NetworkUpdateClientInfo | ( | ClientID | client_id | ) |

Send updated client info of a particular client.

Parameters

  client_id | The client to send it for.

Definition at line 1529 of file network_server.cpp.

References NetworkClientInfo::client_playas, TimerGameEconomy::date, TimerGameEconomy::date_fract, Debug, NetworkClientInfo::GetByClientID(), NetworkAdminClientUpdate(), and ServerNetworkGameSocketHandler::STATUS_AUTHORIZED.

Referenced by CmdCompanyCtrl(), NetworkServerChangeClientName(), NetworkServerDoMove(), NetworkServerNewCompany(), NetworkUpdateClientName(), and ServerNetworkGameSocketHandler::Receive_CLIENT_SET_NAME().

## Variable Documentation

## ◆ _calendar_network_yearly

const IntervalTimer< TimerGameCalendar > _calendar_network_yearly({ TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE },[](auto) { if(!_network_server) return;NetworkCheckRestartMapYear();}) | ( | { TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE } | ,
|  | [] (auto) { if(!_network_server) return;NetworkCheckRestartMapYear();} |
| ) |  |
| static

Calendar yearly "callback".

Called whenever the calendar year changes.

## ◆ _economy_network_daily

const IntervalTimer< TimerGameEconomy > _economy_network_daily({TimerGameEconomy::DAY, TimerGameEconomy::Priority::NONE},[](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Daily);}) | ( | {TimerGameEconomy::DAY, TimerGameEconomy::Priority::NONE} | ,
|  | [] (auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Daily);} |
| ) |  |
| static

Daily "callback".

Called whenever the economy date changes.

## ◆ _economy_network_yearly

const IntervalTimer< TimerGameEconomy > _economy_network_yearly({TimerGameEconomy::YEAR, TimerGameEconomy::Priority::NONE},[](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Annually);}) | ( | {TimerGameEconomy::YEAR, TimerGameEconomy::Priority::NONE} | ,
|  | [] (auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Annually);} |
| ) |  |
| static

Economy yearly "callback".

Called whenever the economy year changes.

## ◆ _network_client_id

ClientID _network_client_id = CLIENT_ID_FIRST
| static

The identifier counter for new clients (is never decreased)

Definition at line 49 of file network_server.cpp.

Referenced by ServerNetworkGameSocketHandler::ServerNetworkGameSocketHandler().

## ◆ _network_monthly

const IntervalTimer< TimerGameEconomy > _network_monthly({TimerGameEconomy::MONTH, TimerGameEconomy::Priority::NONE},[](auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Monthly);}) | ( | {TimerGameEconomy::MONTH, TimerGameEconomy::Priority::NONE} | ,
|  | [] (auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Monthly);} |
| ) |  |
| static

Economy monthly "callback".

Called whenever the economy month changes.

## ◆ _network_quarterly

const IntervalTimer< TimerGameEconomy > _network_quarterly({TimerGameEconomy::QUARTER, TimerGameEconomy::Priority::NONE},[](auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Quarterly);}) | ( | {TimerGameEconomy::QUARTER, TimerGameEconomy::Priority::NONE} | ,
|  | [] (auto) { if(!_network_server) return;NetworkAutoCleanCompanies();NetworkAdminUpdate(AdminUpdateFrequency::Quarterly);} |
| ) |  |
| static

Quarterly "callback".

Called whenever the economy quarter changes.

## ◆ _network_restart_map_timer

IntervalTimer< TimerGameRealtime > _network_restart_map_timer({std::chrono::hours::zero(), TimerGameRealtime::UNPAUSED},[](auto) { if(!_network_server) return; if(_settings_client.network.restart_hours==0) return;Debug(net, 3, "Auto-restarting map: {} hours played", _settings_client.network.restart_hours);NetworkRestartMap();}) | ( | {std::chrono::hours::zero(), TimerGameRealtime::UNPAUSED} | ,
|  | [] (auto) { if(!_network_server) return;if(_settings_client.network.restart_hours==0) return;Debug(net, 3, "Auto-restarting map: {} hours played", _settings_client.network.restart_hours);NetworkRestartMap();} |
| ) |  |
| static

Timer to restart a network server automatically based on real-time hours played.

Initialized at zero to disable until settings are loaded.

Referenced by ChangeNetworkRestartTime().

## ◆ _network_weekly

const IntervalTimer< TimerGameEconomy > _network_weekly({TimerGameEconomy::WEEK, TimerGameEconomy::Priority::NONE},[](auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Weekly);}) | ( | {TimerGameEconomy::WEEK, TimerGameEconomy::Priority::NONE} | ,
|  | [] (auto) { if(!_network_server) return;NetworkAdminUpdate(AdminUpdateFrequency::Weekly);} |
| ) |  |
| static

Economy weekly "callback".

Called whenever the economy week changes.

## ◆ _networkclientsocket_pool

NetworkClientSocketPool _networkclientsocket_pool("NetworkClientSocket") | ( | "NetworkClientSocket" |  | ) |

Make very sure the preconditions given in network_type.h are actually followed.

The pool with clients.