Mercurial > hg > openttd
changeset 18902:74d56f453ead draft
(svn r23751) -Codechange: rename NetworkUDPGameLoop to a more descriptive name, and move the UDP specific bits to network_udp
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 04 Jan 2012 22:08:43 +0000 |
parents | 0551c0afdaad |
children | 883947621bf9 |
files | src/network/network.cpp src/network/network_func.h src/network/network_udp.cpp src/network/network_udp.h src/openttd.cpp |
diffstat | 5 files changed, 23 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -827,20 +827,18 @@ } } -/* 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(); TCPConnecter::CheckCallbacks(); NetworkHTTPSocketHandler::HTTPReceive(); - 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--; - } + NetworkBackgroundUDPLoop(); } /* The main loop called from ttd.c
--- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -40,7 +40,7 @@ void NetworkReboot(); void NetworkDisconnect(bool blocking = false, bool close_admins = true); void NetworkGameLoop(); -void NetworkUDPGameLoop(); +void NetworkBackgroundLoop(); void ParseConnectionString(const char **company, const char **port, char *connection_string); void NetworkStartDebugLog(NetworkAddress address); void NetworkPopulateCompanyStats(NetworkCompanyStats *stats);
--- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -675,4 +675,16 @@ 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 */
--- a/src/network/network_udp.h +++ b/src/network/network_udp.h @@ -23,6 +23,7 @@ void NetworkUDPAdvertise(); void NetworkUDPRemoveAdvertise(bool blocking); void NetworkUDPClose(); +void NetworkBackgroundUDPLoop(); #endif /* ENABLE_NETWORK */
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1348,7 +1348,7 @@ if (_game_mode == GM_BOOTSTRAP) { #ifdef ENABLE_NETWORK /* Check for UDP stuff */ - if (_network_available) NetworkUDPGameLoop(); + if (_network_available) NetworkBackgroundLoop(); #endif InputLoop(); return; @@ -1378,7 +1378,7 @@ #ifdef ENABLE_NETWORK /* Check for UDP stuff */ - if (_network_available) NetworkUDPGameLoop(); + if (_network_available) NetworkBackgroundLoop(); if (_networking && !HasModalProgress()) { /* Multiplayer */