(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

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 14 years ago
parent 611a9f2007
commit 6d09f4a3cb

@ -30,6 +30,7 @@ NetworkGameSocketHandler::NetworkGameSocketHandler(SOCKET s)
this->sock = s;
this->last_frame = _frame_counter;
this->last_frame_server = _frame_counter;
this->last_packet = _realtime_tick;
}
/**
@ -70,6 +71,8 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p)
{
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)

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

@ -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 {

Loading…
Cancel
Save