OpenTTD Source 20260421-master-gc2fbc6fdeb
network.cpp File Reference

Base functions for networking support. More...

#include "../stdafx.h"
#include "../strings_func.h"
#include "../command_func.h"
#include "../timer/timer_game_tick.h"
#include "../timer/timer_game_economy.h"
#include "network_admin.h"
#include "network_client.h"
#include "network_query.h"
#include "network_server.h"
#include "network_content.h"
#include "network_udp.h"
#include "network_gamelist.h"
#include "network_base.h"
#include "network_coordinator.h"
#include "core/udp.h"
#include "core/host.h"
#include "network_gui.h"
#include "../console_func.h"
#include "../3rdparty/md5/md5.h"
#include "../core/random_func.hpp"
#include "../window_func.h"
#include "../company_func.h"
#include "../company_base.h"
#include "../landscape_type.h"
#include "../rev.h"
#include "../core/pool_func.hpp"
#include "../gfx_func.h"
#include "../error.h"
#include "../misc_cmd.h"
#include "../core/string_builder.hpp"
#include <charconv>
#include "table/strings.h"
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

class  TCPQueryConnecter
 Non blocking connection to query servers for their game info. More...
class  TCPClientConnecter
 Non blocking connection create to actually connect to servers. More...

Functions

std::string GenerateUid (std::string_view subject)
 Generate an unique ID.
bool HasClients ()
 Return whether there is any client connected or trying to connect at all.
bool NetworkCanJoinCompany (CompanyID company_id)
 Returns whether the given company can be joined by this client.
static auto FindKey (auto *authorized_keys, std::string_view authorized_key)
 Simple helper to find the location of the given authorized key in the authorized keys.
uint8_t NetworkSpectatorCount ()
 Get the number of clients that are playing as a spectator.
void NetworkTextMessage (NetworkAction action, TextColour colour, bool self_send, std::string_view name, std::string_view str, StringParameter &&data)
 Writes a text-message to the console and the chat box.
uint NetworkCalculateLag (const NetworkClientSocket *cs)
 Calculate the frame-lag of a client.
void ShowNetworkError (StringID error_string)
 There was a non-recoverable error, drop back to the main menu with a nice error.
StringID GetNetworkErrorMsg (NetworkErrorCode err)
 Retrieve a short translateable string of the error code.
void NetworkHandlePauseChange (PauseModes prev_mode, PauseMode changed_mode)
 Handle the pause mode change so we send the right messages to the chat.
static void CheckPauseHelper (bool pause, PauseMode pm)
 Helper function for the pause checkers.
static uint NetworkCountActiveClients ()
 Counts the number of active clients connected.
static void CheckMinActiveClients ()
 Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate.
static bool NetworkHasJoiningClient ()
 Checks whether there is a joining client.
static void CheckPauseOnJoin ()
 Check whether we should pause on join.
std::string_view ParseCompanyFromConnectionString (std::string_view connection_string, CompanyID *company_id)
 Parse the company part ("#company" postfix) of a connecting string.
std::string_view ParseFullConnectionString (std::string_view connection_string, uint16_t &port, CompanyID *company_id)
 Converts a string to ip/port/company Format: IP:port#company.
std::string NormalizeConnectionString (std::string_view connection_string, uint16_t default_port)
 Normalize a connection string.
NetworkAddress ParseConnectionString (std::string_view connection_string, uint16_t default_port)
 Convert a string containing either "hostname" or "hostname:ip" to a NetworkAddress.
static void InitializeNetworkPools (bool close_admins=true)
 Resets the pools used for network clients, and the admin pool if needed.
void NetworkClose (bool close_admins)
 Close current connections.
static void NetworkInitialize (bool close_admins=true)
 Initializes the network (cleans sockets and stuff).
void NetworkQueryServer (std::string_view connection_string)
 Query a server to fetch the game-info.
NetworkGameNetworkAddServer (std::string_view connection_string, bool manually, bool never_expire)
 Validates an address entered as a string and adds the server to the list.
void GetBindAddresses (NetworkAddressList *addresses, uint16_t port)
 Get the addresses to bind to.
void NetworkRebuildHostList ()
 Generates the list of manually added hosts from NetworkGame and dumps them into the array _network_host_list.
