… | |
… | |
211 | { |
211 | { |
212 | for (int i = 0; i < CHKSUM_SIZE; ++i) |
212 | for (int i = 0; i < CHKSUM_SIZE; ++i) |
213 | sl.printf ("%02x", d.chksum [i]); |
213 | sl.printf ("%02x", d.chksum [i]); |
214 | } |
214 | } |
215 | |
215 | |
|
|
216 | // gcfclient uses the server-provided checksum for comparison, |
|
|
217 | // but always wrotes a broken checksum to its cache file, so we |
|
|
218 | // have to provide gcfclient with a useless checksum just to |
|
|
219 | // have to cache the image despite its bugs. |
|
|
220 | static uint32 gcfclient_checksum (const facedata *d) |
|
|
221 | { |
|
|
222 | uint32 csum = 0; |
|
|
223 | |
|
|
224 | for (std::string::const_iterator i = d->data.begin (); |
|
|
225 | i != d->data.end (); |
|
|
226 | ++i) |
|
|
227 | { |
|
|
228 | csum = rotate_right (csum); |
|
|
229 | csum += *(uint8 *)&*i; |
|
|
230 | } |
|
|
231 | |
|
|
232 | return csum; |
|
|
233 | } |
|
|
234 | |
216 | /** |
235 | /** |
217 | * Sends a face to a client if they are in pixmap mode |
236 | * Sends a face to a client if they are in pixmap mode |
218 | * nothing gets sent in bitmap mode. |
237 | * nothing gets sent in bitmap mode. |
219 | * If nocache is true (nonzero), ignore the cache setting from the client - |
238 | * If nocache is true (nonzero), ignore the cache setting from the client - |
220 | * this is needed for the askface, in which we really do want to send the |
239 | * this is needed for the askface, in which we really do want to send the |
… | |
… | |
234 | |
253 | |
235 | packet sl; |
254 | packet sl; |
236 | |
255 | |
237 | if (ns->facecache && !nocache) |
256 | if (ns->facecache && !nocache) |
238 | { |
257 | { |
239 | sl << (ns->image2 ? "face2 " : "face1 ") |
258 | if (ns->force_face0) |
240 | << uint16 (face_num); |
259 | sl << "face " << uint16 (face_num); |
241 | |
|
|
242 | if (ns->image2) |
260 | else if (ns->image2) |
243 | sl << uint8 (0); |
261 | sl << "face2 " << uint16 (face_num) << uint8 (0) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); |
244 | |
262 | else |
245 | sl << uint32 (0); |
263 | sl << "face1 " << uint16 (face_num) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); |
246 | |
264 | |
247 | // how lame |
265 | // how lame |
248 | print_facename (sl, *d); |
266 | print_facename (sl, *d); |
249 | |
267 | |
250 | ns->send_packet (sl); |
268 | ns->send_packet (sl); |
251 | } |
269 | } |
252 | else |
270 | else |
253 | { |
271 | { |
|
|
272 | fprintf (stderr, "image %s %d\n", &faces [face_num].name, nocache);//D |
254 | sl << (ns->image2 ? "image2 " : "image ") |
273 | sl << (ns->image2 ? "image2 " : "image ") |
255 | << uint32 (face_num); |
274 | << uint32 (face_num); |
256 | |
275 | |
257 | if (ns->image2) |
276 | if (ns->image2) |
258 | sl << uint8 (0); |
277 | sl << uint8 (0); |