Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

network_internal.h File Reference

Variables and function used internally. More...

#include "network_func.h"
#include "core/tcp_game.h"
#include "../command_type.h"

Go to the source code of this file.

Data Structures

struct  CommandPacket
 Everything we need to know about a command to be able to execute it. More...

Defines

#define _ddc_fastforward   (false)
 Helper variable to make the dedicated server go fast until the (first) join.

Typedefs

typedef class
ServerNetworkGameSocketHandler 
NetworkClientSocket

Enumerations

enum  NetworkJoinStatus {
  NETWORK_JOIN_STATUS_CONNECTING, NETWORK_JOIN_STATUS_AUTHORIZING, NETWORK_JOIN_STATUS_WAITING, NETWORK_JOIN_STATUS_DOWNLOADING,
  NETWORK_JOIN_STATUS_PROCESSING, NETWORK_JOIN_STATUS_REGISTERING, NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO, NETWORK_JOIN_STATUS_END
}
 

Status of the clients during joining.

More...
enum  NetworkLanguage {
  NETLANG_ANY = 0, NETLANG_ENGLISH, NETLANG_GERMAN, NETLANG_FRENCH,
  NETLANG_BRAZILIAN, NETLANG_BULGARIAN, NETLANG_CHINESE, NETLANG_CZECH,
  NETLANG_DANISH, NETLANG_DUTCH, NETLANG_ESPERANTO, NETLANG_FINNISH,
  NETLANG_HUNGARIAN, NETLANG_ICELANDIC, NETLANG_ITALIAN, NETLANG_JAPANESE,
  NETLANG_KOREAN, NETLANG_LITHUANIAN, NETLANG_NORWEGIAN, NETLANG_POLISH,
  NETLANG_PORTUGUESE, NETLANG_ROMANIAN, NETLANG_RUSSIAN, NETLANG_SLOVAK,
  NETLANG_SLOVENIAN, NETLANG_SPANISH, NETLANG_SWEDISH, NETLANG_TURKISH,
  NETLANG_UKRAINIAN, NETLANG_AFRIKAANS, NETLANG_CROATIAN, NETLANG_CATALAN,
  NETLANG_ESTONIAN, NETLANG_GALICIAN, NETLANG_GREEK, NETLANG_LATVIAN,
  NETLANG_COUNT
}
 

Language ids for server_lang and client_lang.

More...

Functions

void NetworkTCPQueryServer (NetworkAddress address)
void GetBindAddresses (NetworkAddressList *addresses, uint16 port)
 Get the addresses to bind to.
void NetworkAddServer (const char *b)
void NetworkRebuildHostList ()
void UpdateNetworkGameWindow (bool unselect)
 Update the network new window because a new server is found on the network.
bool IsNetworkCompatibleVersion (const char *version)
 Checks whether the given version string is compatible with our version.
void NetworkDistributeCommands ()
 Distribute the commands of ourself and the clients.
void NetworkExecuteLocalCommandQueue ()
 Execute all commands on the local command queue that ought to be executed this frame.
void NetworkFreeLocalCommandQueue ()
 Free the local command queues.
void NetworkSyncCommandQueue (NetworkClientSocket *cs)
 Sync our local command queue to the command queue of the given socket.
void NetworkError (StringID error_string)
void NetworkTextMessage (NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str="", int64 data=0)
uint NetworkCalculateLag (const NetworkClientSocket *cs)
StringID GetNetworkErrorMsg (NetworkErrorCode err)
 Retrieve the string id of an internal error number.
bool NetworkFindName (char new_name[NETWORK_CLIENT_NAME_LENGTH])
 Check whether a name is unique, and otherwise try to make it unique.
const char * GenerateCompanyPasswordHash (const char *password, const char *password_server_id, uint32 password_game_seed)
 Hash the given password using server ID and game seed.

Variables

uint32 _frame_counter_server
 The frame_counter of the server, if in network-mode.
uint32 _frame_counter_max
 To where we may go with our clients.
uint32 _frame_counter
 The current frame.
uint32 _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 _sync_seed_1
 Seed to compare during sync checks.
uint32 _sync_frame
 The frame to perform the sync check.
bool _network_first_time
 Whether we have finished joining or not.
NetworkJoinStatus _network_join_status
 The status of joining.
uint8 _network_join_waiting
 The number of clients waiting in front of us.
uint32 _network_join_bytes
 The number of bytes we already downloaded.