bool NetworkClientConnectGame (std::string_view connection_string, CompanyID default_company, const std::string &join_server_password)
 Join a client to the server at with the given connection string.
void NetworkClientJoinGame ()
 Actually perform the joining to the server.
static void NetworkInitGameInfo ()
 Initialise/fill the server's game info.
static void NetworkInitServerClientInfo ()
 Initialise the server's client info.
bool NetworkValidateServerName (std::string &server_name)
 Trim the given server name in place, i.e.
static void CheckClientAndServerName ()
 Check whether the client and server name are set, for a dedicated server and if not set them to some default value and tell the user to change this as soon as possible.
bool NetworkServerStart ()
 Run everything related to the network when starting a server.
void NetworkOnGameStart ()
 Perform tasks when the server is started.
void NetworkReboot ()
 The server is rebooting... The only difference with NetworkDisconnect, is the packets that is sent.
void NetworkDisconnect (bool close_admins)
 We want to disconnect from the host/clients.
void NetworkUpdateServerGameType ()
 The setting server_game_type was updated; possibly we need to take some action.
static bool NetworkReceive ()
 Receives something from the network.
static void NetworkSend ()
 This sends all buffered commands (if possible).
void NetworkBackgroundLoop ()
 We have to do some (simple) background stuff that runs normally, even when we are not in multiplayer.
void NetworkGameLoop ()
 The main loop called from ttd.c.
void NetworkStartUp ()
 This tries to launch the network for a given OS.
void NetworkShutDown ()
 This shuts the network down.

Variables

NetworkClientInfoPool _networkclientinfo_pool {"NetworkClientInfo"}
 Make sure both pools have the same size.
bool _networking
 are we in networking mode?
bool _network_server
 network-server is active
bool _network_available
 is network mode available?
bool _network_dedicated
 are we a dedicated server?
bool _is_network_server
 Does this client wants to be a network-server?
ClientID _network_own_client_id
 Our client identifier.
ClientID _redirect_console_to_client
 If not invalid, redirect the console output to a client.
uint8_t _network_reconnect
 Reconnect timeout.
StringList _network_bind_list
 The addresses to bind on.
StringList _network_host_list
 The servers we know.
StringList _network_ban_list
 The banned clients.
uint32_t _frame_counter_server
 The frame_counter of the server, if in network-mode.
uint32_t _frame_counter_max
 To where we may go with our clients.
uint32_t _frame_counter
 The current frame.
uint32_t _last_sync_frame
 Used in the server to store the last time a sync packet was sent to clients.
NetworkAddressList _broadcast_list
 List of broadcast addresses.
uint32_t _sync_seed_1
 Seed to compare during sync checks.
uint32_t _sync_frame
 The frame to perform the sync check.
bool _network_first_time
 Whether we have finished joining or not.
uint8_t _network_clients_connected = 0
 The amount of clients connected.

Detailed Description

Base functions for networking support.

Definition in file network.cpp.

Function Documentation

◆ CheckClientAndServerName()

void CheckClientAndServerName ( )
static

Check whether the client and server name are set, for a dedicated server and if not set them to some default value and tell the user to change this as soon as possible.

If the saved name is the default value, then the user is told to override this value too. This is only meant dedicated servers, as for the other servers the GUI ensures a name has been entered.

Definition at line 902 of file network.cpp.

References _settings_client, Debug, and StrTrimInPlace().

Referenced by NetworkServerStart().

◆ CheckMinActiveClients()

void CheckMinActiveClients ( )
static

Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate.

Definition at line 446 of file network.cpp.

References _network_dedicated, _pause_mode, _settings_client, ActiveClients, CheckPauseHelper(), Error, and NetworkCountActiveClients().

Referenced by NetworkGameLoop().

◆ CheckPauseHelper()

void CheckPauseHelper ( bool pause,
PauseMode pm )
static

Helper function for the pause checkers.

If pause is true and the current pause mode isn't set the game will be paused, if it it false and the pause mode is set the game will be unpaused. In the other cases nothing happens to the pause state.

Parameters
pausewhether we'd like to pause
pmthe mode which we would like to pause with

Definition at line 418 of file network.cpp.

