… | |
… | |
211 | |
211 | |
212 | ix.pri = pri; |
212 | ix.pri = pri; |
213 | ix.idx = idx; |
213 | ix.idx = idx; |
214 | ix.ofs = d->data.size (); |
214 | ix.ofs = d->data.size (); |
215 | |
215 | |
|
|
216 | auto (pos, ns->ixface.end ()); |
|
|
217 | |
|
|
218 | if (ns->fxix < 2) |
|
|
219 | { |
|
|
220 | // gcfclient does not support prioritising, older cfplus versions |
|
|
221 | // do not support interleaved transfers. |
|
|
222 | if (!ns->ixface.empty ()) |
|
|
223 | pos = ns->ixface.end () - 1; |
|
|
224 | } |
|
|
225 | else |
|
|
226 | { |
216 | // the by far most common case will be to insert |
227 | // the by far most common case will be to insert |
217 | // right at the end, so no looping. |
228 | // near the end, so little looping. |
218 | auto (i, ns->ixface.end ()); |
229 | while (pos != ns->ixface.begin ()) |
219 | for (; i != ns->ixface.begin (); ) |
230 | { |
220 | if (pri >= (--i)->pri) |
231 | --pos; |
|
|
232 | |
|
|
233 | // sort within 2k bins, to slightly prefer smaller images |
|
|
234 | if (pri > pos->pri || (pri == pos->pri && (ix.ofs >> 11) <= (pos->ofs >> 11))) |
|
|
235 | { |
|
|
236 | ++pos; |
221 | break; |
237 | break; |
|
|
238 | } |
|
|
239 | } |
|
|
240 | } |
222 | |
241 | |
223 | ns->ixface.insert (i, ix); |
242 | ns->ixface.insert (pos, ix); |
|
|
243 | |
|
|
244 | #if 0 |
|
|
245 | for (auto (i, ns->ixface.begin ()); i != ns->ixface.end (); ++i) |
|
|
246 | fprintf (stderr, "<%d,%d> ", i->pri, i->ofs); |
|
|
247 | fprintf (stderr, "\n"); |
|
|
248 | #endif |
224 | } |
249 | } |
225 | |
250 | |
226 | /** |
251 | /** |
227 | * Tells client the picture it has to use |
252 | * Tells client the picture it has to use |
228 | * to smooth a picture number given as argument. |
253 | * to smooth a picture number given as argument. |
… | |
… | |
281 | { |
306 | { |
282 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
307 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
283 | return; |
308 | return; |
284 | } |
309 | } |
285 | |
310 | |
286 | if (faces_sent[facenum]) |
311 | faceinfo *f = face_info (facenum); |
|
|
312 | |
|
|
313 | // refuse tos end non-image faces |
|
|
314 | if (f->type) |
287 | return; |
315 | return; |
288 | |
316 | |
289 | faces_sent[facenum] = true; |
317 | if (!must_send_face (facenum)) |
|
|
318 | return; |
290 | |
319 | |
291 | // if for some reason we let a client without face caching connect, |
320 | // if for some reason we let a client without face caching connect, |
292 | // we better support that decision here and implement it. |
321 | // we better support that decision here and implement it. |
293 | if (!facecache) |
322 | if (!facecache) |
294 | return send_image (facenum); |
323 | return send_image (facenum); |
… | |
… | |
312 | print_facename (sl, *d); |
341 | print_facename (sl, *d); |
313 | send_packet (sl); |
342 | send_packet (sl); |
314 | |
343 | |
315 | if (EMI_smooth) |
344 | if (EMI_smooth) |
316 | { |
345 | { |
317 | faceinfo *f = face_info (facenum); |
|
|
318 | |
|
|
319 | if (f->smooth) |
346 | if (f->smooth) |
320 | { |
347 | { |
321 | send_face (f->smooth); |
348 | send_face (f->smooth); |
322 | |
349 | |
323 | packet sl ("smooth"); |
350 | packet sl ("smooth"); |