Changeset - r16518:ad4d363993ef
[Not reviewed]
master
0 3 0
rubidium - 14 years ago 2010-11-19 12:33:19
rubidium@openttd.org
(svn r21254) -Change: show a different "lag" message when a client is lagging because of connection trouble or lagging because the client is just slow
3 files changed with 17 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/network/core/tcp_game.cpp
Show inline comments
 
@@ -30,6 +30,7 @@ NetworkGameSocketHandler::NetworkGameSoc
 
	this->sock              = s;
 
	this->last_frame        = _frame_counter;
 
	this->last_frame_server = _frame_counter;
 
	this->last_packet       = _realtime_tick;
 
}
 

	
 
/**
 
@@ -70,6 +71,8 @@ NetworkRecvStatus NetworkGameSocketHandl
 
{
 
	PacketGameType type = (PacketGameType)p->Recv_uint8();
 

	
 
	this->last_packet = _realtime_tick;
 

	
 
	switch (this->HasClientQuit() ? PACKET_END : type) {
 
		GAME_COMMAND(PACKET_SERVER_FULL)
 
		GAME_COMMAND(PACKET_SERVER_BANNED)
src/network/core/tcp_game.h
Show inline comments
 
@@ -473,6 +473,7 @@ public:
 
	uint32 last_frame;           ///< Last frame we have executed
 
	uint32 last_frame_server;    ///< Last frame the server has executed
 
	CommandQueue incoming_queue; ///< The command-queue awaiting handling
 
	uint last_packet;            ///< Time we received the last frame.
 

	
 
	NetworkRecvStatus CloseConnection(bool error = true);
 
	virtual NetworkRecvStatus CloseConnection(NetworkRecvStatus status) = 0;
src/network/network_server.cpp
Show inline comments
 
@@ -1522,14 +1522,23 @@ void NetworkServer_Tick(bool send_frame)
 
				if (lag > 3) {
 
					/* Client did still not report in after 4 game-day, drop him
 
					 *  (that is, the 3 of above, + 1 before any lag is counted) */
 
					IConsolePrintF(CC_ERROR,"Client #%d is dropped because the client did not respond for more than 4 game-days", cs->client_id);
 
					IConsolePrintF(CC_ERROR, cs->last_packet + 3 * DAY_TICKS * MILLISECONDS_PER_TICK > _realtime_tick ?
 
							/* A packet was received in the last three game days, so the client is likely lagging behind. */
 
								"Client #%d is dropped because the client's game state is more than 4 game-days behind" :
 
							/* No packet was received in the last three game days; sounds like a lost connection. */
 
								"Client #%d is dropped because the client did not respond for more than 4 game-days",
 
							cs->client_id);
 
					cs->CloseConnection(NETWORK_RECV_STATUS_SERVER_ERROR);
 
					continue;
 
				}
 

	
 
				/* Report once per time we detect the lag */
 
				if (cs->lag_test == 0) {
 
					IConsolePrintF(CC_WARNING,"[%d] Client #%d is slow, try increasing *net_frame_freq to a higher value!", _frame_counter, cs->client_id);
 
				/* Report once per time we detect the lag, and only when we
 
				 * received a packet in the last 2000 milliseconds. If we
 
				 * did not receive a packet, then the client is not just
 
				 * slow, but the connection is likely severed. Mentioning
 
				 * frame_freq is not useful in this case. */
 
				if (cs->lag_test == 0 && cs->last_packet + DAY_TICKS * MILLISECONDS_PER_TICK > _realtime_tick) {
 
					IConsolePrintF(CC_WARNING,"[%d] Client #%d is slow, try increasing [network.]frame_freq to a higher value!", _frame_counter, cs->client_id);
 
					cs->lag_test = 1;
 
				}
 
			} else {
0 comments (0 inline, 0 general)