1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
63 | { |
63 | { |
64 | tstamp stamp = NOW; |
64 | tstamp stamp = NOW; |
65 | |
65 | |
66 | if (cmd_queue.size () >= MAX_QUEUE_DEPTH) |
66 | if (cmd_queue.size () >= MAX_QUEUE_DEPTH) |
67 | { |
67 | { |
68 | //TODO: just disconnect here? |
|
|
69 | reset_state (); |
68 | reset_state (); |
70 | send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); |
69 | send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); |
71 | } |
70 | } |
72 | else |
71 | else |
73 | { |
72 | { |
… | |
… | |
179 | destroy (); |
178 | destroy (); |
180 | } |
179 | } |
181 | } |
180 | } |
182 | #endif |
181 | #endif |
183 | |
182 | |
|
|
183 | // limit budget surplus/deficit by one mss, add per-tick budget |
184 | rate_avail = min (max_rate + mss, rate_avail + max_rate); |
184 | rate_avail = min (rate_avail, mss) + max_rate; |
185 | |
185 | |
186 | int max_send = rate_avail; |
186 | int max_send = rate_avail; |
187 | |
187 | |
188 | #if HAVE_TCP_INFO |
188 | #if HAVE_TCP_INFO |
189 | // further restrict the available bandwidth by the excess bandwidth available |
189 | // further restrict the available bandwidth by the excess bandwidth available |
190 | max_send = min (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss); |
190 | min_it (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss); |
191 | #endif |
191 | #endif |
192 | |
192 | |
193 | // round to next-lowest mss |
193 | // round to next-lowest mss |
194 | max_send -= max_send % mss; |
194 | max_send -= max_send % mss; |
195 | |
195 | |
… | |
… | |
245 | |
245 | |
246 | packet sl ("ix"); |
246 | packet sl ("ix"); |
247 | |
247 | |
248 | sl << ber32 (ix.idx) |
248 | sl << ber32 (ix.idx) |
249 | << ber32 (ix.ofs) |
249 | << ber32 (ix.ofs) |
250 | << data (d->data.data () + ix.ofs, chunk); |
250 | << data (d->data + ix.ofs, chunk); |
251 | |
251 | |
252 | send_packet (sl); |
252 | send_packet (sl); |
253 | } |
253 | } |
254 | else |
254 | else |
255 | ix.ofs = 0; |
255 | ix.ofs = 0; |