References _pause_mode.

Referenced by CheckMinActiveClients(), and CheckPauseOnJoin().

◆ CheckPauseOnJoin()

void CheckPauseOnJoin ( )
static

Check whether we should pause on join.

Definition at line 472 of file network.cpp.

References _pause_mode, _settings_client, CheckPauseHelper(), Error, Join, and NetworkHasJoiningClient().

Referenced by NetworkGameLoop().

◆ FindKey()

auto FindKey ( auto * authorized_keys,
std::string_view authorized_key )
static

Simple helper to find the location of the given authorized key in the authorized keys.

Parameters
authorized_keysThe keys to look through.
authorized_keyThe key to look for.
Returns
The iterator to the location of the authorized key, or authorized_keys.end().

Definition at line 170 of file network.cpp.

References StrEqualsIgnoreCase().

Referenced by NetworkAuthorizedKeys::Add(), NetworkAuthorizedKeys::Contains(), and NetworkAuthorizedKeys::Remove().

◆ GenerateUid()

std::string GenerateUid ( std::string_view subject)
extern

Generate an unique ID.

It isn't as much of an unique ID but more a hashed digest of a random string and a time. It is very likely to be unique, but it does not follow any UUID standard.

Parameters
subjectWhat to create the ID for.
Returns
The generated ID.

Definition at line 68 of file misc.cpp.

References FormatArrayAsHex(), and RandomBytesWithFallback().

Referenced by GenerateSavegameId().

◆ GetBindAddresses()

void GetBindAddresses ( NetworkAddressList * addresses,
uint16_t port )

Get the addresses to bind to.

Parameters
addressesthe list to write to.
portthe port to bind to.

Definition at line 737 of file network.cpp.

References _network_bind_list.

Referenced by TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Listen(), and NetworkUDPInitialize().

◆ GetNetworkErrorMsg()

◆ HasClients()

bool HasClients ( )

Return whether there is any client connected or trying to connect at all.

Returns
whether we have any client activity

Definition at line 99 of file network.cpp.

◆ InitializeNetworkPools()

void InitializeNetworkPools ( bool close_admins = true)
static

Resets the pools used for network clients, and the admin pool if needed.

Parameters
close_adminsWhether the admin pool has to be cleared as well.

Definition at line 593 of file network.cpp.

References PoolBase::Clean(), NetworkAdmin, NetworkClient, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

Referenced by ClientNetworkGameSocketHandler::NetworkClose, and NetworkInitialize().

◆ NetworkAddServer()

NetworkGame * NetworkAddServer ( std::string_view connection_string,
bool manually,
bool never_expire )

Validates an address entered as a string and adds the server to the list.

If you use this function, the games will be marked as manually added.

Parameters
connection_stringThe IP:port of the server to add.
manuallyWhether the enter should be marked as manual added.
never_expireWhether the entry can expire (removed when no longer found in the public listing).
Returns
The entry on the game list.

Definition at line 711 of file network.cpp.

References ClearGRFConfigList(), NetworkServerGameInfo::grfconfig, NetworkGame::info, NetworkGame::manually, NetworkGameListAddItem(), NetworkQueryServer(), NetworkServerGameInfo::server_name, UpdateNetworkGameWindow(), and NetworkGame::version.

Referenced by NetworkGameWindow::NetworkGameWindow(), NetworkGameWindow::OnQueryTextFinished(), ClientNetworkUDPSocketHandler::ReceiveServerResponse(), and ShowNetworkGameWindow().

◆ NetworkBackgroundLoop()

void NetworkBackgroundLoop ( )

We have to do some (simple) background stuff that runs normally, even when we are not in multiplayer.

For example stuff needed for finding servers or downloading content.

Definition at line 1116 of file network.cpp.

References _network_content_client, _network_coordinator_client, TCPConnecter::CheckCallbacks(), NetworkHTTPSocketHandler::HTTPReceive(), NetworkBackgroundUDPLoop(), NetworkGameSocketHandler::ProcessDeferredDeletions(), and QueryNetworkGameSocketHandler::SendReceive().

Referenced by NetworkSurveyHandler::Transmit().

◆ NetworkCalculateLag()

