--- deliantra/server/socket/image.C 2012/11/09 00:11:49 1.71 +++ deliantra/server/socket/image.C 2012/11/11 04:29:11 1.72 @@ -58,18 +58,29 @@ if (!d) return; // doh - client::ixsend ix; + /* cfperl_ix calls cf::face::ix which loads the data */ + /* and then calls cf::client::send_ix to actually queue the ix */ + cfperl_ix (ns, idx, pri, d->size, d->fofs); +} - ix.pri = pri; - ix.idx = idx; - ix.ofs = d->data.size (); - ix.data = d->data; +void +client::ix_send (faceidx idx, sint16 pri, SV *data_sv) +{ + STRLEN size; + char *data = SvPVbyte (data_sv, size); + ixsend ix; + + ix.pri = pri; + ix.idx = idx; + ix.ofs = size; + ix.data = (uint8 *)data; + ix.data_sv = SvREFCNT_inc (data_sv); - auto (pos, ns->ixface.end ()); + auto (pos, ixface.end ()); // the by far most common case will be to insert // near the end, so little looping. - while (pos != ns->ixface.begin ()) + while (pos != ixface.begin ()) { --pos; @@ -81,15 +92,25 @@ } } - ns->ixface.insert (pos, ix); + ixface.insert (pos, ix); #if 0 - for (auto (i, ns->ixface.begin ()); i != ns->ixface.end (); ++i) + for (auto (i, ixface.begin ()); i != ixface.end (); ++i) fprintf (stderr, "<%d,%d> ", i->pri, i->ofs); fprintf (stderr, "\n"); #endif } +void +client::ix_pop () +{ + ixsend &ix = ixface.back (); + + SvREFCNT_dec (ix.data_sv); + + ixface.pop_back (); +} + /** * Sends a face offer (fx) to a client. * If nocache is true (nonzero), ignore the cache setting from the client -