… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & The Crossfire Development Team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & The Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /** |
25 | /** |
… | |
… | |
49 | #define BG_SCRUB_RATE 4 // how often to send a face in the background |
50 | #define BG_SCRUB_RATE 4 // how often to send a face in the background |
50 | |
51 | |
51 | #define MAX_QUEUE_DEPTH 50 |
52 | #define MAX_QUEUE_DEPTH 50 |
52 | #define MAX_QUEUE_BACKLOG 3. |
53 | #define MAX_QUEUE_BACKLOG 3. |
53 | |
54 | |
54 | // disconnect a socket after this many seconds without an ack |
|
|
55 | #define SOCKET_TIMEOUT 16. |
|
|
56 | |
|
|
57 | void |
55 | void |
58 | client::reset_state () |
56 | client::reset_state () |
59 | { |
57 | { |
60 | if (!pl) |
58 | if (!pl) |
61 | return; |
59 | return; |
… | |
… | |
95 | { |
93 | { |
96 | command &cmd = cmd_queue.front (); |
94 | command &cmd = cmd_queue.front (); |
97 | |
95 | |
98 | if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW) |
96 | if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW) |
99 | { |
97 | { |
100 | reset_state (); |
98 | reset_state (); // the command might actually reset some movement state etc. |
101 | send_packet_printf ("drawinfo %d ignoring delayed commands.", NDI_RED); |
99 | |
|
|
100 | if (pl) |
|
|
101 | pl->failmsg ( |
|
|
102 | "Cannot keep up with your commands, ignoring them! " |
|
|
103 | "H<Your character cannot keep up with the instructions you give G<him|her>. " |
|
|
104 | "Try issuing commands slower, or, if G<he|she> is incapacitated (paralyzed and so on), " |
|
|
105 | "wait till your character can act again.\n\nIf G<he|she> is permanently stuck, then " |
|
|
106 | "try the B<suicide> command (or use B<chat> to ask somebody to B<invite> you out).>" |
|
|
107 | ); |
102 | } |
108 | } |
103 | else |
109 | else |
104 | execute (cmd.handler, cmd.data, cmd.datalen); |
110 | execute (cmd.handler, cmd.data, cmd.datalen); |
105 | |
111 | |
106 | sfree<char> (cmd.data, cmd.datalen + 1); |
112 | 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, |
164 | tcpi.tcpi_snd_ssthresh, tcpi.tcpi_snd_cwnd, tcpi.tcpi_advmss, tcpi.tcpi_pmtu, tcpi.tcpi_advmss, |
159 | |
165 | |
160 | tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked)); |
166 | tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked)); |
161 | #endif |
167 | #endif |
162 | |
168 | |
163 | // fast-time-out a player by checking for missign acks |
169 | // fast-time-out a player by checking for missing acks |
164 | // do this only when player is active |
170 | // do this only when player is active |
165 | if (pl && pl->active |
171 | if (pl && pl->active |
166 | && tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000)) |
172 | && tcpi.tcpi_last_ack_recv > int (socket_timeout * 1000)) |
167 | { |
173 | { |
168 | send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); |
174 | send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); |
169 | write_outputbuffer (); |
175 | write_outputbuffer (); |
170 | |
176 | |
171 | LOG (llevDebug, "connection on fd %d closed due to ack timeout (%u/%u/%u)\n", fd, |
177 | LOG (llevDebug, "connection on fd %d closed due to ack timeout (%u/%u/%u)\n", fd, |