mirror of https://github.com/OpenTTD/OpenTTD
(svn r23751) -Codechange: rename NetworkUDPGameLoop to a more descriptive name, and move the UDP specific bits to network_udp
parent
b80fb93b1b
commit
531e501b5a
|
@ -827,20 +827,18 @@ static void NetworkSend()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have to do some UDP checking */
|
/**
|
||||||
void NetworkUDPGameLoop()
|
* We have to do some (simple) background stuff that runs normally,
|
||||||
|
* even when we are not in multiplayer. For example stuff needed
|
||||||
|
* for finding servers or downloading content.
|
||||||
|
*/
|
||||||
|
void NetworkBackgroundLoop()
|
||||||
{
|
{
|
||||||
_network_content_client.SendReceive();
|
_network_content_client.SendReceive();
|
||||||
TCPConnecter::CheckCallbacks();
|
TCPConnecter::CheckCallbacks();
|
||||||
NetworkHTTPSocketHandler::HTTPReceive();
|
NetworkHTTPSocketHandler::HTTPReceive();
|
||||||
|
|
||||||
if (_network_udp_server) {
|
NetworkBackgroundUDPLoop();
|
||||||
_udp_server_socket->ReceivePackets();
|
|
||||||
_udp_master_socket->ReceivePackets();
|
|
||||||
} else {
|
|
||||||
_udp_client_socket->ReceivePackets();
|
|
||||||
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The main loop called from ttd.c
|
/* The main loop called from ttd.c
|
||||||
|
|
|
@ -40,7 +40,7 @@ const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *passw
|
||||||
void NetworkReboot();
|
void NetworkReboot();
|
||||||
void NetworkDisconnect(bool blocking = false, bool close_admins = true);
|
void NetworkDisconnect(bool blocking = false, bool close_admins = true);
|
||||||
void NetworkGameLoop();
|
void NetworkGameLoop();
|
||||||
void NetworkUDPGameLoop();
|
void NetworkBackgroundLoop();
|
||||||
void ParseConnectionString(const char **company, const char **port, char *connection_string);
|
void ParseConnectionString(const char **company, const char **port, char *connection_string);
|
||||||
void NetworkStartDebugLog(NetworkAddress address);
|
void NetworkStartDebugLog(NetworkAddress address);
|
||||||
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
|
void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
|
||||||
|
|
|
@ -675,4 +675,16 @@ void NetworkUDPClose()
|
||||||
DEBUG(net, 1, "[udp] closed listeners");
|
DEBUG(net, 1, "[udp] closed listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Receive the UDP packets. */
|
||||||
|
void NetworkBackgroundUDPLoop()
|
||||||
|
{
|
||||||
|
if (_network_udp_server) {
|
||||||
|
_udp_server_socket->ReceivePackets();
|
||||||
|
_udp_master_socket->ReceivePackets();
|
||||||
|
} else {
|
||||||
|
_udp_client_socket->ReceivePackets();
|
||||||
|
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -23,6 +23,7 @@ void NetworkUDPQueryServer(NetworkAddress address, bool manually = false);
|
||||||
void NetworkUDPAdvertise();
|
void NetworkUDPAdvertise();
|
||||||
void NetworkUDPRemoveAdvertise(bool blocking);
|
void NetworkUDPRemoveAdvertise(bool blocking);
|
||||||
void NetworkUDPClose();
|
void NetworkUDPClose();
|
||||||
|
void NetworkBackgroundUDPLoop();
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ void GameLoop()
|
||||||
if (_game_mode == GM_BOOTSTRAP) {
|
if (_game_mode == GM_BOOTSTRAP) {
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
/* Check for UDP stuff */
|
/* Check for UDP stuff */
|
||||||
if (_network_available) NetworkUDPGameLoop();
|
if (_network_available) NetworkBackgroundLoop();
|
||||||
#endif
|
#endif
|
||||||
InputLoop();
|
InputLoop();
|
||||||
return;
|
return;
|
||||||
|
@ -1378,7 +1378,7 @@ void GameLoop()
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
/* Check for UDP stuff */
|
/* Check for UDP stuff */
|
||||||
if (_network_available) NetworkUDPGameLoop();
|
if (_network_available) NetworkBackgroundLoop();
|
||||||
|
|
||||||
if (_networking && !HasModalProgress()) {
|
if (_networking && !HasModalProgress()) {
|
||||||
/* Multiplayer */
|
/* Multiplayer */
|
||||||
|
|
Loading…
Reference in New Issue