uint NetworkCalculateLag ( const NetworkClientSocket * cs)

Calculate the frame-lag of a client.

Parameters
csThe client's socket.
Returns
The number of frames the client is lagging behind.

Definition at line 299 of file network.cpp.

References _frame_counter, _settings_client, and Ticks::DAY_TICKS.

Referenced by NetworkServer_Tick(), and NetworkServerShowStatusToConsole().

◆ NetworkCanJoinCompany()

bool NetworkCanJoinCompany ( CompanyID company_id)

Returns whether the given company can be joined by this client.

Parameters
company_idThe id of the company.
Returns
true when this company is allowed to join, otherwise false.

Definition at line 143 of file network.cpp.

References _network_own_client_id, NetworkClientInfo::CanJoinCompany(), and NetworkClientInfo::GetByClientID().

Referenced by CompanyWindow::OnPaint().

◆ NetworkClientConnectGame()

bool NetworkClientConnectGame ( std::string_view connection_string,
CompanyID default_company,
const std::string & join_server_password )

Join a client to the server at with the given connection string.

The default for the passwords is nullptr. When the server needs a password and none is given, the user is asked to enter the password in the GUI. This function will return false whenever some information required to join is not correct such as the company number or the client's name, or when there is not networking avalabile at all. If the function returns false the connection with the existing server is not disconnected. It will return true when it starts the actual join process, i.e. when it actually shows the join status window.

Parameters
connection_stringThe IP address, port and company number to join as.
default_companyThe company number to join as when none is given.
join_server_passwordThe password for the server.
Returns
Whether the join has started.

Definition at line 809 of file network.cpp.

References _network_available, _network_join, _switch_mode, ServerAddress::connection_string, Debug, NETWORK_DEFAULT_PORT, NetworkClientJoinGame(), NetworkValidateOurClientName(), ServerAddress::Parse(), and SM_JOIN_GAME.

Referenced by ConNetworkConnect(), ConNetworkReconnect(), NetworkGameWindow::OnClick(), and AfterNewGRFScan::OnNewGRFsScanned().

◆ NetworkClientJoinGame()

void NetworkClientJoinGame ( )

Actually perform the joining to the server.

Use NetworkClientConnectGame when you want to connect to a specific server/company. This function assumes _network_join is already fully set up.

Definition at line 842 of file network.cpp.

References _network_join, _network_join_status, _settings_client, Connecting, TCPConnecter::Create(), Debug, NetworkDisconnect(), NetworkInitialize(), and ShowJoinStatusWindow().

Referenced by NetworkClientConnectGame().

◆ NetworkClose()

void NetworkClose ( bool close_admins)

Close current connections.

Parameters
close_adminsWhether the admin connections have to be closed as well.

Definition at line 604 of file network.cpp.

Referenced by NetworkDisconnect(), and NetworkReboot().

◆ NetworkCountActiveClients()

uint NetworkCountActiveClients ( )
static

Counts the number of active clients connected.

It has to be in STATUS_ACTIVE and not a spectator

Returns
number of active clients

Definition at line 430 of file network.cpp.

Referenced by CheckMinActiveClients().

◆ NetworkDisconnect()

void NetworkDisconnect ( bool close_admins)

◆ NetworkGameLoop()

◆ NetworkHandlePauseChange()

void NetworkHandlePauseChange ( PauseModes prev_mode,
PauseMode changed_mode )

Handle the pause mode change so we send the right messages to the chat.

Parameters
prev_modeThe previous pause mode.
changed_modeThe pause mode that got changed.

Definition at line 363 of file network.cpp.

References _networking, _pause_mode, ActiveClients, CC_DEFAULT, GameScript, GetString(), GetStringWithArgs(), Join, LinkGraph, NetworkTextMessage(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), Normal, and ServerMessage.

Referenced by CmdPause().

◆ NetworkHasJoiningClient()

bool NetworkHasJoiningClient ( )
static

Checks whether there is a joining client.

Returns
true iff one client is joining (but not authorizing)

Definition at line 460 of file network.cpp.

Referenced by CheckPauseOnJoin().

◆ NetworkInitGameInfo()

void NetworkInitGameInfo ( )
static

Initialise/fill the server's game info.

