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. |
Variables and function used internally.
Definition in file network_internal.h.
#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().
enum NetworkJoinStatus |
Status of the clients during joining.
Definition at line 56 of file network_internal.h.
enum NetworkLanguage |
Language ids for server_lang and client_lang.
Do NOT modify the order.
Definition at line 69 of file network_internal.h.
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.
password | Password to hash. | |
password_server_id | Server ID. | |
password_game_seed | Game seed. |
Definition at line 182 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.
addresses | the list to write to. | |
port | the port to bind to. |
Definition at line 615 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.
err | NetworkErrorCode |
Definition at line 299 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.
other | the version string to compare to |
Definition at line 1076 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 275 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.
new_name | The name to check/modify. |
Definition at line 1677 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.
cs | The client to sync the queue to. |
Definition at line 179 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.
unselect | unselect the currently selected item |
Definition at line 73 of file network_gui.cpp.
References InvalidateWindowData().
Referenced by NetworkGameListAddItem(), NetworkGameListHandleDelayedInsert(), NetworkGameListRemoveItem(), and ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE().