1 | /* |
1 | /* |
2 | * static char *rcsid_image_c = |
2 | * static char *rcsid_image_c = |
3 | * "$Id: image.c,v 1.1.1.1 2006/02/03 07:11:30 root Exp $"; |
3 | * "$Id: image.c,v 1.1.1.2 2006/02/22 18:01:18 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
105 | "brown", /* 10 */ |
105 | "brown", /* 10 */ |
106 | "yellow", /* 11 */ |
106 | "yellow", /* 11 */ |
107 | "khaki" /* 12 */ |
107 | "khaki" /* 12 */ |
108 | }; |
108 | }; |
109 | |
109 | |
110 | static int compar (struct bmappair *a, struct bmappair *b) { |
110 | static int compar (const struct bmappair *a, const struct bmappair *b) { |
111 | return strcmp (a->name, b->name); |
111 | return strcmp (a->name, b->name); |
112 | } |
112 | } |
113 | static int compar_smooth (struct smoothing *a, struct smoothing *b) { |
113 | static int compar_smooth (const struct smoothing *a, const struct smoothing *b) { |
114 | if (a->id<b->id) |
114 | if (a->id<b->id) |
115 | return -1; |
115 | return -1; |
116 | if (b->id<a->id) |
116 | if (b->id<a->id) |
117 | return 1; |
117 | return 1; |
118 | return 0; |
118 | return 0; |
… | |
… | |
317 | * you want some default face used, or can be set to negative |
317 | * you want some default face used, or can be set to negative |
318 | * so that it will be known that the face could not be found |
318 | * so that it will be known that the face could not be found |
319 | * (needed in client, so that it will know to request that image |
319 | * (needed in client, so that it will know to request that image |
320 | * from the server) |
320 | * from the server) |
321 | */ |
321 | */ |
322 | int FindFace (char *name, int error) { |
322 | int FindFace (const char *name, int error) { |
323 | struct bmappair *bp, tmp; |
323 | struct bmappair *bp, tmp; |
324 | char *p; |
324 | char *p; |
325 | |
325 | |
326 | if ((p = strchr (name, '\n'))) |
326 | if ((p = strchr (name, '\n'))) |
327 | *p = '\0'; |
327 | *p = '\0'; |
328 | |
328 | |
329 | tmp.name = name; |
329 | tmp.name = (char *)name; |
330 | bp = (struct bmappair *)bsearch |
330 | bp = (struct bmappair *)bsearch |
331 | (&tmp, xbm, nroffiles, sizeof(struct bmappair), (int (*)(const void*, const void*))compar); |
331 | (&tmp, xbm, nroffiles, sizeof(struct bmappair), (int (*)(const void*, const void*))compar); |
332 | |
332 | |
333 | return bp ? bp->number : error; |
333 | return bp ? bp->number : error; |
334 | } |
334 | } |