Changeset - r25169:d36f2d41209f
[Not reviewed]
master
0 4 0
Rubidium - 3 years ago 2021-04-11 09:22:50
rubidium@openttd.org
Change: move some things only relevant to UDP from network.cpp to network_udp.cpp
4 files changed with 13 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/network/network.cpp
Show inline comments
 
@@ -74,19 +74,12 @@ uint32 _sync_seed_2;                  //
 
#endif
 
uint32 _sync_frame;                   ///< The frame to perform the sync check.
 
bool _network_first_time;             ///< Whether we have finished joining or not.
 
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.
 

	
 
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
 
static_assert((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);
 
static_assert((int)NETWORK_COMPANY_NAME_LENGTH == MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH);
 

	
 
extern NetworkUDPSocketHandler *_udp_client_socket; ///< udp client socket
 
extern NetworkUDPSocketHandler *_udp_server_socket; ///< udp server socket
 
extern NetworkUDPSocketHandler *_udp_master_socket; ///< udp master socket
 

	
 
/** The amount of clients connected */
 
byte _network_clients_connected = 0;
 

	
 
@@ -724,7 +717,7 @@ bool NetworkServerStart()
 

	
 
	/* Try to start UDP-server */
 
	DEBUG(net, 1, "starting listeners for incoming server queries");
 
	_network_udp_server = _udp_server_socket->Listen();
 
	NetworkUDPServerListen();
 

	
 
	_network_company_states = CallocT<NetworkCompanyState>(MAX_COMPANIES);
 
	_network_server = true;
 
@@ -1060,7 +1053,6 @@ void NetworkStartUp()
 
	_network_available = NetworkCoreInitialize();
 
	_network_dedicated = false;
 
	_network_need_advertise = true;
 
	_network_advertise_retries = 0;
 

	
 
	/* Generate an server id when there is none yet */
 
	if (StrEmpty(_settings_client.network.network_id)) NetworkGenerateServerId();
src/network/network_internal.h
Show inline comments
 
@@ -126,11 +126,6 @@ extern uint32 _network_join_bytes_total;
 

	
 
extern uint8 _network_reconnect;
 

	
 
extern bool _network_udp_server;
 
extern uint16 _network_udp_broadcast;
 

	
 
extern uint8 _network_advertise_retries;
 

	
 
extern CompanyMask _network_company_passworded;
 

	
 
void NetworkTCPQueryServer(NetworkAddress address);
src/network/network_udp.cpp
Show inline comments
 
@@ -47,6 +47,10 @@ NetworkUDPSocketHandler *_udp_client_soc
 
NetworkUDPSocketHandler *_udp_server_socket = nullptr; ///< udp server socket
 
NetworkUDPSocketHandler *_udp_master_socket = nullptr; ///< udp master socket
 

	
 
static bool _network_udp_server;         ///< Is the UDP server started?
 
static uint16 _network_udp_broadcast;    ///< Timeout for the UDP broadcasts.
 
static uint8 _network_advertise_retries; ///< The number of advertisement retries we did.
 

	
 
/**
 
 * Helper function doing the actual work for querying the server.
 
 * @param address The address of the server.
 
@@ -622,6 +626,13 @@ void NetworkUDPInitialize()
 

	
 
	_network_udp_server = false;
 
	_network_udp_broadcast = 0;
 
	_network_advertise_retries = 0;
 
}
 

	
 
/** Start the listening of the UDP server component. */
 
void NetworkUDPServerListen()
 
{
 
	_network_udp_server = _udp_server_socket->Listen();
 
}
 

	
 
/** Close all UDP related stuff. */
src/network/network_udp.h
Show inline comments
 
@@ -19,6 +19,7 @@ void NetworkUDPQueryServer(NetworkAddres
 
void NetworkUDPAdvertise();
 
void NetworkUDPRemoveAdvertise(bool blocking);
 
void NetworkUDPClose();
 
void NetworkUDPServerListen();
 
void NetworkBackgroundUDPLoop();
 

	
 
#endif /* NETWORK_UDP_H */
0 comments (0 inline, 0 general)