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.77 by root, Tue May 6 16:55:26 2008 UTC vs.
Revision 1.80 by root, Thu Jul 16 23:17:44 2009 UTC

95 { 95 {
96 command &cmd = cmd_queue.front (); 96 command &cmd = cmd_queue.front ();
97 97
98 if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW) 98 if (cmd.stamp + MAX_QUEUE_BACKLOG < NOW)
99 { 99 {
100 reset_state (); 100 reset_state (); // the command might actually reset some movement state etc.
101 send_packet_printf ("drawinfo %d ignoring delayed commands.", NDI_RED); 101
102 if (pl)
103 pl->failmsg (
104 "Cannot keep up with your commands, ignoring them! "
105 "H<Your character cannot keep up with the instructions you give G<him|her>. "
106 "Try issuing commands slower, or, if G<he|she> is incapacitated (paralyzed and so on), "
107 "wait till your character can act again.\n\nIf G<he|she> is permanently stuck, then "
108 "try the B<suicide> command (or use B<chat> to ask somebody to B<invite> you out).>"
109 );
102 } 110 }
103 else 111 else
104 execute (cmd.handler, cmd.data, cmd.datalen); 112 execute (cmd.handler, cmd.data, cmd.datalen);
105 113
106 sfree<char> (cmd.data, cmd.datalen + 1); 114 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, 166 tcpi.tcpi_snd_ssthresh, tcpi.tcpi_snd_cwnd, tcpi.tcpi_advmss, tcpi.tcpi_pmtu, tcpi.tcpi_advmss,
159 167
160 tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked)); 168 tcpi.tcpi_snd_cwnd - (tcpi.tcpi_unacked - tcpi.tcpi_sacked));
161#endif 169#endif
162 170
163 // fast-time-out a player by checking for missign acks 171 // fast-time-out a player by checking for missing acks
164 // do this only when player is active 172 // do this only when player is active
165 if (pl && pl->active 173 if (pl && pl->active
166 && tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000)) 174 && tcpi.tcpi_last_ack_recv > int (SOCKET_TIMEOUT * 1000))
167 { 175 {
168 send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)"); 176 send_msg (NDI_RED | NDI_REPLY, "connection-timeout", "safety disconnect due to tcp/ip timeout (no packets received)");
182#if HAVE_TCP_INFO 190#if HAVE_TCP_INFO
183 // further restrict the available bandwidth by the excess bandwidth available 191 // further restrict the available bandwidth by the excess bandwidth available
184 max_send = min (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss); 192 max_send = min (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss);
185#endif 193#endif
186 194
187 // if we can split images, round to next-lowest mss 195 // round to next-lowest mss
188 if (fxix) max_send -= max_send % mss; 196 max_send -= max_send % mss;
189 197
190 if (ixface.empty ()) 198 if (ixface.empty ())
191 { 199 {
192 // regularly send a new face when queue is empty 200 // regularly send a new face when queue is empty
193 if (bg_scrub && !--bg_scrub && enable_bg_scrub) 201 if (bg_scrub && !--bg_scrub)
194 while (scrub_idx < faces.size () - 1) 202 while (scrub_idx < faces.size () - 1)
195 { 203 {
196 ++scrub_idx; 204 ++scrub_idx;
197 205
198 if (!faces_sent [scrub_idx]) 206 if (!faces_sent [scrub_idx])
220 228
221 ixsend &ix = ixface.back (); 229 ixsend &ix = ixface.back ();
222 230
223 if (facedata *d = face_data (ix.idx, faceset)) 231 if (facedata *d = face_data (ix.idx, faceset))
224 { 232 {
225 if (fxix)
226 {
227 // estimate the packet header overhead "ix " + idx + (new)ofs 233 // estimate the packet header overhead "ix " + idx + (new)ofs
228 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs); 234 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs);
229 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen; 235 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen;
230 236
231 // only transfer something if the amount of data transferred 237 // only transfer something if the amount of data transferred
232 // has a healthy relation to the header overhead 238 // has a healthy relation to the header overhead
233 if (chunk < 64) 239 if (chunk < 64)
234 break; 240 break;
235 241
236 chunk = min (chunk, (int)ix.ofs); 242 chunk = min (chunk, (int)ix.ofs);
237 243
238 ix.ofs -= chunk; 244 ix.ofs -= chunk;
239 245
240 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D 246 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D
241 247
242 packet sl ("ix"); 248 packet sl ("ix");
243 249
244 sl << ber32 (ix.idx) 250 sl << ber32 (ix.idx)
245 << ber32 (ix.ofs) 251 << ber32 (ix.ofs)
246 << data (d->data.data () + ix.ofs, chunk); 252 << data (d->data.data () + ix.ofs, chunk);
247 253
248 send_packet (sl); 254 send_packet (sl);
249 }
250 else
251 {
252 send_image (ix.idx);
253 ix.ofs = 0;
254 }
255 } 255 }
256 else 256 else
257 ix.ofs = 0; 257 ix.ofs = 0;
258 258
259 if (!ix.ofs) 259 if (!ix.ofs)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines