--- deliantra/server/socket/image.C 2007/03/14 00:07:26 1.29 +++ deliantra/server/socket/image.C 2007/03/14 18:25:18 1.34 @@ -200,7 +200,7 @@ void SendFaceCmd (char *buf, int len, client *ns) { - ns->send_face (atoi (buf), 1); + ns->send_image (atoi (buf)); } // how lame @@ -210,10 +210,10 @@ sl.printf ("%02x", d.chksum [i]); } -// gcfclient uses the server-provided checksum for comparison, -// but always wrotes a broken checksum to its cache file, so we -// have to provide gcfclient with a useless checksum just to -// have to cache the image despite its bugs. +// gcfclient uses the server-provided checksum for comparison, but always +// writes a broken checksum to its cache file, so we have to provide +// gcfclient with the same broken (and useless) checksum just to have it +// cache the image despite its bugs. static uint32 gcfclient_checksum (const facedata *d) { uint32 csum = 0; @@ -238,7 +238,7 @@ * we look at the facecache, and if set, send the image name. */ void -client::send_face (faceidx facenum, bool forced) +client::send_face (faceidx facenum) { // never send face 0. ever. it does not exist. if (!facenum) @@ -252,37 +252,75 @@ return; } + if (faces_sent[facenum]) + return; + + faces_sent[facenum] = true; + + if (!facecache) + { + send_drawinfo ( + "*** Please enable image/face caching in preferences or use a client that supports it.\n", + NDI_RED + ); + return send_image (facenum); + } + packet sl; - if (facecache && !forced) + if (force_face0) + sl << "face " << uint16 (facenum); + else if (image2) + sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); + else + sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); + + // how lame + print_facename (sl, *d); + send_packet (sl); + + faceinfo *f = face_info (facenum); + if (f->smooth && EMI_smooth) { - if (faces_sent[facenum] & NS_FACESENT_FACE) - return; + send_face (f->smooth); - faces_sent[facenum] |= NS_FACESENT_FACE; + packet sl ("smooth"); - if (force_face0) - sl << "face " << uint16 (facenum); - else if (image2) - sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); - else - sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); + sl << uint16 (facenum) + << uint16 (f->smooth); - // how lame - print_facename (sl, *d); + send_packet (sl); } - else - { - sl << (image2 ? "image2 " : "image ") - << uint32 (facenum); +} - if (image2) - sl << uint8 (0); +void +client::send_image (faceidx facenum) +{ + // never send face 0. ever. it does not exist. + if (!facenum) + return; + + const facedata *d = face_data (facenum, faceset); - sl << uint32 (d->data.size ()) - << data (d->data.data (), d->data.size ()); + if (!d) + { + LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); + return; } + faces_sent[facenum] = true; + + packet sl; + + sl << (image2 ? "image2 " : "image ") + << uint32 (facenum); + + if (image2) + sl << uint8 (0); + + sl << uint32 (d->data.size ()) + << data (d->data.data (), d->data.size ()); + send_packet (sl); } @@ -305,45 +343,6 @@ } /** - * A lot like the old AskSmooth (in fact, now called by AskSmooth). - * Basically, it makes no sense to wait for the client to request a - * a piece of data from us that we know the client wants. So - * if we know the client wants it, might as well push it to the - * client. - */ -void -client::send_smooth (faceidx face) -{ - faceinfo *f = face_info (face); - - if (!f) - return; - - if (faces_sent[face] & NS_FACESENT_SMOOTH) - return; - - faces_sent[face] |= NS_FACESENT_SMOOTH; - - /* If we can't find a face, return and set it so we won't try to send this - * again. - */ - if (!f->smooth) - { - LOG (llevError, "could not findsmooth for %d.\n", face); - return; - } - - send_face (f->smooth); - - packet sl ("smooth"); - - sl << uint16 (face) - << uint16 (f->smooth); - - send_packet (sl); -} - -/** * Need to send an animation sequence to the client. * We will send appropriate face commands to the client if we haven't * sent them the face yet (this can become quite costly in terms of @@ -435,7 +434,7 @@ for (int i = start; i <= stop && i < faces.size (); i++) { - ns->faces_sent[i] |= NS_FACESENT_FACE; + ns->faces_sent[i] = true; const facedata *d = face_data (i, ns->faceset);