Definition at line 856 of file network.cpp.

References _network_dedicated, _network_game_info, and FillStaticNetworkServerGameInfo().

Referenced by NetworkServerStart().

◆ NetworkInitialize()

void NetworkInitialize ( bool close_admins = true)
static

Initializes the network (cleans sockets and stuff).

Parameters
close_adminsWhether to disconnect all the admin connections.

Definition at line 644 of file network.cpp.

References _network_first_time, _network_reconnect, _sync_frame, and InitializeNetworkPools().

Referenced by NetworkClientJoinGame(), NetworkServerStart(), and NetworkStartUp().

◆ NetworkInitServerClientInfo()

◆ NetworkOnGameStart()

void NetworkOnGameStart ( )

◆ NetworkQueryServer()

void NetworkQueryServer ( std::string_view connection_string)

Query a server to fetch the game-info.

Parameters
connection_stringthe address to query.

Definition at line 689 of file network.cpp.

References _network_available, TCPConnecter::Create(), Debug, NetworkGameListAddItem(), and NetworkGame::refreshing.

Referenced by NetworkAddServer(), and NetworkGameWindow::OnClick().

◆ NetworkReboot()

void NetworkReboot ( )

The server is rebooting... The only difference with NetworkDisconnect, is the packets that is sent.

Definition at line 1012 of file network.cpp.

References _network_dedicated, _network_server, ServerNetworkAdminSocketHandler::IterateActive(), and NetworkClose().

◆ NetworkRebuildHostList()

void NetworkRebuildHostList ( )

Generates the list of manually added hosts from NetworkGame and dumps them into the array _network_host_list.

This array is needed by the function that generates the config file.

Definition at line 753 of file network.cpp.

References _network_game_list, and _network_host_list.

Referenced by NetworkGameListRemoveItem(), and NetworkGameWindow::OnQueryTextFinished().

◆ NetworkReceive()

◆ NetworkSend()

void NetworkSend ( )
static

◆ NetworkServerStart()

◆ NetworkShutDown()

void NetworkShutDown ( )

This shuts the network down.

Definition at line 1341 of file network.cpp.

References _network_available, Debug, NetworkCoreShutdown(), NetworkDisconnect(), NetworkHTTPUninitialize(), and NetworkUDPClose().

Referenced by ShutdownGame().

◆ NetworkSpectatorCount()

uint8_t NetworkSpectatorCount ( )

Get the number of clients that are playing as a spectator.

Returns
The number of spectator clients.

Definition at line 220 of file network.cpp.

References _network_dedicated, and COMPANY_SPECTATOR.

Referenced by ConServerInfo(), and GetCurrentNetworkServerGameInfo().

◆ NetworkStartUp()

void NetworkStartUp ( )

◆ NetworkTextMessage()

void NetworkTextMessage ( NetworkAction action,
TextColour colour,
bool self_send,
std::string_view name,
std::string_view str,
StringParameter && data )

Writes a text-message to the console and the chat box.

Parameters
actionThe network action that lead to this message.
colourThe color for the message.
self_sendWhether the message came from ourselves, or the network.
nameThe name of the client.
strArbitrary extra string, depending on the action. For example a complete message or company name.
dataArbitrary extra data, depending on the action. For example a client's ID or an amount of money that was given.

Definition at line 244 of file network.cpp.

References _current_text_dir, _network_server, _settings_client, CC_DEFAULT, CHAR_TD_LRM, CHAR_TD_RLM, ChatClient, ChatExternal, ChatTeam, ClientJoin, ClientKicked, ClientLeave, ClientNameChange, CompanyJoin, CompanyNew, CompanySpectator, TimerGameEconomy::date, TimerGameEconomy::date_fract, Debug, GetString(), GiveMoney, IConsolePrint(), NetworkAddChatMessage(), BaseStringBuilder::PutUtf8(), ServerMessage, and TD_LTR.

