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.72 by root, Thu Mar 13 12:20:52 2008 UTC vs.
Revision 1.78 by root, Sat Dec 27 01:25:00 2008 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 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
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
115client::tick () 115client::tick ()
116{ 116{
117 if (!pl || destroyed ()) 117 if (!pl || destroyed ())
118 return; 118 return;
119 119
120 pl->dirty = true;
121
120 /* Update the players stats once per tick. More efficient than 122 /* Update the players stats once per tick. More efficient than
121 * sending them whenever they change, and probably just as useful 123 * sending them whenever they change, and probably just as useful
122 */ 124 */
123 esrv_update_stats (pl); 125 esrv_update_stats (pl);
124 126
125 if (last_weight != -1 && last_weight != WEIGHT (pl->ob)) 127 sint32 weight = pl->ob->client_weight ();
128
129 if (last_weight != weight)
126 { 130 {
131 pl->ob->update_stats ();
127 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob); 132 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob);
128 if (last_weight != WEIGHT (pl->ob))
129 LOG (llevError, "esrv_update_item(UPD_WEIGHT) did not set player weight: is %lu, should be %lu\n",
130 (unsigned long) last_weight, WEIGHT (pl->ob));
131 } 133 }
132 134
133 draw_client_map (pl); 135 draw_client_map (pl);
134 136
135 if (update_look) 137 if (update_look)
180#if HAVE_TCP_INFO 182#if HAVE_TCP_INFO
181 // further restrict the available bandwidth by the excess bandwidth available 183 // further restrict the available bandwidth by the excess bandwidth available
182 max_send = min (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss); 184 max_send = min (max_send, (tcpi.tcpi_snd_cwnd - tcpi.tcpi_unacked + tcpi.tcpi_sacked) * mss);
183#endif 185#endif
184 186
185 // if we can split images, round to next-lowest mss 187 // round to next-lowest mss
186 if (fxix) max_send -= max_send % mss; 188 max_send -= max_send % mss;
187 189
188 if (ixface.empty ()) 190 if (ixface.empty ())
189 { 191 {
190 // regularly send a new face when queue is empty 192 // regularly send a new face when queue is empty
191 if (bg_scrub && !--bg_scrub && enable_bg_scrub) 193 if (bg_scrub && !--bg_scrub)
192 while (scrub_idx < faces.size () - 1) 194 while (scrub_idx < faces.size () - 1)
193 { 195 {
194 ++scrub_idx; 196 ++scrub_idx;
195 197
196 if (!faces_sent [scrub_idx]) 198 if (!faces_sent [scrub_idx])
218 220
219 ixsend &ix = ixface.back (); 221 ixsend &ix = ixface.back ();
220 222
221 if (facedata *d = face_data (ix.idx, faceset)) 223 if (facedata *d = face_data (ix.idx, faceset))
222 { 224 {
223 if (fxix)
224 {
225 // estimate the packet header overhead "ix " + idx + (new)ofs 225 // estimate the packet header overhead "ix " + idx + (new)ofs
226 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs); 226 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs);
227 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen; 227 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen;
228 228
229 // only transfer something if the amount of data transferred 229 // only transfer something if the amount of data transferred
230 // has a healthy relation to the header overhead 230 // has a healthy relation to the header overhead
231 if (chunk < 64) 231 if (chunk < 64)
232 break; 232 break;
233 233
234 chunk = min (chunk, (int)ix.ofs); 234 chunk = min (chunk, (int)ix.ofs);
235 235
236 ix.ofs -= chunk; 236 ix.ofs -= chunk;
237 237
238 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D 238 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D
239 239
240 packet sl ("ix"); 240 packet sl ("ix");
241 241
242 sl << ber32 (ix.idx) 242 sl << ber32 (ix.idx)
243 << ber32 (ix.ofs) 243 << ber32 (ix.ofs)
244 << data (d->data.data () + ix.ofs, chunk); 244 << data (d->data.data () + ix.ofs, chunk);
245 245
246 send_packet (sl); 246 send_packet (sl);
247 }
248 else
249 {
250 send_image (ix.idx);
251 ix.ofs = 0;
252 }
253 } 247 }
254 else 248 else
255 ix.ofs = 0; 249 ix.ofs = 0;
256 250
257 if (!ix.ofs) 251 if (!ix.ofs)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines