… | |
… | |
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 | if (!facecache) |
|
|
244 | { |
|
|
245 | send_drawinfo ( |
|
|
246 | "*** Please enable face caching or use a client that supports it.\n", |
|
|
247 | NDI_RED |
|
|
248 | ); |
|
|
249 | return send_image (facenum); |
|
|
250 | } |
|
|
251 | |
243 | // never send face 0. ever. it does not exist. |
252 | // never send face 0. ever. it does not exist. |
244 | if (!facenum) |
253 | if (!facenum) |
245 | return; |
254 | return; |
246 | |
255 | |
247 | const facedata *d = face_data (facenum, faceset); |
256 | const facedata *d = face_data (facenum, faceset); |
… | |
… | |
250 | { |
259 | { |
251 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
260 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
252 | return; |
261 | return; |
253 | } |
262 | } |
254 | |
263 | |
|
|
264 | if (faces_sent[facenum]) |
|
|
265 | return; |
|
|
266 | |
|
|
267 | faces_sent[facenum] = true; |
|
|
268 | |
255 | packet sl; |
269 | packet sl; |
256 | |
270 | |
257 | if (facecache && !forced) |
|
|
258 | { |
|
|
259 | if (faces_sent[facenum]) |
|
|
260 | return; |
|
|
261 | |
|
|
262 | faces_sent[facenum] = true; |
|
|
263 | |
|
|
264 | if (force_face0) |
271 | if (force_face0) |
265 | sl << "face " << uint16 (facenum); |
272 | sl << "face " << uint16 (facenum); |
266 | else if (image2) |
273 | else if (image2) |
267 | sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
274 | sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
268 | else |
275 | else |
269 | sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
276 | sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0); |
270 | |
277 | |
271 | // how lame |
278 | // how lame |
272 | print_facename (sl, *d); |
279 | print_facename (sl, *d); |
|
|
280 | send_packet (sl); |
|
|
281 | |
|
|
282 | faceinfo *f = face_info (facenum); |
|
|
283 | if (f->smooth && EMI_smooth) |
|
|
284 | { |
|
|
285 | send_face (f->smooth); |
|
|
286 | |
|
|
287 | packet sl ("smooth"); |
|
|
288 | |
|
|
289 | sl << uint16 (facenum) |
|
|
290 | << uint16 (f->smooth); |
|
|
291 | |
273 | send_packet (sl); |
292 | send_packet (sl); |
274 | |
|
|
275 | faceinfo *f = face_info (facenum); |
|
|
276 | if (f->smooth && EMI_smooth) |
|
|
277 | { |
|
|
278 | send_face (f->smooth); |
|
|
279 | |
|
|
280 | packet sl ("smooth"); |
|
|
281 | |
|
|
282 | sl << uint16 (facenum) |
|
|
283 | << uint16 (f->smooth); |
|
|
284 | |
|
|
285 | send_packet (sl); |
|
|
286 | } |
|
|
287 | } |
|
|
288 | else |
|
|
289 | { |
293 | } |
|
|
294 | } |
|
|
295 | |
|
|
296 | void |
|
|
297 | client::send_image (faceidx facenum) |
|
|
298 | { |
|
|
299 | // never send face 0. ever. it does not exist. |
|
|
300 | if (!facenum) |
|
|
301 | return; |
|
|
302 | |
|
|
303 | const facedata *d = face_data (facenum, faceset); |
|
|
304 | |
|
|
305 | if (!d) |
|
|
306 | { |
|
|
307 | LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); |
|
|
308 | return; |
|
|
309 | } |
|
|
310 | |
|
|
311 | packet sl; |
|
|
312 | |
290 | sl << (image2 ? "image2 " : "image ") |
313 | sl << (image2 ? "image2 " : "image ") |
291 | << uint32 (facenum); |
314 | << uint32 (facenum); |
292 | |
315 | |
293 | if (image2) |
316 | if (image2) |
294 | sl << uint8 (0); |
317 | sl << uint8 (0); |
295 | |
318 | |
296 | sl << uint32 (d->data.size ()) |
319 | sl << uint32 (d->data.size ()) |
297 | << data (d->data.data (), d->data.size ()); |
320 | << data (d->data.data (), d->data.size ()); |
298 | |
321 | |
299 | send_packet (sl); |
322 | send_packet (sl); |
300 | } |
|
|
301 | } |
323 | } |
302 | |
324 | |
303 | // send all faces of this object to the client |
325 | // send all faces of this object to the client |
304 | // this uses more bandwidth initially, but makes |
326 | // this uses more bandwidth initially, but makes |
305 | // animations look much smoother, and every client |
327 | // animations look much smoother, and every client |