OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef NETWORK_INTERNAL_H
11 #define NETWORK_INTERNAL_H
17 #include "../command_type.h"
29 #define ENABLE_NETWORK_SYNC_EVERY_FRAME
35 #define NETWORK_SEND_DOUBLE_SEED
45 #ifdef DEBUG_DUMP_COMMANDS
48 #define _ddc_fastforward (false)
55 NETWORK_JOIN_STATUS_CONNECTING,
56 NETWORK_JOIN_STATUS_AUTHORIZING,
57 NETWORK_JOIN_STATUS_WAITING,
58 NETWORK_JOIN_STATUS_DOWNLOADING,
59 NETWORK_JOIN_STATUS_PROCESSING,
60 NETWORK_JOIN_STATUS_REGISTERING,
62 NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
63 NETWORK_JOIN_STATUS_END,
76 #ifdef NETWORK_SEND_DOUBLE_SEED
77 extern uint32 _sync_seed_2;
100 void NetworkRebuildHostList();
121 void ShowNetworkError(
StringID error_string);
122 void NetworkTextMessage(
NetworkAction action,
TextColour colour,
bool self_send,
const std::string &name,
const std::string &str =
"", int64 data = 0);
123 uint NetworkCalculateLag(
const NetworkClientSocket *cs);
126 std::string
GenerateCompanyPasswordHash(
const std::string &password,
const std::string &password_server_id, uint32 password_game_seed);
std::string connection_string
Address of the server.
uint8 _network_join_waiting
The number of clients waiting in front of us.
void NetworkQueryServer(const std::string &connection_string)
Query a server to fetch the game-info.
uint8 _network_reconnect
Reconnect timeout.
std::string NormalizeConnectionString(const std::string &connection_string, uint16 default_port)
Normalize a connection string.
NetworkAction
Actions that can be used for NetworkTextMessage.
uint32 frame
the frame in which this packet is executed
NetworkJoinStatus
Status of the clients during joining.
uint32 _network_join_bytes
The number of bytes we already downloaded.
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void NetworkDistributeCommands()
Distribute the commands of ourself and the clients.
std::string_view ParseCompanyFromConnectionString(const std::string &connection_string, CompanyID *company_id)
Parse the company part ("#company" postfix) of a connecting string.
Structure for buffering the build command when selecting a station to join.
bool _network_first_time
Whether we have finished joining or not.
CommandPacket * next
the next command packet (if in queue)
Owner
Enum for all companies/owners.
CompanyID company
company that is executing the command
Everything we need to know about a command to be able to execute it.
std::vector< NetworkAddress > NetworkAddressList
Type for a list of addresses.
struct NetworkGameList * NetworkAddServer(const std::string &connection_string, bool manually=true, bool never_expire=false)
Validates an address entered as a string and adds the server to the list.
std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed)
Hash the given password using server ID and game seed.
bool manually
True if the server was added manually.
std::string _network_server_name
The current name of the server you are on.
CompanyMask _network_company_passworded
Bitmask of the password status of all companies.
bool my_cmd
did the command originate from "me"
void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
Get the addresses to bind to.
ConnectionType
The type of connection the Game Coordinator can detect we have.
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16 default_port)
Convert a string containing either "hostname" or "hostname:ip" to a NetworkAddress.
Class for handling the server side of the game connection.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
#define _ddc_fastforward
Helper variable to make the dedicated server go fast until the (first) join.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
uint32 _last_sync_frame
Used in the server to store the last time a sync packet was sent to clients.
CommandPacket()
Make sure the pointer is nullptr.
void NetworkSyncCommandQueue(NetworkClientSocket *cs)
Sync our local command queue to the command queue of the given socket.
uint32 _sync_seed_1
Seed to compare during sync checks.
uint32 _sync_frame
The frame to perform the sync check.
Structure with information shown in the game list (GUI)
NetworkJoinStatus _network_join_status
The status of joining.
uint32 _frame_counter
The current frame.
ConnectionType _network_server_connection_type
What type of connection the Game Coordinator detected we are on.
@ INVALID_COMPANY
An invalid company.
void NetworkExecuteLocalCommandQueue()
Execute all commands on the local command queue that ought to be executed this frame.
StringID GetNetworkErrorMsg(NetworkErrorCode err)
Retrieve the string id of an internal error number.
NetworkAddressList _broadcast_list
List of broadcast addresses.
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
bool NetworkMakeClientNameUnique(std::string &new_name)
Check whether a name is unique, and otherwise try to make it unique.
uint32 _frame_counter_server
The frame_counter of the server, if in network-mode.
void NetworkFreeLocalCommandQueue()
Free the local command queues.
uint32 _network_join_bytes_total
The total number of bytes to download.
uint32 _frame_counter_max
To where we may go with our clients.
NetworkErrorCode
The error codes we send around in the protocols.