(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)
This commit is contained in:
truelight
2005-03-29 19:10:13 +00:00
parent c68cfdeeca
commit 508738f836
5 changed files with 88 additions and 6 deletions

View File

@@ -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);