summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-04 22:08:43 +0000
committerrubidium <rubidium@openttd.org>2012-01-04 22:08:43 +0000
commit531e501b5a9b255c9694b62228baa8c962bf4c60 (patch)
treeaaf78f62ca555cb07f0c0417a9f6c9bb492bc784 /src
parentb80fb93b1b5ff5cbe495ddd3d1c7d95fe12d4ef2 (diff)
downloadopenttd-531e501b5a9b255c9694b62228baa8c962bf4c60.tar.xz
(svn r23751) -Codechange: rename NetworkUDPGameLoop to a more descriptive name, and move the UDP specific bits to network_udp
Diffstat (limited to 'src')
-rw-r--r--src/network/network.cpp16
-rw-r--r--src/network/network_func.h2
-rw-r--r--src/network/network_udp.cpp12
-rw-r--r--src/network/network_udp.h1
-rw-r--r--src/openttd.cpp4
5 files changed, 23 insertions, 12 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 0035c5105..14453d70f 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -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();
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
diff --git a/src/network/network_func.h b/src/network/network_func.h
index 015c7dba1..7ce8414f9 100644
--- a/src/network/network_func.h
+++ b/src/network/network_func.h
@@ -40,7 +40,7 @@ const char *NetworkChangeCompanyPassword(CompanyID company_id, const char *passw
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);
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 974b0bf6b..58d0f31c5 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -675,4 +675,16 @@ void NetworkUDPClose()
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 */
diff --git a/src/network/network_udp.h b/src/network/network_udp.h
index bd315baba..3dfd07672 100644
--- a/src/network/network_udp.h
+++ b/src/network/network_udp.h
@@ -23,6 +23,7 @@ void NetworkUDPQueryServer(NetworkAddress address, bool manually = false);
void NetworkUDPAdvertise();
void NetworkUDPRemoveAdvertise(bool blocking);
void NetworkUDPClose();
+void NetworkBackgroundUDPLoop();
#endif /* ENABLE_NETWORK */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index f9c74cd1c..e892ebd5d 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1348,7 +1348,7 @@ void GameLoop()
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 @@ void GameLoop()
#ifdef ENABLE_NETWORK
/* Check for UDP stuff */
- if (_network_available) NetworkUDPGameLoop();
+ if (_network_available) NetworkBackgroundLoop();
if (_networking && !HasModalProgress()) {
/* Multiplayer */