ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/loop.C
(Generate patch)

Comparing deliantra/server/socket/loop.C (file contents):
Revision 1.83 by root, Tue Nov 3 23:44:21 2009 UTC vs.
Revision 1.92 by root, Tue Jan 3 11:25:37 2012 UTC

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 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.
41#include <netdb.h> 41#include <netdb.h>
42 42
43#include <unistd.h> 43#include <unistd.h>
44#include <arpa/inet.h> 44#include <arpa/inet.h>
45 45
46#include <loader.h>
47
48#define BG_SCRUB_RATE 4 // how often to send a face in the background 46#define BG_SCRUB_RATE 4 // how often to send a face in the background
49 47
50#define MAX_QUEUE_DEPTH 50 48#define MAX_QUEUE_DEPTH 50
51#define MAX_QUEUE_BACKLOG 3. 49#define MAX_QUEUE_BACKLOG 3.
52 50
65{ 63{
66 tstamp stamp = NOW; 64 tstamp stamp = NOW;
67 65
68 if (cmd_queue.size () >= MAX_QUEUE_DEPTH) 66 if (cmd_queue.size () >= MAX_QUEUE_DEPTH)
69 { 67 {
70 //TODO: just disconnect here?
71 reset_state (); 68 reset_state ();
72 send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); 69 send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED);
73 } 70 }
74 else 71 else
75 { 72 {
124 pl->dirty = true; 121 pl->dirty = true;
125 122
126 /* Update the players stats once per tick. More efficient than 123 /* Update the players stats once per tick. More efficient than
127 * sending them whenever they change, and probably just as useful 124 * sending them whenever they change, and probably just as useful
128 */ 125 */
126 pl->need_updated_stats ();
129 esrv_update_stats (pl); 127 esrv_update_stats (pl);
128
129 if (pl->ns->update_spells)
130 esrv_update_spells (pl);
130 131
131 sint32 weight = pl->ob->client_weight (); 132 sint32 weight = pl->ob->client_weight ();
132 133
133 if (last_weight != weight) 134 if (last_weight != weight)
134 { 135 {
177 destroy (); 178 destroy ();
178 } 179 }
179 } 180 }
180#endif 181#endif
181 182
183 // limit budget surplus/deficit by one mss, add per-tick budget
182 rate_avail = min (max_rate + mss, rate_avail + max_rate); 184 rate_avail = min (rate_avail, mss) + max_rate;
183 185
184 int max_send = rate_avail; 186 int max_send = rate_avail;
185 187
186#if HAVE_TCP_INFO 188#if HAVE_TCP_INFO
187 // further restrict the available bandwidth by the excess bandwidth available 189 // further restrict the available bandwidth by the excess bandwidth available
188 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);
189#endif 191#endif
190 192
191 // round to next-lowest mss 193 // round to next-lowest mss
192 max_send -= max_send % mss; 194 max_send -= max_send % mss;
193 195
243 245
244 packet sl ("ix"); 246 packet sl ("ix");
245 247
246 sl << ber32 (ix.idx) 248 sl << ber32 (ix.idx)
247 << ber32 (ix.ofs) 249 << ber32 (ix.ofs)
248 << data (d->data.data () + ix.ofs, chunk); 250 << data (d->data + ix.ofs, chunk);
249 251
250 send_packet (sl); 252 send_packet (sl);
251 } 253 }
252 else 254 else
253 ix.ofs = 0; 255 ix.ofs = 0;
264 266
265 rate_avail -= outputbuffer_len (); 267 rate_avail -= outputbuffer_len ();
266} 268}
267 269
268void 270void
269client::flush_sockets (void) 271client::flush_sockets ()
270{ 272{
271 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 273 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
272 (*i)->flush (); 274 (*i)->flush ();
273} 275}
274 276
275void 277void
276client::clock (void) 278client::clock ()
277{ 279{
278 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 280 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
279 (*i)->tick (); 281 (*i)->tick ();
280 282
281 // give them all the same chances 283 // give them all the same chances

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines