84 if (strcmp(a->
name,
"bug.111") == 0) {
85 if (strcmp(b->
name,
"bug.111") == 0)
88 }
else if (strcmp(b->
name,
"bug.111") == 0)
130 if ((fp = fopen(buf,
"r")) == NULL) {
131 LOG(
llevError,
"faces: couldn't open file: %s\n", strerror(errno));
135 while (fgets(buf,
MAX_BUF, fp) != NULL) {
138 if (!strncmp(buf,
"end", 3)) {
140 }
else if (!strncmp(buf,
"face", 4)) {
144 cp[strlen(cp)-1] =
'\0';
146 if ((tmp =
find_face(cp, (
unsigned)-1)) == (
unsigned)-1) {
151 on_face = &new_faces[tmp];
153 }
else if (on_face == NULL) {
154 LOG(
llevError,
"faces: got line with no face set: %s\n", buf);
155 }
else if (!strncmp(buf,
"visibility", 10)) {
157 }
else if (!strncmp(buf,
"magicmap", 8)) {
159 cp[strlen(cp)-1] =
'\0';
161 }
else if (!strncmp(buf,
"is_floor", 8)) {
162 int value = atoi(buf+9);
188 if ((fp = fopen(buf,
"r")) == NULL) {
189 LOG(
llevError,
"bmaps: couldn't open: %s\n", strerror(errno));
196 while (fgets(buf,
MAX_BUF, fp) != NULL) {
197 if (buf[0] !=
'#' && buf[0] !=
'\n') {
205 if (new_faces == NULL) {
210 new_faces[i].
name = NULL;
217 while (i < nrofpixmaps && fgets(buf,
MAX_BUF, fp) != NULL) {
221 p = strrchr(buf,
'/');
222 if ((p == NULL) || (strtok(p,
" \t\n") == NULL)) {
243 for (l = 0; l < strlen(p); l++) {
253 if (i != nrofpixmaps) {
254 LOG(
llevError,
"read_bmap_names: first read gave %d faces but only loaded %d??\n", nrofpixmaps, i);
258 LOG(
llevDebug,
"bmaps: loaded %d faces\n", nrofpixmaps);
260 qsort(new_faces, nrofpixmaps,
sizeof(
New_Face), (
int (*)(
const void *,
const void *))
compare_face);
269 if (new_faces[i].magicmap == 255) {
309 return bp ? bp->
number : error;
326 unsigned regular, smoothed;
330 if ((fp = fopen(buf,
"r")) == NULL) {
331 LOG(
llevError,
"Cannot open smooth file: %s\n", strerror(errno));
335 while (fgets(buf,
MAX_BUF, fp) != NULL) {
339 if ((p = strchr(buf,
'\n')))
342 p = strchr(buf,
' ');
349 if (regular == (
unsigned)-1) {
355 if (smoothed == (
unsigned)-1) {
366 LOG(
llevDebug,
"smooth: loaded %d entries\n", nrofsmooth);
383 if (new_faces[face].smoothface == ((
uint16_t)-1))
400 free((
char*)(new_faces[i].name));
413 int fallback = facesets[faceset].
fallback;
419 if (!facesets[fallback].prefix) {
420 LOG(
llevError,
"Face set %d falls to non set faceset %d\n", faceset, fallback);
425 LOG(
llevError,
"Infinite loop found in facesets. aborting.\n");
451 char *cp, *cps[7+1], *slash;
456 memset(facesets, 0,
sizeof(facesets));
458 if ((infile = fopen(filename,
"r")) == NULL) {
462 while (fgets(buf,
HUGE_BUF-1, infile) != NULL) {
465 if (
split_string(buf, cps,
sizeof(cps)/
sizeof(*cps),
':') != 7)
466 LOG(
llevError,
"Bad line in image_info file, ignoring line:\n %s", buf);
475 facesets[len].
fallback = atoi(cps[3]);
483 if (facesets[i].prefix)
492 if (!facesets[fileno].prefix)
499 if ((infile = fopen(filename,
"rb")) == NULL) {
503 while (fgets(buf,
HUGE_BUF-1, infile) != NULL) {
504 if (strncmp(buf,
"IMAGE ", 6) != 0) {
505 LOG(
llevError,
"read_client_images:Bad image line - not IMAGE, instead\n%s", buf);
515 for ( ; *cp !=
' ' && *cp !=
'\n' && *cp !=
'\0'; cp++) {
520 LOG(
llevError,
"read_client_images: couldn't read name\n");
525 slash = strrchr(cp,
'/');
528 if (cp[strlen(cp) - 1] ==
'\n')
529 cp[strlen(cp) - 1] =
'\0';
533 if (num == (
unsigned)-1) {
534 LOG(
llevError,
"read_client_images: couldn't find picture %s\n", cp);
538 LOG(
llevError,
"read_client_images: invalid picture number %d for %s\n", num, cp);
543 facesets[fileno].
faces[num].
data = malloc(len);
544 if ((i = fread(facesets[fileno].faces[num].data, len, 1, infile)) != 1) {
545 LOG(
llevError,
"read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf);
549 for (i = 0; i < len; i++) {
577 if (facesets[num].prefix) {
579 free(facesets[num].faces[q].data);
580 free(facesets[num].prefix);
581 free(facesets[num].fullname);
582 free(facesets[num].size);
583 free(facesets[num].extension);
584 free(facesets[num].comment);
585 free(facesets[num].faces);
612 if (!facesets[faceset].prefix) {
613 LOG(
llevError,
"get_face_fallback called with unused set (%d)?\n", faceset);
616 if (facesets[faceset].faces[imageno].data)
void fatal(enum fatal_error err)
int is_valid_faceset(int fsn)
static void read_face_data(void)
static uint8_t find_color(const char *name)
int find_smooth(uint16_t face, uint16_t *smoothed)
void free_socket_images(void)
void read_client_images(void)
void free_all_images(void)
void read_bmap_names(void)
face_sets facesets[MAX_FACE_SETS]
static const char *const colorname[]
EXTERN int bmaps_checksum
size_t split_string(char *str, char *array[], size_t array_size, char sep)
void LOG(LogLevel logLevel, const char *format,...)
int get_face_fallback(int faceset, int imageno)
unsigned find_face(const char *name, unsigned error)
static int compare_face(const New_Face *a, const New_Face *b)
static void check_faceset_fallback(int faceset, int togo)