summaryrefslogtreecommitdiff
path: root/network.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-03-29 19:10:13 +0000
committertruelight <truelight@openttd.org>2005-03-29 19:10:13 +0000
commit508738f836af7f5315ea14f8daa280d00cad2d10 (patch)
tree71c58f5741951475a3a1776a1833c7a13b621ba7 /network.c
parentc68cfdeecaccbd3979e920ec424f98375e0f9e3d (diff)
downloadopenttd-508738f836af7f5315ea14f8daa280d00cad2d10.tar.xz
(svn r2106) -Fix: improved the network-join algoritm, it is now a bit more stable
-Add: added 'pause_on_join' and 'max_join_time' for MP games, where you can auto-pause the game when a client wants to join the game. This to avoid connection losses because of big maps (200+ trains). (with tnx to #openttdcoop for the ideas and testing)
Diffstat (limited to 'network.c')
-rw-r--r--network.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/network.c b/network.c
index 69633b693..9e9b92fa6 100644
--- a/network.c
+++ b/network.c
@@ -4,6 +4,7 @@
#include "strings.h"
#include "map.h"
#include "network_data.h"
+#include "command.h"
#if defined(WITH_REV)
extern const char _openttd_revision[];
@@ -466,6 +467,9 @@ static NetworkClientState *NetworkAllocClient(SOCKET s)
cs->last_frame = 0;
cs->quited = false;
+ cs->last_frame = _frame_counter;
+ cs->last_frame_server = _frame_counter;
+
if (_network_server) {
ci = DEREF_CLIENT_INFO(cs);
memset(ci, 0, sizeof(*ci));
@@ -511,6 +515,12 @@ void NetworkCloseClient(NetworkClientState *cs)
SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->index, errorno);
}
}
+
+ /* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
+ if (cs->status == STATUS_PRE_ACTIVE && _network_pause_on_join) {
+ DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
+ NetworkServer_HandleChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, "Game unpaused", NETWORK_SERVER_INDEX);
+ }
}
closesocket(cs->socket);