uint32 _network_join_bytes_total
 The total number of bytes to download.
uint8 _network_reconnect
 Reconnect timeout.
bool _network_udp_server
 Is the UDP server started?
uint16 _network_udp_broadcast
 Timeout for the UDP broadcasts.
uint8 _network_advertise_retries
 The number of advertisement retries we did.
CompanyMask _network_company_passworded
 Bitmask of the password status of all companies.

Detailed Description

Variables and function used internally.

Definition in file network_internal.h.


Define Documentation

#define _ddc_fastforward   (false)

Helper variable to make the dedicated server go fast until the (first) join.

Used to load the desync debug logs, i.e. for reproducing a desync. There's basically no need to ever enable this, unless you really know what you are doing, i.e. debugging a desync.

Definition at line 50 of file network_internal.h.

Referenced by VideoDriver_Dedicated::MainLoop().


Enumeration Type Documentation

Status of the clients during joining.

Definition at line 56 of file network_internal.h.

Language ids for server_lang and client_lang.

Do NOT modify the order.

Definition at line 69 of file network_internal.h.


Function Documentation

const char* GenerateCompanyPasswordHash ( const char *  password,
const char *  password_server_id,
uint32  password_game_seed 
)

Hash the given password using server ID and game seed.

Parameters:
password Password to hash.
password_server_id Server ID.
password_game_seed Game seed.
Returns:
The hashed password.

Definition at line 181 of file network.cpp.

References lengthof, NETWORK_SERVER_ID_LENGTH, and StrEmpty().

Referenced by NetworkServerSetCompanyPassword(), ClientNetworkGameSocketHandler::SendCompanyPassword(), ClientNetworkGameSocketHandler::SendMove(), and ClientNetworkGameSocketHandler::SendSetPassword().

void GetBindAddresses ( NetworkAddressList addresses,
uint16  port 
)

Get the addresses to bind to.

Parameters:
addresses the list to write to.
port the port to bind to.

Definition at line 618 of file network.cpp.

References SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), SmallVector< T, S >::End(), and SmallVector< T, S >::Length().

Referenced by TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::Listen(), and NetworkUDPInitialize().

StringID GetNetworkErrorMsg ( NetworkErrorCode  err  ) 

Retrieve the string id of an internal error number.

Parameters:
err NetworkErrorCode
Returns:
the StringID

Definition at line 298 of file network.cpp.

References lengthof.

Referenced by ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(), ServerNetworkGameSocketHandler::SendError(), and ServerNetworkAdminSocketHandler::SendError().

bool IsNetworkCompatibleVersion ( const char *  other  ) 

Checks whether the given version string is compatible with our version.

Parameters:
other the version string to compare to

Definition at line 1077 of file network.cpp.

References NETWORK_REVISION_LENGTH.

Referenced by ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE().

void NetworkDistributeCommands (  ) 

Distribute the commands of ourself and the clients.

Definition at line 276 of file network_command.cpp.

References DistributeQueue(), and FOR_ALL_CLIENT_SOCKETS.

bool NetworkFindName ( char  new_name[NETWORK_CLIENT_NAME_LENGTH]  ) 

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 1676 of file network_server.cpp.

References CLIENT_ID_SERVER, NetworkClientInfo::client_name, FOR_ALL_CLIENT_INFOS, NetworkClientInfo::GetByClientID(), MAX_CLIENTS, and ttd_strlcpy().

Referenced by NetworkUpdateClientName().

void NetworkSyncCommandQueue ( NetworkClientSocket cs  ) 

Sync our local command queue to the command queue of the given socket.

This is needed for the case where we receive a command before saving the game for a joining client, but without the execution of those commands. Not syncing those commands means that the client will never get them and as such will be in a desynced state from the time it started with joining.

Parameters:
cs The client to sync the queue to.

Definition at line 180 of file network_command.cpp.

References CommandContainer::callback, CommandPacket::next, and CommandQueue::Peek().

Referenced by ServerNetworkGameSocketHandler::SendMap().

void UpdateNetworkGameWindow ( bool  unselect  ) 

Update the network new window because a new server is found on the network.

Parameters:
unselect unselect the currently selected item

Definition at line 74 of file network_gui.cpp.

References InvalidateWindowData(), WC_NETWORK_WINDOW, and WN_NETWORK_WINDOW_GAME.

Referenced by NetworkGameListAddItem(), NetworkGameListHandleDelayedInsert(), NetworkGameListRemoveItem(), and ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE().