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.92 by root, Tue Jan 3 11:25:37 2012 UTC vs.
Revision 1.97 by root, Sun Nov 11 05:53:12 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,2010,2011,2012 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.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the Affero GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23/** 23/**
24 * \file 24 * \file
113} 113}
114 114
115void 115void
116client::tick () 116client::tick ()
117{ 117{
118 if (!pl || destroyed ()) 118 if (destroyed ())
119 return; 119 return;
120 120
121 if (pl)
122 {
121 pl->dirty = true; 123 pl->dirty = true;
122 124
123 /* Update the players stats once per tick. More efficient than 125 /* Update the players stats once per tick. More efficient than
124 * sending them whenever they change, and probably just as useful 126 * sending them whenever they change, and probably just as useful
125 */ 127 */
126 pl->need_updated_stats (); 128 pl->need_updated_stats ();
127 esrv_update_stats (pl); 129 esrv_update_stats (pl);
128 130
129 if (pl->ns->update_spells) 131 if (pl->ns->update_spells)
130 esrv_update_spells (pl); 132 esrv_update_spells (pl);
131 133
132 sint32 weight = pl->ob->client_weight (); 134 sint32 weight = pl->ob->client_weight ();
133 135
134 if (last_weight != weight) 136 if (last_weight != weight)
135 { 137 {
136 pl->ob->update_stats (); 138 pl->ob->update_stats ();
137 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob); 139 esrv_update_item (UPD_WEIGHT, pl->ob, pl->ob);
138 } 140 }
139 141
140 draw_client_map (pl); 142 draw_client_map (pl);
141 143
142 if (update_look) 144 if (update_look)
143 esrv_draw_look (pl); 145 esrv_draw_look (pl);
144 146
145 mapinfo_queue_run (); 147 mapinfo_queue_run ();
148 }
146 149
147#if HAVE_TCP_INFO 150#if HAVE_TCP_INFO
148 // check time of last ack, and, if too old, kill connection 151 // check time of last ack, and, if too old, kill connection
149 socklen_t len = sizeof (tcpi); 152 socklen_t len = sizeof (tcpi);
150 153
201 { 204 {
202 ++scrub_idx; 205 ++scrub_idx;
203 206
204 if (!faces_sent [scrub_idx]) 207 if (!faces_sent [scrub_idx])
205 if (faceinfo *f = face_info (scrub_idx)) 208 if (faceinfo *f = face_info (scrub_idx))
206 if (f->type == FT_FACE || f->type == FT_SOUND) // only scrub faces and sounds for now 209 if (f->type == FT_IMAGE || f->type == FT_SOUND) // only scrub faces and sounds for now
207 { 210 {
208 send_face (scrub_idx, -120); 211 send_face (scrub_idx, -120);
209 flush_fx (); 212 flush_fx ();
210 213
211 bg_scrub = 1; // send up to one fx per tick, unless an image was requested 214 bg_scrub = 1; // send up to one fx per tick, unless an image was requested
224 if (avail <= 0) 227 if (avail <= 0)
225 break; 228 break;
226 229
227 ixsend &ix = ixface.back (); 230 ixsend &ix = ixface.back ();
228 231
229 if (facedata *d = face_data (ix.idx, faceset))
230 {
231 // estimate the packet header overhead "ix " + idx + (new)ofs 232 // estimate the packet header overhead "ix " + idx + (new)ofs
232 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs); 233 int pktlen = 3 + ber32::encoded_size (ix.idx) + ber32::encoded_size (ix.ofs);
233 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen; 234 int chunk = min (avail - packet::hdrlen, MAXSOCKBUF) - pktlen;
234 235
235 // only transfer something if the amount of data transferred 236 // only transfer something if the amount of data transferred
236 // has a healthy relation to the header overhead 237 // has a healthy relation to the header overhead
237 if (chunk < 64) 238 if (chunk < 64)
238 break; 239 break;
239 240
240 chunk = min (chunk, (int)ix.ofs); 241 chunk = min (chunk, (int)ix.ofs);
241 242
242 ix.ofs -= chunk; 243 ix.ofs -= chunk;
243 244
244 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D 245 //fprintf (stderr, "i%dx %6d: %5d+%4d (%4d)\n", fxix, ix.idx,ix.ofs,chunk, ixface.size());//D
245 246
246 packet sl ("ix"); 247 packet sl ("ix");
247 248
248 sl << ber32 (ix.idx) 249 sl << ber32 (ix.idx)
249 << ber32 (ix.ofs) 250 << ber32 (ix.ofs)
250 << data (d->data + ix.ofs, chunk); 251 << data (ix.data + ix.ofs, chunk);
251 252
252 send_packet (sl); 253 send_packet (sl);
253 }
254 else
255 ix.ofs = 0;
256 254
257 if (!ix.ofs) 255 if (!ix.ofs)
258 { 256 {
259 ixface.pop_back (); 257 ix_pop ();
260 258
261 if (ixface.empty ()) 259 if (ixface.empty ())
262 break; 260 break;
263 } 261 }
264 } 262 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines