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.5 by root, Sun Oct 8 16:51:51 2006 UTC vs.
Revision 1.19 by root, Thu Feb 15 18:09:34 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001 Mark Wedel 5 * Copyright (C) 2001 Mark Wedel
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The author can be reached via e-mail to <crossfire@schmorp.de> 22 * The author can be reached via e-mail to <crossfire@schmorp.de>
22*/ 23 */
23 24
24/** \file 25/** \file
25 * Image related communication 26 * Image related communication
26 * 27 *
27 * \date 2003-12-02 28 * \date 2003-12-02
33 */ 34 */
34 35
35#include <global.h> 36#include <global.h>
36#include <sproto.h> 37#include <sproto.h>
37 38
38#include <newclient.h>
39#include <newserver.h>
40#include <loader.h>
41
42#define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */ 39#define MAX_FACE_SETS 20 /**< Maximum number of image sets the program will handle */
43 40
44/** Information about one image */ 41/** Information about one image */
45typedef struct FaceInfo 42typedef struct FaceInfo
46{ 43{
47
48 uint8 *data; /**< image data */ 44 uint8 *data; /**< image data */
49
50 uint16 datalen; /**< length of the xpm data */ 45 uint16 datalen; /**< length of the xpm data */
51
52 uint32 checksum; /**< Checksum of face data */ 46 uint32 checksum; /**< Checksum of face data */
53} FaceInfo; 47} FaceInfo;
54 48
55/** Information about one face set */ 49/** Information about one face set */
56typedef struct 50typedef struct
57{ 51{
58
59 char *prefix; /**< */ 52 char *prefix; /**< */
60 char *fullname; 53 char *fullname;
61 54
62 uint8 fallback; /**< faceset to use when an image is not found in this faceset */ 55 uint8 fallback; /**< faceset to use when an image is not found in this faceset */
63 char *size; 56 char *size;
94 if (facesets[num].prefix) 87 if (facesets[num].prefix)
95 { 88 {
96 for (q = 0; q < nrofpixmaps; q++) 89 for (q = 0; q < nrofpixmaps; q++)
97 if (facesets[num].faces[q].data) 90 if (facesets[num].faces[q].data)
98 free (facesets[num].faces[q].data); 91 free (facesets[num].faces[q].data);
92
99 free (facesets[num].prefix); 93 free (facesets[num].prefix);
100 free (facesets[num].fullname); 94 free (facesets[num].fullname);
101 free (facesets[num].size); 95 free (facesets[num].size);
102 free (facesets[num].extension); 96 free (facesets[num].extension);
103 free (facesets[num].comment); 97 free (facesets[num].comment);
133 if (!facesets[faceset].prefix) 127 if (!facesets[faceset].prefix)
134 { 128 {
135 LOG (llevError, "get_face_fallback called with unused set (%d)?\n", faceset); 129 LOG (llevError, "get_face_fallback called with unused set (%d)?\n", faceset);
136 return 0; /* use default set */ 130 return 0; /* use default set */
137 } 131 }
132
138 if (facesets[faceset].faces[imageno].data) 133 if (facesets[faceset].faces[imageno].data)
139 return faceset; 134 return faceset;
135
140 return get_face_fallback (facesets[faceset].fallback, imageno); 136 return get_face_fallback (facesets[faceset].fallback, imageno);
141} 137}
142 138
143/** 139/**
144 * Checks fallback are correctly defined. 140 * Checks fallback are correctly defined.
160 if (!facesets[fallback].prefix) 156 if (!facesets[fallback].prefix)
161 { 157 {
162 LOG (llevError, "Face set %d falls to non set faceset %d\n", faceset, fallback); 158 LOG (llevError, "Face set %d falls to non set faceset %d\n", faceset, fallback);
163 abort (); 159 abort ();
164 } 160 }
161
165 togo--; 162 togo--;
166 if (togo == 0) 163 if (togo == 0)
167 { 164 {
168 LOG (llevError, "Infinite loop found in facesets. aborting.\n"); 165 LOG (llevError, "Infinite loop found in facesets. aborting.\n");
169 abort (); 166 abort ();
170 } 167 }
168
171 check_faceset_fallback (fallback, togo); 169 check_faceset_fallback (fallback, togo);
172} 170}
173 171
174#define MAX_IMAGE_SIZE 10000 172#define MAX_IMAGE_SIZE 10000
175 173
187 * Function largely rewritten May 2000 to be more general purpose. 185 * Function largely rewritten May 2000 to be more general purpose.
188 * The server itself does not care what the image data is - to the server, 186 * The server itself does not care what the image data is - to the server,
189 * it is just data it needs to allocate. As such, the code is written 187 * it is just data it needs to allocate. As such, the code is written
190 * to do such. 188 * to do such.
191 */ 189 */
192
193void 190void
194read_client_images (void) 191read_client_images (void)
195{ 192{
196 char filename[400]; 193 char filename[400];
197 char buf[HUGE_BUF]; 194 char buf[HUGE_BUF];
204 if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) 201 if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL)
205 { 202 {
206 LOG (llevError, "Unable to open %s\n", filename); 203 LOG (llevError, "Unable to open %s\n", filename);
207 abort (); 204 abort ();
208 } 205 }
206
209 while (fgets (buf, HUGE_BUF - 1, infile) != NULL) 207 while (fgets (buf, HUGE_BUF - 1, infile) != NULL)
210 { 208 {
211 badline = 0; 209 badline = 0;
212 210
213 if (buf[0] == '#') 211 if (buf[0] == '#')
214 continue; 212 continue;
213
215 if (!(cps[0] = strtok (buf, ":"))) 214 if (!(cps[0] = strtok (buf, ":")))
216 badline = 1; 215 badline = 1;
216
217 for (i = 1; i < 7; i++) 217 for (i = 1; i < 7; i++)
218 {
219 if (!(cps[i] = strtok (NULL, ":"))) 218 if (!(cps[i] = strtok (NULL, ":")))
220 badline = 1; 219 badline = 1;
221 } 220
222 if (badline) 221 if (badline)
223 {
224 LOG (llevError, "Bad line in image_info file, ignoring line:\n %s", buf); 222 LOG (llevError, "Bad line in image_info file, ignoring line:\n %s", buf);
225 }
226 else 223 else
227 { 224 {
228 len = atoi (cps[0]); 225 len = atoi (cps[0]);
229 if (len >= MAX_FACE_SETS) 226 if (len >= MAX_FACE_SETS)
230 { 227 {
231 LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS); 228 LOG (llevError, "To high a setnum in image_info file: %d > %d\n", len, MAX_FACE_SETS);
232 abort (); 229 abort ();
233 } 230 }
234 facesets[len].prefix = strdup_local (cps[1]); 231 facesets[len].prefix = strdup (cps[1]);
235 facesets[len].fullname = strdup_local (cps[2]); 232 facesets[len].fullname = strdup (cps[2]);
236 facesets[len].fallback = atoi (cps[3]); 233 facesets[len].fallback = atoi (cps[3]);
237 facesets[len].size = strdup_local (cps[4]); 234 facesets[len].size = strdup (cps[4]);
238 facesets[len].extension = strdup_local (cps[5]); 235 facesets[len].extension = strdup (cps[5]);
239 facesets[len].comment = strdup_local (cps[6]); 236 facesets[len].comment = strdup (cps[6]);
240 } 237 }
241 } 238 }
239
242 close_and_delete (infile, compressed); 240 close_and_delete (infile, compressed);
241
243 for (i = 0; i < MAX_FACE_SETS; i++) 242 for (i = 0; i < MAX_FACE_SETS; i++)
244 { 243 {
245 if (facesets[i].prefix) 244 if (facesets[i].prefix)
246 check_faceset_fallback (i, MAX_FACE_SETS); 245 check_faceset_fallback (i, MAX_FACE_SETS);
247 } 246 }
247
248 /* Loaded the faceset information - now need to load up the 248 /* Loaded the faceset information - now need to load up the
249 * actual faces. 249 * actual faces.
250 */ 250 */
251 251
252 for (fileno = 0; fileno < MAX_FACE_SETS; fileno++) 252 for (fileno = 0; fileno < MAX_FACE_SETS; fileno++)
253 { 253 {
254 /* if prefix is not set, this is not used */ 254 /* if prefix is not set, this is not used */
255 if (!facesets[fileno].prefix) 255 if (!facesets[fileno].prefix)
256 continue; 256 continue;
257
257 facesets[fileno].faces = (FaceInfo *) calloc (nrofpixmaps, sizeof (FaceInfo)); 258 facesets[fileno].faces = (FaceInfo *) calloc (nrofpixmaps, sizeof (FaceInfo));
258 259
259 sprintf (filename, "%s/crossfire.%d", settings.datadir, fileno); 260 sprintf (filename, "%s/crossfire.%d", settings.datadir, fileno);
260 LOG (llevDebug, "Loading image file %s\n", filename); 261 LOG (llevDebug, "Loading image file %s\n", filename);
261 262
262 if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL) 263 if ((infile = open_and_uncompress (filename, 0, &compressed)) == NULL)
263 { 264 {
264 LOG (llevError, "Unable to open %s\n", filename); 265 LOG (llevError, "Unable to open %s\n", filename);
265 abort (); 266 abort ();
266 } 267 }
268
267 while (fgets (buf, HUGE_BUF - 1, infile) != NULL) 269 while (fgets (buf, HUGE_BUF - 1, infile) != NULL)
268 { 270 {
269 if (strncmp (buf, "IMAGE ", 6) != 0) 271 if (strncmp (buf, "IMAGE ", 6) != 0)
270 { 272 {
271 LOG (llevError, "read_client_images:Bad image line - not IMAGE, instead\n%s", buf); 273 LOG (llevError, "read_client_images:Bad image line - not IMAGE, instead\n%s", buf);
272 abort (); 274 abort ();
273 } 275 }
276
274 num = atoi (buf + 6); 277 num = atoi (buf + 6);
275 if (num < 0 || num >= nrofpixmaps) 278 if (num < 0 || num >= nrofpixmaps)
276 { 279 {
277 LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf); 280 LOG (llevError, "read_client_images: Image num %d not in 0..%d\n%s", num, nrofpixmaps, buf);
278 abort (); 281 abort ();
279 } 282 }
283
280 /* Skip accross the number data */ 284 /* Skip accross the number data */
281 for (cp = buf + 6; *cp != ' '; cp++); 285 for (cp = buf + 6; *cp != ' '; cp++);
282 len = atoi (cp); 286 len = atoi (cp);
283 if (len == 0 || len > MAX_IMAGE_SIZE) 287 if (len == 0 || len > MAX_IMAGE_SIZE)
284 { 288 {
285 LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf); 289 LOG (llevError, "read_client_images: length not valid: %d > %d \n%s", len, MAX_IMAGE_SIZE, buf);
286 abort (); 290 abort ();
287 } 291 }
292
288 /* We don't actualy care about the name of the image that 293 /* We don't actualy care about the name of the image that
289 * is embedded in the image file, so just ignore it. 294 * is embedded in the image file, so just ignore it.
290 */ 295 */
291 facesets[fileno].faces[num].datalen = len; 296 facesets[fileno].faces[num].datalen = len;
292 facesets[fileno].faces[num].data = (uint8 *) malloc (len); 297 facesets[fileno].faces[num].data = (uint8 *) malloc (len);
293 if ((i = fread (facesets[fileno].faces[num].data, len, 1, infile)) != 1) 298 if ((i = fread (facesets[fileno].faces[num].data, len, 1, infile)) != 1)
294 { 299 {
295 LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf); 300 LOG (llevError, "read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf);
296 abort (); 301 abort ();
297 } 302 }
303
298 facesets[fileno].faces[num].checksum = 0; 304 facesets[fileno].faces[num].checksum = 0;
299 for (i = 0; i < len; i++) 305 for (i = 0; i < len; i++)
300 { 306 {
301 ROTATE_RIGHT (facesets[fileno].faces[num].checksum); 307 rotate_right (facesets[fileno].faces[num].checksum);
302 facesets[fileno].faces[num].checksum += facesets[fileno].faces[num].data[i]; 308 facesets[fileno].faces[num].checksum += facesets[fileno].faces[num].data[i];
303 facesets[fileno].faces[num].checksum &= 0xffffffff; 309 facesets[fileno].faces[num].checksum &= 0xffffffff;
304 } 310 }
305 } 311 }
312
306 close_and_delete (infile, compressed); 313 close_and_delete (infile, compressed);
307 } /* For fileno < MAX_FACE_SETS */ 314 } /* For fileno < MAX_FACE_SETS */
308} 315}
309 316
310/** 317/**
311 * Client tells us what type of faces it wants. Also sets 318 * Client tells us what type of faces it wants. Also sets
312 * the caching attribute. 319 * the caching attribute.
313 * 320 *
314 */ 321 */
315
316void 322void
317SetFaceMode (char *buf, int len, NewSocket * ns) 323SetFaceMode (char *buf, int len, client *ns)
318{ 324{
319 char tmp[256];
320
321 int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE); 325 int mask = (atoi (buf) & CF_FACE_CACHE), mode = (atoi (buf) & ~CF_FACE_CACHE);
322 326
323 if (mode == CF_FACE_NONE) 327 if (mode == CF_FACE_NONE)
324 {
325 ns->facecache = 1; 328 ns->facecache = 1;
326 }
327 else if (mode != CF_FACE_PNG) 329 else if (mode != CF_FACE_PNG)
328 {
329 sprintf (tmp, "drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png"); 330 ns->send_packet_printf ("drawinfo %d %s", NDI_RED, "Warning - send unsupported face mode. Will use Png");
330 Write_String_To_Socket (ns, tmp, strlen (tmp)); 331
331#ifdef ESRV_DEBUG
332 LOG (llevDebug, "SetFaceMode: Invalid mode from client: %d\n", mode);
333#endif
334 }
335 if (mask) 332 if (mask)
336 {
337 ns->facecache = 1; 333 ns->facecache = 1;
338 }
339} 334}
340 335
341/** 336/**
342 * Client has requested pixmap that it somehow missed getting. 337 * Client has requested pixmap that it somehow missed getting.
343 * This will be called often if the client is 338 * This will be called often if the client is
344 * caching images. 339 * caching images.
345 */ 340 */
346
347void 341void
348SendFaceCmd (char *buff, int len, NewSocket * ns) 342SendFaceCmd (char *buf, int len, client *ns)
349{ 343{
350 long tmpnum = atoi (buff); 344 uint16 facenum = atoi (buf);
351 short facenum = tmpnum & 0xffff;
352 345
353 if (facenum != 0) 346 if (facenum != 0)
354 esrv_send_face (ns, facenum, 1); 347 esrv_send_face (ns, facenum, 1);
355} 348}
356 349
360 * If nocache is true (nonzero), ignore the cache setting from the client - 353 * If nocache is true (nonzero), ignore the cache setting from the client -
361 * this is needed for the askface, in which we really do want to send the 354 * this is needed for the askface, in which we really do want to send the
362 * 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,
363 * 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.
364 */ 357 */
365
366void 358void
367esrv_send_face (NewSocket * ns, short face_num, int nocache) 359esrv_send_face (client *ns, short face_num, int nocache)
368{ 360{
369 SockList sl;
370 char fallback; 361 char fallback;
371 362
372 if (face_num <= 0 || face_num >= nrofpixmaps) 363 if (face_num <= 0 || face_num >= nrofpixmaps)
373 { 364 {
374 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); 365 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num);
375 return; 366 return;
376 } 367 }
377 368
378 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 369 packet sl;
379 fallback = get_face_fallback (ns->faceset, face_num); 370 fallback = get_face_fallback (ns->faceset, face_num);
380 371
381 if (facesets[fallback].faces[face_num].data == NULL) 372 if (facesets[fallback].faces[face_num].data == NULL)
382 { 373 {
383 LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num); 374 LOG (llevError, "esrv_send_face: faces[%d].data == NULL\n", face_num);
384 return; 375 return;
385 } 376 }
386 377
387 if (ns->facecache && !nocache) 378 if (ns->facecache && !nocache)
388 { 379 {
380 sl << (ns->image2 ? "face2 " : "face1 ")
381 << uint16 (face_num);
382
389 if (ns->image2) 383 if (ns->image2)
390 strcpy ((char *) sl.buf, "face2 "); 384 sl << uint8 (fallback);
391 else if (ns->sc_version >= 1026) 385
392 strcpy ((char *) sl.buf, "face1 "); 386 sl << uint32 (facesets[fallback].faces[face_num].checksum)
387 << new_faces[face_num].name;
388
389 ns->send_packet (sl);
390 }
393 else 391 else
394 strcpy ((char *) sl.buf, "face "); 392 {
393 sl << (ns->image2 ? "image2 " : "image ")
394 << uint32 (face_num);
395 395
396 sl.len = strlen ((const char *) sl.buf);
397 SockList_AddShort (&sl, face_num);
398 if (ns->image2) 396 if (ns->image2)
399 SockList_AddChar (&sl, fallback); 397 sl << uint8 (fallback);
400 if (ns->sc_version >= 1026) 398
401 SockList_AddInt (&sl, facesets[fallback].faces[face_num].checksum);
402 strcpy ((char *) sl.buf + sl.len, new_faces[face_num].name);
403 sl.len += strlen (new_faces[face_num].name);
404 Send_With_Handling (ns, &sl);
405 }
406 else
407 {
408 if (ns->image2)
409 strcpy ((char *) sl.buf, "image2 ");
410 else
411 strcpy ((char *) sl.buf, "image ");
412 sl.len = strlen ((char *) sl.buf);
413 SockList_AddInt (&sl, face_num);
414 if (ns->image2)
415 SockList_AddChar (&sl, fallback);
416 SockList_AddInt (&sl, facesets[fallback].faces[face_num].datalen); 399 sl << uint32 (facesets[fallback].faces[face_num].datalen)
417 memcpy (sl.buf + sl.len, facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen); 400 << data (facesets[fallback].faces[face_num].data, facesets[fallback].faces[face_num].datalen);
418 sl.len += facesets[fallback].faces[face_num].datalen; 401
419 Send_With_Handling (ns, &sl); 402 ns->send_packet (sl);
420 } 403 }
404
421 ns->faces_sent[face_num] |= NS_FACESENT_FACE; 405 ns->faces_sent[face_num] |= NS_FACESENT_FACE;
422 free (sl.buf);
423} 406}
424 407
425/** 408/**
426 * Sends the number of images, checksum of the face file, 409 * Sends the number of images, checksum of the face file,
427 * and the image_info file information. See the doc/Developers/protocol 410 * and the image_info file information. See the doc/Developers/protocol
428 * if you want further detail. 411 * if you want further detail.
429 */ 412 */
430 413
431void 414void
432send_image_info (NewSocket * ns, char *params) 415send_image_info (client *ns, char *params)
433{ 416{
434 SockList sl; 417 packet sl;
435 int i;
436 418
437 sl.buf = (unsigned char *) malloc (MAXSOCKBUF);
438
439 sprintf ((char *) sl.buf, "replyinfo image_info\n%d\n%d\n", nrofpixmaps - 1, bmaps_checksum); 419 sl.printf ("replyinfo image_info\n%d\n%u\n", nrofpixmaps - 1, (unsigned int)bmaps_checksum);
420
440 for (i = 0; i < MAX_FACE_SETS; i++) 421 for (int i = 0; i < MAX_FACE_SETS; i++)
441 {
442 if (facesets[i].prefix) 422 if (facesets[i].prefix)
443 { 423 sl.printf ("%d:%s:%s:%d:%s:%s:%s", i,
444 sprintf ((char *) sl.buf + strlen ((const char *) sl.buf), "%d:%s:%s:%d:%s:%s:%s",
445 i, facesets[i].prefix, facesets[i].fullname, facesets[i].fallback, 424 facesets[i].prefix, facesets[i].fullname , facesets[i].fallback,
446 facesets[i].size, facesets[i].extension, facesets[i].comment); 425 facesets[i].size , facesets[i].extension, facesets[i].comment);
447 } 426
448 } 427 ns->send_packet (sl);
449 sl.len = strlen ((const char *) sl.buf);
450 Send_With_Handling (ns, &sl);
451 free (sl.buf);
452} 428}
453 429
454/** 430/**
455 * Sends requested face information. 431 * Sends requested face information.
456 * \param ns socket to send to 432 * \param ns socket to send to
459 * For each image in [start..stop] sends 435 * For each image in [start..stop] sends
460 * - checksum 436 * - checksum
461 * - name 437 * - name
462 */ 438 */
463void 439void
464send_image_sums (NewSocket * ns, char *params) 440send_image_sums (client *ns, char *params)
465{ 441{
466 int start, stop; 442 int start, stop;
467 short i;
468 char qq;
469 char *cp, buf[MAX_BUF]; 443 char *cp, buf[MAX_BUF];
470 SockList sl;
471 444
472 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 445 packet sl;
473 446
474 start = atoi (params); 447 start = atoi (params);
475 for (cp = params; *cp != '\0'; cp++) 448 for (cp = params; *cp != '\0'; cp++)
476 if (*cp == ' ') 449 if (*cp == ' ')
477 break; 450 break;
478 451
479 stop = atoi (cp); 452 stop = atoi (cp);
480 if (stop < start || *cp == '\0' || (stop - start) > 1000 || stop >= nrofpixmaps) 453 if (stop < start || *cp == '\0' || (stop - start) > 1000 || stop >= nrofpixmaps)
481 { 454 {
482 sprintf (buf, "replyinfo image_sums %d %d", start, stop); 455 sl.printf ("replyinfo image_sums %d %d", start, stop);
483 cs_write_string (ns, buf, strlen (buf)); 456 ns->send_packet (sl);
457 sl.reset ();
484 return; 458 return;
485 } 459 }
460
486 sprintf ((char *) sl.buf, "replyinfo image_sums %d %d ", start, stop); 461 sl.printf ("replyinfo image_sums %d %d ", start, stop);
487 462
488 sl.len = strlen ((const char *) sl.buf);
489
490 for (i = start; i <= stop; i++) 463 for (int i = start; i <= stop; i++)
491 { 464 {
492 SockList_AddShort (&sl, i);
493 ns->faces_sent[i] |= NS_FACESENT_FACE; 465 ns->faces_sent[i] |= NS_FACESENT_FACE;
494 466
495 qq = get_face_fallback (ns->faceset, i); 467 int qq = get_face_fallback (ns->faceset, i);
468
469 sl << uint16 (i)
496 SockList_AddInt (&sl, facesets[qq].faces[i].checksum); 470 << uint32 (facesets[qq].faces[i].checksum)
497 SockList_AddChar (&sl, qq); 471 << uint8 (qq)
498 472 << data8 (&new_faces[i].name, new_faces[i].name.length () + 1);
499 qq = strlen (new_faces[i].name);
500 SockList_AddChar (&sl, (char) (qq + 1));
501 strcpy ((char *) sl.buf + sl.len, new_faces[i].name);
502 sl.len += qq;
503 SockList_AddChar (&sl, 0);
504 } 473 }
474
505 /* It would make more sense to catch this pre-emptively in the code above. 475 /* It would make more sense to catch this pre-emptively in the code above.
506 * however, if this really happens, we probably just want to cut down the 476 * however, if this really happens, we probably just want to cut down the
507 * size to less than 1000, since that is what we claim the protocol would 477 * size to less than 1000, since that is what we claim the protocol would
508 * support. 478 * support.
509 */ 479 */
510 if (sl.len >= MAXSOCKBUF) 480 if (sl.length () >= MAXSOCKBUF)
511 { 481 {
512 LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.len, MAXSOCKBUF); 482 LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF);
513 abort (); 483 abort ();
514 } 484 }
515 Send_With_Handling (ns, &sl); 485
516 free (sl.buf); 486 ns->send_packet (sl);
517} 487}
488

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines