… | |
… | |
198 | * caching images. |
198 | * caching images. |
199 | */ |
199 | */ |
200 | void |
200 | void |
201 | SendFaceCmd (char *buf, int len, client *ns) |
201 | SendFaceCmd (char *buf, int len, client *ns) |
202 | { |
202 | { |
203 | ns->send_face (atoi (buf), 1); |
203 | ns->send_image (atoi (buf)); |
204 | } |
204 | } |
205 | |
205 | |
206 | // how lame |
206 | // how lame |
207 | static void print_facename (packet &sl, const facedata &d) |
207 | static void print_facename (packet &sl, const facedata &d) |
208 | { |
208 | { |
209 | for (int i = 0; i < CHKSUM_SIZE; ++i) |
209 | for (int i = 0; i < CHKSUM_SIZE; ++i) |
210 | sl.printf ("%02x", d.chksum [i]); |
210 | sl.printf ("%02x", d.chksum [i]); |
211 | } |
211 | } |
212 | |
212 | |
213 | // gcfclient uses the server-provided checksum for comparison, |
213 | // gcfclient uses the server-provided checksum for comparison, but always |
214 | // but always wrotes a broken checksum to its cache file, so we |
214 | // writes a broken checksum to its cache file, so we have to provide |
215 | // have to provide gcfclient with a useless checksum just to |
215 | // gcfclient with the same broken (and useless) checksum just to have it |
216 | // have to cache the image despite its bugs. |
216 | // cache the image despite its bugs. |
217 | static uint32 gcfclient_checksum (const facedata *d) |
217 | static uint32 gcfclient_checksum (const facedata *d) |
218 | { |
218 | { |
219 | uint32 csum = 0; |
219 | uint32 csum = 0; |
220 | |
220 | |
221 | for (std::string::const_iterator i = d->data.begin (); |
221 | for (std::string::const_iterator i = d->data.begin (); |
… | |
… | |
236 | * this is needed for the askface, in which we really do want to send the |
236 | * this is needed for the askface, in which we really do want to send the |
237 | * face (and askface is the only place that should be setting it). Otherwise, |
237 | * face (and askface is the only place that should be setting it). Otherwise, |
238 | * we look at the facecache, and if set, send the image name. |
238 | * we look at the facecache, and if set, send the image name. |
239 | */ |
239 | */ |
240 | void |
240 | void |
241 | client::send_face (faceidx facenum, bool forced) |
241 | client::send_face (faceidx facenum) |
242 | { |
242 | { |
243 | // never send face 0. ever. it does not exist. |
243 | // never send face 0. ever. it does not exist. |
244 | if (!facenum) |
244 | if (!facenum) |
245 | return; |
245 | return; |
246 | |
246 | |
… | |
… | |
250 | { |
250 | { |
251 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
251 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
252 | return; |
252 | return; |
253 | } |
253 | } |
254 | |
254 | |
|
|
255 | if (faces_sent[facenum]) |
|
|
256 | return; |
|
|
257 | |
|
|
258 | faces_sent[facenum] = true; |
|
|
259 | |
|
|
260 | if (!facecache) |
|
|
261 | { |
|
|
262 | send_drawinfo ( |
|
|
263 | "\n" |
|
|
264 | "\n" |
|
|
265 | "***\n" |
|
|
266 | "*** WARNING:\n" |
|
|
267 | "*** Your client does not support face/image caching,\n" |
|
|
268 | "*** or it has been disabled. Face caching is mandatory\n" |
|
|
269 | "*** so please enable it or use a newer client.\n" |
|
|
270 | "***\n" |
|
|
271 | "*** Look at your client preferences:\n" |
|
|
272 | "***\n" |
|
|
273 | "*** CFPlus: all known versions automatically enable the facecache.\n" |
|
|
274 | "*** cfclient: use the -cache commandline option.\n" |
|
|
275 | "*** cfclient: map will not redraw automatically (bug).\n" |
|
|
276 | "*** gcfclient: use -cache commandline option, or enable\n" |
|
|
277 | "*** gcfclient: Client=>Configure=>Map & Image=>Cache Images.\n" |
|
|
278 | "*** jcrossclient: your client is broken, use CFPlus or gcfclient.\n" |
|
|
279 | "***\n" |
|
|
280 | "***\n", |
|
|
281 | NDI_RED |
|
|
282 | ); |
|
|
283 | return; |
|
|
284 | //return send_image (facenum); |
|
|
285 | } |
|
|
286 | |
255 | packet sl; |
287 | packet sl; |
256 | |
288 | |
257 | if (facecache && !forced) |
|
|
258 | { |
|
|
259 | if (faces_sent[facenum]) |
|
|
260 | return; |
|
|
261 | |
|
|
262 | faces_sent[facenum] = true; |
|
|
263 | |
|
|
264 | faceinfo *f = face_info (facenum); |
|
|
265 | if (f->smooth && EMI_smooth) |
|
|
266 | { |
|
|
267 | send_face (f->smooth); |
|
|
268 | |
|
|
269 | packet sl ("smooth"); |
|
|
270 | |
|
|
271 | sl << uint16 (facenum) |
|
|
272 | << uint16 (f->smooth); |
|
|
273 | |
|
|
274 | send_packet (sl); |
|
|
275 | } |
|
|
276 | |
|
|
277 | if (force_face0) |
289 | if (force_face0) |
278 | sl << "face " << uint16 (facenum); |
290 | sl << "face " << uint16 (facenum); |
279 | else if (image2) |
291 | else if (image2) |
280 | sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
292 | sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
281 | else |
|
|
282 | sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
|
|
283 | |
|
|
284 | // how lame |
|
|
285 | print_facename (sl, *d); |
|
|
286 | } |
|
|
287 | else |
293 | else |
|
|
294 | sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
|
|
295 | |
|
|
296 | // how lame |
|
|
297 | print_facename (sl, *d); |
|
|
298 | send_packet (sl); |
|
|
299 | |
|
|
300 | faceinfo *f = face_info (facenum); |
|
|
301 | if (f->smooth && EMI_smooth) |
|
|
302 | { |
|
|
303 | send_face (f->smooth); |
|
|
304 | |
|
|
305 | packet sl ("smooth"); |
|
|
306 | |
|
|
307 | sl << uint16 (facenum) |
|
|
308 | << uint16 (f->smooth); |
|
|
309 | |
|
|
310 | send_packet (sl); |
288 | { |
311 | } |
|
|
312 | } |
|
|
313 | |
|
|
314 | void |
|
|
315 | client::send_image (faceidx facenum) |
|
|
316 | { |
|
|
317 | // never send face 0. ever. it does not exist. |
|
|
318 | if (!facenum) |
|
|
319 | return; |
|
|
320 | |
|
|
321 | const facedata *d = face_data (facenum, faceset); |
|
|
322 | |
|
|
323 | if (!d) |
|
|
324 | { |
|
|
325 | LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); |
|
|
326 | return; |
|
|
327 | } |
|
|
328 | |
|
|
329 | faces_sent[facenum] = true; |
|
|
330 | |
|
|
331 | if (force_image_newmap) |
|
|
332 | force_newmap = true; |
|
|
333 | |
|
|
334 | packet sl; |
|
|
335 | |
289 | sl << (image2 ? "image2 " : "image ") |
336 | sl << (image2 ? "image2 " : "image ") |
290 | << uint32 (facenum); |
337 | << uint32 (facenum); |
291 | |
338 | |
292 | if (image2) |
339 | if (image2) |
293 | sl << uint8 (0); |
340 | sl << uint8 (0); |
294 | |
341 | |
295 | sl << uint32 (d->data.size ()) |
342 | sl << uint32 (d->data.size ()) |
296 | << data (d->data.data (), d->data.size ()); |
343 | << data (d->data.data (), d->data.size ()); |
297 | } |
|
|
298 | |
344 | |
299 | send_packet (sl); |
345 | send_packet (sl); |
300 | } |
346 | } |
301 | |
347 | |
302 | // send all faces of this object to the client |
348 | // send all faces of this object to the client |