--- deliantra/server/socket/image.C 2007/07/01 05:00:20 1.44 +++ deliantra/server/socket/image.C 2007/07/12 18:48:20 1.48 @@ -213,14 +213,39 @@ ix.idx = idx; ix.ofs = d->data.size (); - // the by far most common case will be to insert - // right at the end, so no looping. - auto (i, ns->ixface.end ()); - for (; i != ns->ixface.begin (); ) - if (pri >= (--i)->pri) - break; + auto (pos, ns->ixface.end ()); - ns->ixface.insert (i, ix); + if (ns->fxix < 2) + { + // gcfclient does not support prioritising, older cfplus versions + // do not support interleaved transfers. + if (!ns->ixface.empty ()) + pos = ns->ixface.end () - 1; + } + else + { + // the by far most common case will be to insert + // near the end, so little looping. + while (pos != ns->ixface.begin ()) + { + --pos; + + // sort within 2k bins, to slightly prefer smaller images + if (pri > pos->pri || (pri == pos->pri && (ix.ofs >> 11) <= (pos->ofs >> 11))) + { + ++pos; + break; + } + } + } + + ns->ixface.insert (pos, ix); + +#if 0 + for (auto (i, ns->ixface.begin ()); i != ns->ixface.end (); ++i) + fprintf (stderr, "<%d,%d> ", i->pri, i->ofs); + fprintf (stderr, "\n"); +#endif } /** @@ -283,10 +308,12 @@ return; } - if (faces_sent[facenum]) + // refuse tos end non-image faces + if (d->type) return; - faces_sent[facenum] = true; + if (!must_send_face (facenum)) + return; // if for some reason we let a client without face caching connect, // we better support that decision here and implement it.