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.7 by root, Thu Dec 14 01:12:35 2006 UTC vs.
Revision 1.12 by root, Thu Dec 14 22:45:41 2006 UTC

229 if (len >= MAX_FACE_SETS) 229 if (len >= MAX_FACE_SETS)
230 { 230 {
231 LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS); 231 LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS);
232 abort (); 232 abort ();
233 } 233 }
234 facesets[len].prefix = strdup_local (cps[1]); 234 facesets[len].prefix = strdup (cps[1]);
235 facesets[len].fullname = strdup_local (cps[2]); 235 facesets[len].fullname = strdup (cps[2]);
236 facesets[len].fallback = atoi (cps[3]); 236 facesets[len].fallback = atoi (cps[3]);
237 facesets[len].size = strdup_local (cps[4]); 237 facesets[len].size = strdup (cps[4]);
238 facesets[len].extension = strdup_local (cps[5]); 238 facesets[len].extension = strdup (cps[5]);
239 facesets[len].comment = strdup_local (cps[6]); 239 facesets[len].comment = strdup (cps[6]);
240 } 240 }
241 } 241 }
242 close_and_delete (infile, compressed); 242 close_and_delete (infile, compressed);
243 for (i = 0; i < MAX_FACE_SETS; i++) 243 for (i = 0; i < MAX_FACE_SETS; i++)
244 { 244 {
312 * the caching attribute. 312 * the caching attribute.
313 * 313 *
314 */ 314 */
315 315
316void 316void
317SetFaceMode (char *buf, int len, NewSocket *ns) 317SetFaceMode (char *buf, int len, client_socket *ns)
318{ 318{
319 int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); 319 int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE);
320 320
321 if (mode == CF_FACE_NONE) 321 if (mode == CF_FACE_NONE)
322 ns->facecache = 1; 322 ns->facecache = 1;
323 else if (mode != CF_FACE_PNG) 323 else if (mode != CF_FACE_PNG)
324 { 324 {
325 SockList sl (MAXSOCKBUF); 325 packet sl;
326 sl.printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); 326 sl.printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png");
327 ns->send_packet (sl); 327 ns->send_packet (sl);
328 } 328 }
329 329
330 if (mask) 330 if (mask)
336 * This will be called often if the client is 336 * This will be called often if the client is
337 * caching images. 337 * caching images.
338 */ 338 */
339 339
340void 340void
341SendFaceCmd (char *buff, int len, NewSocket * ns) 341SendFaceCmd (char *buff, int len, client_socket * ns)
342{ 342{
343 long tmpnum = atoi (buff); 343 long tmpnum = atoi (buff);
344 short facenum = tmpnum & 0xffff; 344 short facenum = tmpnum & 0xffff;
345 345
346 if (facenum != 0) 346 if (facenum != 0)
355 * face (and askface is the only place that should be setting it). Otherwise, 355 * face (and askface is the only place that should be setting it). Otherwise,
356 * we look at the facecache, and if set, send the image name. 356 * we look at the facecache, and if set, send the image name.
357 */ 357 */
358 358
359void 359void
360esrv_send_face (NewSocket *ns, short face_num, int nocache) 360esrv_send_face (client_socket *ns, short face_num, int nocache)
361{ 361{
362 char fallback; 362 char fallback;
363 363
364 if (face_num <= 0 || face_num >= nrofpixmaps) 364 if (face_num <= 0 || face_num >= nrofpixmaps)
365 { 365 {
366 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); 366 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num);
367 return; 367 return;
368 } 368 }
369 369
370 SockList sl (MAXSOCKBUF); 370 packet sl;
371 fallback = get_face_fallback (ns->faceset, face_num); 371 fallback = get_face_fallback (ns->faceset, face_num);
372 372
373 if (facesets[fallback].faces[face_num].data == NULL) 373 if (facesets[fallback].faces[face_num].data == NULL)
374 { 374 {
375 LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num); 375 LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num);
385 sl << uint8 (fallback); 385 sl << uint8 (fallback);
386 386
387 sl << uint32 (facesets[fallback].faces[face_num].checksum) 387 sl << uint32 (facesets[fallback].faces[face_num].checksum)
388 << new_faces[face_num].name; 388 << new_faces[face_num].name;
389 389
390 Send_With_Handling (ns, &sl); 390 ns->send_packet (sl);
391 } 391 }
392 else 392 else
393 { 393 {
394 sl << (ns->image2 ? "image2 " : "image ") 394 sl << (ns->image2 ? "image2 " : "image ")
395 << uint32 (face_num); 395 << uint32 (face_num);
398 sl << uint8 (fallback); 398 sl << uint8 (fallback);
399 399
400 sl << uint32 (facesets[fallback].faces[face_num].datalen) 400 sl << uint32 (facesets[fallback].faces[face_num].datalen)
401 << data (facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen); 401 << data (facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen);
402 402
403 Send_With_Handling (ns, &sl); 403 ns->send_packet (sl);
404 } 404 }
405 405
406 ns->faces_sent[face_num] |= NS_FACESENT_FACE; 406 ns->faces_sent[face_num] |= NS_FACESENT_FACE;
407 sl.free ();
408} 407}
409 408
410/** 409/**
411 * Sends the number of images, checksum of the face file, 410 * Sends the number of images, checksum of the face file,
412 * and the image_info file information. See the doc/Developers/protocol 411 * and the image_info file information. See the doc/Developers/protocol
413 * if you want further detail. 412 * if you want further detail.
414 */ 413 */
415 414
416void 415void
417send_image_info (NewSocket * ns, char *params) 416send_image_info (client_socket * ns, char *params)
418{ 417{
419 SockList sl (MAXSOCKBUF); 418 packet sl;
420 419
421 sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); 420 sl.printf ("replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum);
422 421
423 for (int i = 0; i < MAX_FACE_SETS; i++) 422 for (int i = 0; i < MAX_FACE_SETS; i++)
424 if (facesets[i].prefix) 423 if (facesets[i].prefix)
425 sl.printf ("%d:%s:%s:%d:%s:%s:%s", 424 sl.printf ("%d:%s:%s:%d:%s:%s:%s",
426 i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback, 425 i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback,
427 facesets[i].size, facesets[i].extension, facesets[i].comment); 426 facesets[i].size, facesets[i].extension, facesets[i].comment);
428 427
429 Send_With_Handling (ns, &sl); 428 ns->send_packet (sl);
430 sl.free ();
431} 429}
432 430
433/** 431/**
434 * Sends requested face information. 432 * Sends requested face information.
435 * \param ns socket to send to 433 * \param ns socket to send to
438 * For each image in [start..stop] sends 436 * For each image in [start..stop] sends
439 * - checksum 437 * - checksum
440 * - name 438 * - name
441 */ 439 */
442void 440void
443send_image_sums (NewSocket * ns, char *params) 441send_image_sums (client_socket * ns, char *params)
444{ 442{
445 int start, stop; 443 int start, stop;
446 char *cp, buf[MAX_BUF]; 444 char *cp, buf[MAX_BUF];
447 445
448 SockList sl (MAXSOCKBUF); 446 packet sl;
449 447
450 start = atoi (params); 448 start = atoi (params);
451 for (cp = params; *cp != '\0'; cp++) 449 for (cp = params; *cp != '\0'; cp++)
452 if (*cp == ' ') 450 if (*cp == ' ')
453 break; 451 break;
478 /* It would make more sense to catch this pre-emptively in the code above. 476 /* It would make more sense to catch this pre-emptively in the code above.
479 * however, if this really happens, we probably just want to cut down the 477 * however, if this really happens, we probably just want to cut down the
480 * size to less than 1000, since that is what we claim the protocol would 478 * size to less than 1000, since that is what we claim the protocol would
481 * support. 479 * support.
482 */ 480 */
483 if (sl.len >= MAXSOCKBUF) 481 if (sl.length () >= MAXSOCKBUF)
484 { 482 {
485 LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.len, MAXSOCKBUF); 483 LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF);
486 abort (); 484 abort ();
487 } 485 }
488 486
489 Send_With_Handling (ns, &sl); 487 ns->send_packet (sl);
490 sl.free ();
491} 488}
492 489

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines