--- deliantra/server/socket/image.C 2007/03/11 20:25:37 1.25 +++ deliantra/server/socket/image.C 2007/03/12 23:45:37 1.27 @@ -213,6 +213,25 @@ 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. +static uint32 gcfclient_checksum (const facedata *d) +{ + uint32 csum = 0; + + for (std::string::const_iterator i = d->data.begin (); + i != d->data.end (); + ++i) + { + csum = rotate_right (csum); + csum += *(uint8 *)&*i; + } + + return csum; +} + /** * Sends a face to a client if they are in pixmap mode * nothing gets sent in bitmap mode. @@ -236,13 +255,12 @@ if (ns->facecache && !nocache) { - sl << (ns->image2 ? "face2 " : "face1 ") - << uint16 (face_num); - - if (ns->image2) - sl << uint8 (0); - - sl << uint32 (0); + if (ns->force_face0) + sl << "face " << uint16 (face_num); + else if (ns->image2) + sl << "face2 " << uint16 (face_num) << uint8 (0) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); + else + sl << "face1 " << uint16 (face_num) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); // how lame print_facename (sl, *d);