summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-27 10:54:16 +0100
committerPatric Stout <github@truebrain.nl>2021-02-28 12:27:04 +0100
commit13889b6554e029554556af6524c9ec5542c593e2 (patch)
tree5e755da5804ab6228c7a69a5f43a7bfbceb4db8b /src/network
parent8d199b1bbc2f7f0db98b47b709b75ff97b23e730 (diff)
downloadopenttd-13889b6554e029554556af6524c9ec5542c593e2.tar.xz
Fix: [Network] don't show "server doesn't respond" while in queue
Send all clients in the queue every game-day a packet that they are still in the queue.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_server.cpp20
-rw-r--r--src/network/network_server.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index bef5a5350..9e4d0d88f 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1873,6 +1873,21 @@ void NetworkServer_Tick(bool send_frame)
}
break;
+ case NetworkClientSocket::STATUS_MAP_WAIT:
+ /* Send every two seconds a packet to the client, to make sure
+ * he knows the server is still there; just someone else is
+ * still receiving the map. */
+ if (std::chrono::steady_clock::now() > cs->last_packet + std::chrono::seconds(2)) {
+ cs->SendWait();
+ /* We need to reset the timer, as otherwise we will be
+ * spamming the client. Strictly speaking this variable
+ * tracks when we last received a packet from the client,
+ * but as he is waiting, he will not send us any till we
+ * start sending him data. */
+ cs->last_packet = std::chrono::steady_clock::now();
+ }
+ break;
+
case NetworkClientSocket::STATUS_MAP:
/* Downloading the map... this is the amount of time since starting the saving. */
if (lag > _settings_client.network.max_download_time) {
@@ -1902,11 +1917,6 @@ void NetworkServer_Tick(bool send_frame)
}
break;
- case NetworkClientSocket::STATUS_MAP_WAIT:
- /* This is an internal state where we do not wait
- * on the client to move to a different state. */
- break;
-
case NetworkClientSocket::STATUS_END:
/* Bad server/code. */
NOT_REACHED();
diff --git a/src/network/network_server.h b/src/network/network_server.h
index 4e099a7fa..77612fdc8 100644
--- a/src/network/network_server.h
+++ b/src/network/network_server.h
@@ -43,7 +43,6 @@ protected:
NetworkRecvStatus SendCompanyInfo();
NetworkRecvStatus SendNewGRFCheck();
NetworkRecvStatus SendWelcome();
- NetworkRecvStatus SendWait();
NetworkRecvStatus SendNeedGamePassword();
NetworkRecvStatus SendNeedCompanyPassword();
@@ -82,6 +81,7 @@ public:
void CheckNextClientToSendMap(NetworkClientSocket *ignore_cs = nullptr);
+ NetworkRecvStatus SendWait();
NetworkRecvStatus SendMap();
NetworkRecvStatus SendErrorQuit(ClientID client_id, NetworkErrorCode errorno);
NetworkRecvStatus SendQuit(ClientID client_id);