Referenced by ServerNetworkGameSocketHandler::CloseConnection(), CmdGiveMoney(), NetworkClientsToSpectators(), NetworkHandlePauseChange(), NetworkServerChangeClientName(), NetworkServerSendChat(), NetworkServerSendExternalChat(), NetworkUpdateClientName(), ServerNetworkGameSocketHandler::ReceiveClientError(), ServerNetworkGameSocketHandler::ReceiveClientMapOk(), ServerNetworkGameSocketHandler::ReceiveClientQuit(), ServerNetworkGameSocketHandler::ReceiveClientSetName(), ClientNetworkGameSocketHandler::ReceiveServerChat(), ClientNetworkGameSocketHandler::ReceiveServerClientInfo(), ClientNetworkGameSocketHandler::ReceiveServerClientJoined(), ClientNetworkGameSocketHandler::ReceiveServerErrorQuit(), ClientNetworkGameSocketHandler::ReceiveServerExternalChat(), ClientNetworkGameSocketHandler::ReceiveServerQuit(), and ServerNetworkGameSocketHandler::SendError().

◆ NetworkUpdateServerGameType()

void NetworkUpdateServerGameType ( )

The setting server_game_type was updated; possibly we need to take some action.

Definition at line 1063 of file network.cpp.

References _network_coordinator_client, _networking, _settings_client, InviteOnly, Local, and Public.

Referenced by NetworkClientListWindow::OnDropdownSelect().

◆ NetworkValidateServerName()

bool NetworkValidateServerName ( std::string & server_name)

Trim the given server name in place, i.e.

remove leading and trailing spaces. After the trim check whether the server name is not empty. When the server name is empty a GUI error message is shown telling the user to set the servername and this function returns false.

Parameters
server_nameThe server name to validate. It will be trimmed of leading and trailing spaces.
Returns
True iff the server name is valid.

Definition at line 887 of file network.cpp.

References GetEncodedString(), ShowErrorMessage(), StrTrimInPlace(), and WL_ERROR.

Referenced by NetworkStartServerWindow::CheckServerName().

◆ NormalizeConnectionString()

std::string NormalizeConnectionString ( std::string_view connection_string,
uint16_t default_port )

Normalize a connection string.

That is, ensure there is a port in the string.

Parameters
connection_stringThe connection string to normalize.
default_portThe port to use if none is given.
Returns
The normalized connection string.

Definition at line 551 of file network.cpp.

References ParseFullConnectionString().

Referenced by TCPConnecter::TCPConnecter().

◆ ParseCompanyFromConnectionString()

std::string_view ParseCompanyFromConnectionString ( std::string_view connection_string,
CompanyID * company_id )

Parse the company part ("#company" postfix) of a connecting string.

Parameters
connection_stringThe string with the connection data.
company_idThe company ID to set, if available.
Returns
A std::string_view into the connection string without the company part.

Definition at line 487 of file network.cpp.

References COMPANY_NEW_COMPANY, and COMPANY_SPECTATOR.

Referenced by ServerAddress::Parse(), and ParseFullConnectionString().

◆ ParseConnectionString()

NetworkAddress ParseConnectionString ( std::string_view connection_string,
uint16_t default_port )

Convert a string containing either "hostname" or "hostname:ip" to a NetworkAddress.

Parameters
connection_stringThe string to parse.
default_portThe default port to set port to if not in connection_string.
Returns
A valid NetworkAddress of the parsed information.

Definition at line 566 of file network.cpp.

References ParseFullConnectionString().

Referenced by TCPConnecter::Resolve().

◆ ParseFullConnectionString()

std::string_view ParseFullConnectionString ( std::string_view connection_string,
uint16_t & port,
CompanyID * company_id )

Converts a string to ip/port/company Format: IP:port#company.

Returns the IP part as a string view into the passed string. This view is valid as long the passed connection string is valid. If there is no port present in the connection string, the port reference will not be touched. When there is no company ID present in the connection string or company_id is nullptr, then company ID will not be touched.

Parameters
connection_stringThe string with the connection data.
portThe port reference to set.
company_idThe company ID to set, if available.
Returns
A std::string_view into the connection string with the (IP) address part.

Definition at line 531 of file network.cpp.

References ParseCompanyFromConnectionString().

Referenced by NormalizeConnectionString(), openttd_main(), ServerAddress::Parse(), and ParseConnectionString().

◆ ShowNetworkError()

void ShowNetworkError ( StringID error_string)

There was a non-recoverable error, drop back to the main menu with a nice error.

