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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002-2003,2007 Mark Wedel & The Crossfire Development Team |
|
|
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
|
|
7 | * |
5 | * |
8 | * 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 |
9 | * 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 |
10 | * 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 |
11 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
43 | #include <netdb.h> |
41 | #include <netdb.h> |
44 | |
42 | |
45 | #include <unistd.h> |
43 | #include <unistd.h> |
46 | #include <arpa/inet.h> |
44 | #include <arpa/inet.h> |
47 | |
45 | |
48 | #include <loader.h> |
|
|
49 | |
|
|
50 | #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 |
51 | |
47 | |
52 | #define MAX_QUEUE_DEPTH 50 |
48 | #define MAX_QUEUE_DEPTH 50 |
53 | #define MAX_QUEUE_BACKLOG 3. |
49 | #define MAX_QUEUE_BACKLOG 3. |
54 | |
50 | |
… | |
… | |
67 | { |
63 | { |
68 | tstamp stamp = NOW; |
64 | tstamp stamp = NOW; |
69 | |
65 | |
70 | if (cmd_queue.size () >= MAX_QUEUE_DEPTH) |
66 | if (cmd_queue.size () >= MAX_QUEUE_DEPTH) |
71 | { |
67 | { |
72 | //TODO: just disconnect here? |
|
|
73 | reset_state (); |
68 | reset_state (); |
74 | send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); |
69 | send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); |
75 | } |
70 | } |
76 | else |
71 | else |
77 | { |
72 | { |
… | |
… | |
126 | pl->dirty = true; |
121 | pl->dirty = true; |
127 | |
122 | |
128 | /* Update the players stats once per tick. More efficient than |
123 | /* Update the players stats once per tick. More efficient than |
129 | * sending them whenever they change, and probably just as useful |
124 | * sending them whenever they change, and probably just as useful |
130 | */ |
125 | */ |
|
|
126 | pl->need_updated_stats (); |
131 | esrv_update_stats (pl); |
127 | esrv_update_stats (pl); |
|
|
128 | |
|
|
129 | if (pl->ns->update_spells) |
|
|
130 | esrv_update_spells (pl); |
132 | |
131 | |
133 | sint32 weight = pl->ob->client_weight (); |
132 | sint32 weight = pl->ob->client_weight (); |
134 | |
133 | |
135 | if (last_weight != weight) |
134 | if (last_weight != weight) |
136 | { |
135 | { |
… | |
… | |
266 | |
265 | |
267 | rate_avail -= outputbuffer_len (); |
266 | rate_avail -= outputbuffer_len (); |
268 | } |
267 | } |
269 | |
268 | |
270 | void |
269 | void |
271 | client::flush_sockets (void) |
270 | client::flush_sockets () |
272 | { |
271 | { |
273 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
272 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
274 | (*i)->flush (); |
273 | (*i)->flush (); |
275 | } |
274 | } |
276 | |
275 | |
277 | void |
276 | void |
278 | client::clock (void) |
277 | client::clock () |
279 | { |
278 | { |
280 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
279 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
281 | (*i)->tick (); |
280 | (*i)->tick (); |
282 | |
281 | |
283 | // give them all the same chances |
282 | // give them all the same chances |