… | |
… | |
49 | #define BG_SCRUB_RATE 4 // how often to send a face in the background |
49 | #define BG_SCRUB_RATE 4 // how often to send a face in the background |
50 | |
50 | |
51 | #define MAX_QUEUE_DEPTH 50 |
51 | #define MAX_QUEUE_DEPTH 50 |
52 | #define MAX_QUEUE_BACKLOG 3. |
52 | #define MAX_QUEUE_BACKLOG 3. |
53 | |
53 | |
54 | // disconnect a socket after this many seconds without an ack |
|
|
55 | #define SOCKET_TIMEOUT 16. |
|
|
56 | |
|
|
57 | void |
54 | void |
58 | client::reset_state () |
55 | client::reset_state () |
59 | { |
56 | { |
60 | if (!pl) |
57 | if (!pl) |
61 | return; |
58 | return; |
… | |
… | |
95 | { |
92 | { |
96 | command &cmd = cmd_queue.front (); |
93 | command &cmd = cmd_queue.front (); |
97 | |
94 | |
98 | if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW) |
95 | if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW) |
99 | { |
96 | { |
100 | reset_state (); |
97 | reset_state (); // the command might actually reset some movement state etc. |
101 | send_packet_printf ("drawinfo %d ignoring delayed commands.", NDI_RED); |
98 | |
|
|
99 | if (pl) |
|
|
100 | pl->failmsg ( |
|
|
101 | "Cannot keep up with your commands, ignoring them! " |
|
|
102 | "H<Your character cannot keep up with the instructions you give G<him|her>. " |
|
|
103 | "Try issuing commands slower, or, if G<he|she> is incapacitated (paralyzed and so on), " |
|
|
104 | "wait till your character can act again.\n\nIf G<he|she> is permanently stuck, then " |
|
|
105 | "try the B<suicide> command (or use B<chat> to ask somebody to B<invite> you out).>" |
|
|
106 | ); |
102 | } |
107 | } |
103 | else |
108 | else |
104 | execute (cmd.handler, cmd.data, cmd.datalen); |
109 | execute (cmd.handler, cmd.data, cmd.datalen); |
105 | |
110 | |
106 | sfree<char> (cmd.data, cmd.datalen + 1); |
111 | sfree<char> (cmd.data, cmd.datalen + 1); |
… | |
… | |
158 | tcpi.tcpi_snd_ssthresh, tcpi.tcpi_snd_cwnd, tcpi.tcpi_advmss, tcpi.tcpi_pmtu, tcpi.tcpi_advmss, |
163 | tcpi.tcpi_snd_ssthresh, tcpi.tcpi_snd_cwnd, tcpi.tcpi_advmss, tcpi.tcpi_pmtu, tcpi.tcpi_advmss, |
159 | |
164 | |
160 | tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked)); |
165 | tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked)); |
161 | #endif |
166 | #endif |
162 | |
167 | |
163 | // fast-time-out a player by checking for missign acks |
168 | // fast-time-out a player by checking for missing acks |
164 | // do this only when player is active |
169 | // do this only when player is active |
165 | if (pl && pl->active |
170 | if (pl && pl->active |
166 | && tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000)) |
171 | && tcpi.tcpi_last_ack_recv > int (socket_timeout * 1000)) |
167 | { |
172 | { |
168 | send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); |
173 | send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); |
169 | write_outputbuffer (); |
174 | write_outputbuffer (); |
170 | |
175 | |
171 | LOG (llevDebug, "connection on fd %d closed due to ack timeout (%u/%u/%u)\n", fd, |
176 | LOG (llevDebug, "connection on fd %d closed due to ack timeout (%u/%u/%u)\n", fd, |