Parameters
error_stringThe error message to show.

Definition at line 316 of file network.cpp.

References _switch_mode, GetEncodedString(), ShowErrorMessage(), SM_MENU, and WL_CRITICAL.

Referenced by ClientNetworkGameSocketHandler::GameLoop(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Listen(), and TCPClientConnecter::OnFailure().

Variable Documentation

◆ _broadcast_list

NetworkAddressList _broadcast_list

List of broadcast addresses.

Definition at line 82 of file network.cpp.

Referenced by NetworkStartUp(), and NetworkUDPBroadCast().

◆ _frame_counter

◆ _frame_counter_max

◆ _frame_counter_server

uint32_t _frame_counter_server

◆ _is_network_server

bool _is_network_server

Does this client wants to be a network-server?

Definition at line 71 of file network.cpp.

Referenced by VideoDriver_Dedicated::MainLoop(), NetworkStartServerWindow::OnClick(), and SelectGameWindow::OnClick().

◆ _last_sync_frame

uint32_t _last_sync_frame

Used in the server to store the last time a sync packet was sent to clients.

Definition at line 81 of file network.cpp.

Referenced by NetworkServer_Tick(), and NetworkServerStart().

◆ _network_available

◆ _network_ban_list

◆ _network_bind_list

StringList _network_bind_list

The addresses to bind on.

Definition at line 75 of file network.cpp.

Referenced by GetBindAddresses(), and AfterNewGRFScan::OnNewGRFsScanned().

◆ _network_clients_connected

uint8_t _network_clients_connected = 0

◆ _network_dedicated

◆ _network_first_time

bool _network_first_time

Whether we have finished joining or not.

Definition at line 88 of file network.cpp.

Referenced by ClientNetworkGameSocketHandler::GameLoop(), NetworkInitialize(), and ClientNetworkGameSocketHandler::ReceiveServerFrame().

◆ _network_host_list

StringList _network_host_list

The servers we know.

Definition at line 76 of file network.cpp.

Referenced by NetworkRebuildHostList(), and ShowNetworkGameWindow().

◆ _network_own_client_id

◆ _network_reconnect

uint8_t _network_reconnect

Reconnect timeout.

Definition at line 74 of file network.cpp.

Referenced by NetworkInitialize(), and ClientNetworkGameSocketHandler::ReceiveServerNewGame().

◆ _network_server

bool _network_server

network-server is active

Definition at line 68 of file network.cpp.

Referenced by AfterLoadGame(), AfterLoadLinkGraphs(), AI::BroadcastNewEvent(), AI::CanStartNew(), ChangeNetworkRestartTime(), NetworkGameSocketHandler::CloseConnection(), CmdCompanyCtrl(), CmdGoalQuestion(), CmdGoalQuestionAnswer(), CompanyAdminRemove(), CompanyAdminUpdate(), CompanyCheckBankrupt(), ConHookClientOnly(), ConHookNeedNetwork(), ConHookServerOnly(), ConHookServerOrNoNetwork(), ConJoinCompany(), ClientNetworkCoordinatorSocketHandler::ConnectSuccess(), ConRcon(), ConReloadAI(), ConRescanAI(), ConRescanGame(), ConSay(), ConSayClient(), ConSayCompany(), ConStartAI(), ConStopAI(), DoStartupNewCompany(), AI::GameLoop(), Game::GameLoop(), GetSettingsDesc(), NetworkClientListWindow::GetWidgetString(), SettingDesc::IsEditable(), AIPLChunkHandler::Load(), GSDTChunkHandler::Load(), LoadSettings(), MenuClickCompany(), ClientNetworkGameSocketHandler::NetworkClose, NetworkDisconnect(), ClientNetworkGameSocketHandler::NetworkExecuteLocalCommandQueue, NetworkGameLoop(), NetworkMaxCompaniesAllowed(), NetworkOnGameStart(), NetworkPrintClients(), NetworkReboot(), NetworkReceive(), NetworkSend(), NetworkSendCommand(), NetworkServerNewCompany(), NetworkServerStart(), NetworkServerUpdateGameInfo(), NetworkTextMessage(), NetworkUpdateClientName(), AI::NewEvent(), Game::NewEvent(), CompanyWindow::OnClick(), NetworkClientListWindow::OnClick(), NetworkClientListWindow::OnClickCompanyAdmin(), NetworkClientListWindow::OnClickCompanyJoin(), NetworkClientListWindow::OnDropdownSelect(), MainWindow::OnHotkey(), NetworkClientListWindow::OnInvalidateData(), BuildVehicleWindow::OnPaint(), NetworkClientListWindow::OnQueryTextFinished(), OnTick_LinkGraph(), NetworkClientListWindow::RebuildList(), NetworkClientListWindow::RebuildListCompany(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorTurnConnect(), OrderBackup::Reset(), ResetSettings(), OrderBackup::ResetUser(), SafeLoad(), SanitizeSingleStringHelper(), AI::Save(), BKORChunkHandler::Save(), Game::Save(), SendChat(), ClientNetworkCoordinatorSocketHandler::SendReceive(), SetSettingValue(), ShowScriptDebugWindow(), ShowScriptDebugWindowIfScriptError(), AI::StartNew(), Game::StartNew(), StateGameLoop(), AI::Stop(), SurveyConfiguration(), ToolbarOptionsClick(), UpdateClientConfigValues(), and NetworkClientListWindow::UpdateWidgetSize().

◆ _networkclientinfo_pool

NetworkClientInfoPool _networkclientinfo_pool {"NetworkClientInfo"}

Make sure both pools have the same size.

The pool with client information.

Definition at line 64 of file network.cpp.

Referenced by NetworkClientInfo::NetworkClientInfo().

◆ _networking

bool _networking

are we in networking mode?

Definition at line 67 of file network.cpp.

Referenced by AfterLoadGame(), AfterLoadLinkGraphs(), AI::BroadcastNewEvent(), AI::CanStartNew(), ChangeOwnershipOfCompanyItems(), CheckTrainsLengths(), ClientNetworkGameSocketHandler::ClientError(), EndGameWindow::Close(), HighScoreWindow::Close(), SaveLoadWindow::Close(), NetworkGameSocketHandler::CloseConnection(), CmdBuyCompany(), CmdCompanyCtrl(), CmdGiveMoney(), CmdGoalQuestionAnswer(), CmdPause(), CompanyCheckBankrupt(), ConHookNeedNetwork(), ConHookNoNetwork(), ConHookServerOrNoNetwork(), ConPauseGame(), ConReloadAI(), ConRescanAI(), ConRescanGame(), ConStartAI(), ConStopAI(), ConUnpauseGame(), DoStartupNewCompany(), AI::GameLoop(), Game::GameLoop(), GetSettingsDesc(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), CommandHelperBase::InternalPostBefore(), SettingDesc::IsEditable(), AIPLChunkHandler::Load(), GSDTChunkHandler::Load(), LoadNewGRF(), LoadSettings(), MenuClickCompany(), MenuClickSettings(), ClientNetworkGameSocketHandler::NetworkClose, NetworkGameLoop(), NetworkHandlePauseChange(), NetworkServerStart(), NetworkUpdateServerGameType(), AI::NewEvent(), Game::NewEvent(), TCPClientConnecter::OnConnect(), MainToolbarWindow::OnHotkey(), MainWindow::OnHotkey(), BuildVehicleWindow::OnPaint(), CompanyWindow::OnPaint(), OnTick_Companies(), OnTick_LinkGraph(), OrdersWindow::OrderClick_Delete(), ParamSet(), ClientNetworkGameSocketHandler::Receive(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Receive(), RedrawScreenRect(), ReInitAllWindows(), OrderBackup::Reset(), ResetSettings(), AI::Save(), BKORChunkHandler::Save(), Game::Save(), SetSettingValue(), ShowEndGameChart(), ShowNewGrfVehicleError(), ShowScriptDebugWindow(), ShowScriptDebugWindowIfScriptError(), AI::StartNew(), Game::StartNew(), StateGameLoop(), AI::Stop(), SurveyConfiguration(), VideoDriver::Tick(), ToolbarFastForwardClick(), and ToolbarOptionsClick().

◆ _redirect_console_to_client

ClientID _redirect_console_to_client

◆ _sync_frame

◆ _sync_seed_1