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.43 by root, Fri Mar 16 02:37:54 2007 UTC vs.
Revision 1.46 by root, Tue Apr 3 01:06:09 2007 UTC

170 draw_client_map (pl->ob); 170 draw_client_map (pl->ob);
171 171
172 if (update_look) 172 if (update_look)
173 esrv_draw_look (pl->ob); 173 esrv_draw_look (pl->ob);
174 174
175 if (askface.empty ()) 175 if (askface.empty () && !partial_face_ofs)
176 { 176 {
177 // regularly send a new face when queue is empty
177 if (bg_scrub && !--bg_scrub && enable_bg_scrub) 178 if (bg_scrub && !--bg_scrub && enable_bg_scrub)
178 while (scrub_idx < faces.size () - 1) 179 while (scrub_idx < faces.size () - 1)
179 { 180 {
180 ++scrub_idx; 181 ++scrub_idx;
181 if (!faces_sent [scrub_idx]) 182 if (!faces_sent [scrub_idx])
182 { 183 {
183 send_face (scrub_idx); 184 send_face (scrub_idx);
185 flush_fx ();
186
184 bg_scrub = 1; // send up to one face per tick, unless an image was requested 187 bg_scrub = 1; // send up to one face per tick, unless an image was requested
185 break; 188 break;
186 } 189 }
187 } 190 }
191
192 rate_avail = max_rate - outputbuffer_len ();
188 } 193 }
189 else 194 else
190 while (!askface.empty () && outputbuffer_len () < max_rate)
191 { 195 {
192 // use a lifo to send most recently requested images 196 int ol = outputbuffer_len ();
193 faceidx face = askface.back ();
194 askface.pop_back ();
195 197
196 send_image (face); 198 rate_avail = min (max_rate, rate_avail + max_rate);
199 rate_avail -= ol;
197 200
201 int avail = rate_avail;
202
203 // if we can split images, transfer up to mss packets if possible
204 // but never more 768 bytes more.
205 if (fxix) avail += min (768, mss - (ol % mss));
206
198 bg_scrub = BG_SCRUB_RATE; 207 bg_scrub = BG_SCRUB_RATE;
208
209 while (avail > 0)
210 {
211 if (partial_face_ofs)
212 {
213 if (facedata *d = face_data (partial_face, faceset))
214 {
215 // 9 bytes is enough for fx_FFFOOO, 40 leaves some room
216 int chunk = min (min (avail - 40, MAXSOCKBUF - 9), partial_face_ofs);
217
218 if (chunk <= 0)
219 break;
220
221 partial_face_ofs -= chunk;
222
223 packet sl ("ix");
224
225 sl << ber32 (partial_face)
226 << ber32 (partial_face_ofs)
227 << data (d->data.data () + partial_face_ofs, chunk);
228
229 send_packet (sl);
230 }
231 else
232 partial_face_ofs = 0;
233 }
234 else if (!askface.empty ())
235 {
236 // use a lifo to send most recently requested images
237 faceidx facenum = askface.back ();
238 askface.pop_back ();
239
240 if (fxix)
241 {
242 if (facedata *d = face_data (facenum, faceset))
243 {
244 partial_face = facenum;
245 partial_face_ofs = d->data.size ();
246 }
247 }
248 else
249 send_image (facenum);
250 }
251 else
252 break;
253
254 int consumed = ol - outputbuffer_len ();
255 avail -= consumed;
256 rate_avail -= consumed;
199 } 257 }
258 }
200} 259}
201 260

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines