ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/image.C
(Generate patch)

Comparing deliantra/server/socket/image.C (file contents):
Revision 1.27 by root, Mon Mar 12 23:45:37 2007 UTC vs.
Revision 1.37 by root, Mon Mar 19 13:28:16 2007 UTC

198 * caching images. 198 * caching images.
199 */ 199 */
200void 200void
201SendFaceCmd (char *buf, int len, client *ns) 201SendFaceCmd (char *buf, int len, client *ns)
202{ 202{
203 uint16 facenum = atoi (buf); 203 ns->send_image (atoi (buf));
204
205 if (facenum != 0)
206 esrv_send_face (ns, facenum, 1);
207} 204}
208 205
209// how lame 206// how lame
210static void print_facename (packet &sl, const facedata &d) 207static void print_facename (packet &sl, const facedata &d)
211{ 208{
212 for (int i = 0; i < CHKSUM_SIZE; ++i) 209 for (int i = 0; i < CHKSUM_SIZE; ++i)
213 sl.printf ("%02x", d.chksum [i]); 210 sl.printf ("%02x", d.chksum [i]);
214} 211}
215 212
216// gcfclient uses the server-provided checksum for comparison, 213// gcfclient uses the server-provided checksum for comparison, but always
217// 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
218// have to provide gcfclient with a useless checksum just to 215// gcfclient with the same broken (and useless) checksum just to have it
219// have to cache the image despite its bugs. 216// cache the image despite its bugs.
220static uint32 gcfclient_checksum (const facedata *d) 217static uint32 gcfclient_checksum (const facedata *d)
221{ 218{
222 uint32 csum = 0; 219 uint32 csum = 0;
223 220
224 for (std::string::const_iterator i = d->data.begin (); 221 for (std::string::const_iterator i = d->data.begin ();
239 * 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
240 * 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,
241 * 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.
242 */ 239 */
243void 240void
244esrv_send_face (client *ns, short face_num, int nocache) 241client::send_face (faceidx facenum)
245{ 242{
246 if (face_num <= 0 || face_num >= faces.size ()) 243 // never send face 0. ever. it does not exist.
244 if (!facenum)
245 return;
246
247 const facedata *d = face_data (facenum, faceset);
248
249 if (!d)
247 { 250 {
248 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); 251 LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum);
249 return; 252 return;
250 } 253 }
251 254
252 const facedata *d = face_data (face_num, ns->faceset); 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 "*** To enable it, look at your client preferences and reconnect:\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 }
253 286
254 packet sl; 287 packet sl;
255 288
256 if (ns->facecache && !nocache)
257 {
258 if (ns->force_face0) 289 if (force_face0)
259 sl << "face " << uint16 (face_num); 290 sl << "face " << uint16 (facenum);
260 else if (ns->image2) 291 else if (image2)
261 sl << "face2 " << uint16 (face_num) << uint8 (0) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); 292 sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
262 else
263 sl << "face1 " << uint16 (face_num) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0);
264
265 // how lame
266 print_facename (sl, *d);
267
268 ns->send_packet (sl);
269 }
270 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);
271 { 311 }
312}
313
314void
315client::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
272 sl << (ns->image2 ? "image2 " : "image ") 336 sl << (image2 ? "image2 " : "image ")
273 << uint32 (face_num); 337 << uint32 (facenum);
274 338
275 if (ns->image2) 339 if (image2)
276 sl << uint8 (0); 340 sl << uint8 (0);
277 341
278 sl << uint32 (d->data.size ()) 342 sl << uint32 (d->data.size ())
279 << data (d->data.data (), d->data.size ()); 343 << data (d->data.data (), d->data.size ());
280 344
281 ns->send_packet (sl); 345 send_packet (sl);
346}
347
348// send all faces of this object to the client
349// this uses more bandwidth initially, but makes
350// animations look much smoother, and every client
351// is supposed to do client-side caching anyways.
352void
353client::send_faces (object *ob)
354{
355 send_face (ob->face);
356
357 if (ob->animation_id)
282 } 358 {
359 animation &anim = animations [ob->animation_id];
283 360
284 ns->faces_sent[face_num] |= NS_FACESENT_FACE; 361 for (int i = 0; i < anim.num_animations; i++)
362 send_face (anim.faces [i]);
363 }
364}
365
366/**
367 * Need to send an animation sequence to the client.
368 * We will send appropriate face commands to the client if we haven't
369 * sent them the face yet (this can become quite costly in terms of
370 * how much we are sending - on the other hand, this should only happen
371 * when the player logs in and picks stuff up.
372 */
373void
374client::send_animation (short anim_num)
375{
376 /* Do some checking on the anim_num we got. Note that the animations
377 * are added in contigous order, so if the number is in the valid
378 * range, it must be a valid animation.
379 */
380 if (anim_num < 0 || anim_num > num_animations)
381 {
382 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
383 return;
384 }
385
386 packet sl ("anim");
387
388 sl << uint16 (anim_num)
389 << uint16 (0); /* flags - not used right now */
390
391 /* Build up the list of faces. Also, send any information (ie, the
392 * the face itself) down to the client.
393 */
394 for (int i = 0; i < animations[anim_num].num_animations; i++)
395 {
396 send_face (animations[anim_num].faces[i]);
397 sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */
398 }
399
400 send_packet (sl);
401
402 anims_sent[anim_num] = 1;
285} 403}
286 404
287/** 405/**
288 * Sends the number of images, checksum of the face file, 406 * Sends the number of images, checksum of the face file,
289 * and the image_info file information. See the doc/Developers/protocol 407 * and the image_info file information. See the doc/Developers/protocol
290 * if you want further detail. 408 * if you want further detail.
291 */ 409 */
292
293void 410void
294send_image_info (client *ns, char *params) 411send_image_info (client *ns, char *params)
295{ 412{
296 packet sl; 413 packet sl;
297 414
336 453
337 sl.printf ("replyinfo image_sums %d %d ", start, stop); 454 sl.printf ("replyinfo image_sums %d %d ", start, stop);
338 455
339 for (int i = start; i <= stop && i < faces.size (); i++) 456 for (int i = start; i <= stop && i < faces.size (); i++)
340 { 457 {
341 ns->faces_sent[i] |= NS_FACESENT_FACE; 458 ns->faces_sent[i] = true;
342 459
343 const facedata *d = face_data (i, ns->faceset); 460 const facedata *d = face_data (i, ns->faceset);
344 461
345 if (sl.room () < 2 + 4 + 1 + d->data.size () + 1) 462 if (sl.room () < 2 + 4 + 1 + d->data.size () + 1)
346 break; 463 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines