OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #ifndef NETWORK_INTERNAL_H
11 #define NETWORK_INTERNAL_H
17 #include "../command_type.h"
18 #include "../command_func.h"
19 #include "../misc/endian_buffer.hpp"
31 #define ENABLE_NETWORK_SYNC_EVERY_FRAME
37 #define NETWORK_SEND_DOUBLE_SEED
44 NETWORK_JOIN_STATUS_CONNECTING,
45 NETWORK_JOIN_STATUS_AUTHORIZING,
46 NETWORK_JOIN_STATUS_WAITING,
47 NETWORK_JOIN_STATUS_DOWNLOADING,
48 NETWORK_JOIN_STATUS_PROCESSING,
49 NETWORK_JOIN_STATUS_REGISTERING,
51 NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
52 NETWORK_JOIN_STATUS_END,
65 #ifdef NETWORK_SEND_DOUBLE_SEED
66 extern uint32_t _sync_seed_2;
87 void NetworkRebuildHostList();
112 void ShowNetworkError(
StringID error_string);
113 void NetworkTextMessage(
NetworkAction action,
TextColour colour,
bool self_send,
const std::string &name,
const std::string &str =
"", int64_t data = 0,
const std::string &data_str =
"");
114 uint NetworkCalculateLag(
const NetworkClientSocket *cs);
uint32_t _frame_counter_max
To where we may go with our clients.
std::string connection_string
Address of the server.
uint32_t _sync_seed_1
Seed to compare during sync checks.
NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port)
Convert a string containing either "hostname" or "hostname:ip" to a NetworkAddress.
uint32_t frame
the frame in which this packet is executed
void NetworkQueryServer(const std::string &connection_string)
Query a server to fetch the game-info.
@ INVALID_COMPANY
An invalid company.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
NetworkAction
Actions that can be used for NetworkTextMessage.
Owner
Enum for all companies/owners.
NetworkJoinStatus
Status of the clients during joining.
uint8_t _network_join_waiting
The number of clients waiting in front of us.
std::string _network_server_invite_code
Our invite code as indicated by the Game Coordinator.
StringID err_msg
string ID of error message to use.
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.
void ClientNetworkEmergencySave()
Create an emergency savegame when the network connection is lost.
bool _network_first_time
Whether we have finished joining or not.
void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile)
Define a callback function for the client, after the command is finished.
uint32_t _network_join_bytes
The number of bytes we already downloaded.
static void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id)
Insert a client ID into the command data in a command packet.
uint32_t _frame_counter_server
The frame_counter of the server, if in network-mode.
CompanyID company
company that is executing the command
uint32_t _network_join_bytes_total
The total number of bytes to download.
Everything we need to know about a command to be able to execute it.
void GetBindAddresses(NetworkAddressList *addresses, uint16_t port)
Get the addresses to bind to.
uint8_t _network_reconnect
Reconnect timeout.
std::vector< NetworkAddress > NetworkAddressList
Type for a list of addresses.
std::string NormalizeConnectionString(const std::string &connection_string, uint16_t default_port)
Normalize a connection string.
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.
bool manually
True if the server was added manually.
std::vector< uint8_t > CommandDataBuffer
Storage buffer for serialized command data.
std::string _network_server_name
The current name of the server you are on.
bool my_cmd
did the command originate from "me"
ConnectionType
The type of connection the Game Coordinator can detect we have.
uint32_t _sync_frame
The frame to perform the sync check.
Class for handling the server side of the game connection.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
ClientID
'Unique' identifier to be given to clients
uint32_t _frame_counter
The current frame.
CommandDataBuffer data
command parameters.
uint32_t _last_sync_frame
Used in the server to store the last time a sync packet was sent to clients.
void NetworkSyncCommandQueue(NetworkClientSocket *cs)
Sync our local command queue to the command queue of the given socket.
Structure with information shown in the game list (GUI)
NetworkJoinStatus _network_join_status
The status of joining.
ConnectionType _network_server_connection_type
What type of connection the Game Coordinator detected we are on.
void NetworkExecuteLocalCommandQueue()
Execute all commands on the local command queue that ought to be executed this frame.
Commands
List of commands.
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.
CommandCallback * callback
any callback function executed upon successful completion of the command.
void NetworkFreeLocalCommandQueue()
Free the local command queues.
NetworkErrorCode
The error codes we send around in the protocols.
Commands cmd
command being executed.