148 if ((fp = fopen(buf,
"r")) == NULL) {
153 while (fgets(buf,
MAX_BUF, fp) != NULL) {
156 if (!strncmp(buf,
"end", 3)) {
158 }
else if (!strncmp(buf,
"face", 4)) {
162 cp[strlen(cp)-1] =
'\0';
164 if ((tmp =
find_face(cp, (
unsigned)-1)) == (
unsigned)-1) {
168 on_face = &new_faces[tmp];
170 }
else if (on_face == NULL) {
172 }
else if (!strncmp(buf,
"visibility", 10)) {
174 }
else if (!strncmp(buf,
"magicmap", 8)) {
176 cp[strlen(cp)-1] =
'\0';
178 }
else if (!strncmp(buf,
"is_floor", 8)) {
179 int value = atoi(buf+9);
183 LOG(
llevDebug,
"Got unknown line in faces file: %s\n", buf);
201 int value, nrofbmaps = 0, i;
207 if ((fp = fopen(buf,
"r")) == NULL) {
213 while (fgets(buf,
MAX_BUF, fp) != NULL)
214 if (buf[0] !=
'#' && buf[0] !=
'\n')
220 LOG(
llevError,
"read_bmap_names: xbm memory allocation failure.\n");
223 memset(xbm, 0,
sizeof(
struct bmappair)*nrofbmaps);
230 p = (*buf ==
'\\') ? (buf+1) : buf;
231 if (!(p = strtok(p,
" \t")) || !(q = strtok(NULL,
" \t\n"))) {
252 for (l = 0; l < strlen(q); l++) {
268 if (new_faces == NULL) {
269 LOG(
llevError,
"read_bmap_names: new_faces memory allocation failure.\n");
274 new_faces[i].
name =
"";
285 qsort(xbm, nroffiles,
sizeof(
struct bmappair), (
int (*)(
const void *,
const void *))
compar);
290 if (new_faces[i].magicmap == 255) {
328 if ((p = strchr(name,
'\n')))
331 tmp.
name = (
char *)name;
334 return bp ? bp->
number : error;
351 int regular, smoothed, nrofsmooth = 0;
355 if ((fp = fopen(buf,
"r")) == NULL) {
360 while (fgets(buf,
MAX_BUF, fp) != NULL) {
364 p = strchr(buf,
' ');
371 if (regular == (
unsigned)-1) {
377 if (smoothed == (
unsigned)-1) {
388 LOG(
llevDebug,
"done (got %d smooth entries)\n", nrofsmooth);
405 if (new_faces[face].smoothface == ((
uint16)-1))
436 int fallback = facesets[faceset].
fallback;
442 if (!facesets[fallback].prefix) {
443 LOG(
llevError,
"Face set %d falls to non set faceset %d\n", faceset, fallback);
448 LOG(
llevError,
"Infinite loop found in facesets. aborting.\n");
476 int num, len, compressed, fileno, i, badline;
478 memset(facesets, 0,
sizeof(facesets));
484 while (fgets(buf,
HUGE_BUF-1, infile) != NULL) {
489 if (!(cps[0] = strtok(buf,
":")))
491 for (i = 1; i < 7; i++) {
492 if (!(cps[i] = strtok(NULL,
":")))
496 LOG(
llevError,
"Bad line in image_info file, ignoring line:\n %s", buf);
505 facesets[len].
fallback = atoi(cps[3]);
513 if (facesets[i].prefix)
522 if (!facesets[fileno].prefix)
533 while (fgets(buf,
HUGE_BUF-1, infile) != NULL) {
534 if (strncmp(buf,
"IMAGE ", 6) != 0) {
535 LOG(
llevError,
"read_client_images:Bad image line - not IMAGE, instead\n%s", buf);
544 for (cp = buf+6; *cp !=
' '; cp++)
555 facesets[fileno].
faces[num].
data = malloc(len);
556 if ((i = fread(facesets[fileno].faces[num].data, len, 1, infile)) != 1) {
557 LOG(
llevError,
"read_client_images: Did not read desired amount of data, wanted %d, got %d\n%s", len, i, buf);
561 for (i = 0; i < len; i++) {
588 if (facesets[num].prefix) {
590 if (facesets[num].faces[q].data)
591 free(facesets[num].faces[q].data);
592 free(facesets[num].prefix);
593 free(facesets[num].fullname);
594 free(facesets[num].size);
595 free(facesets[num].extension);
596 free(facesets[num].comment);
597 free(facesets[num].faces);
624 if (!facesets[faceset].prefix) {
625 LOG(
llevError,
"get_face_fallback called with unused set (%d)?\n", faceset);
628 if (facesets[faceset].faces[imageno].data)
static int compar(const struct bmappair *a, const struct bmappair *b)
int find_smooth(uint16 face, uint16 *smoothed)
int is_valid_faceset(int fsn)
void close_and_delete(FILE *fp, int compressed)
static void read_face_data(void)
static struct bmappair * xbm
void free_socket_images(void)
static uint8 find_color(const char *name)
void read_client_images(void)
char * strdup_local(const char *str)
void free_all_images(void)
void read_bmap_names(void)
int snprintf(char *dest, int max, const char *format,...)
face_sets facesets[MAX_FACE_SETS]
static const char *const colorname[]
EXTERN int bmaps_checksum
void LOG(LogLevel logLevel, const char *format,...)
int get_face_fallback(int faceset, int imageno)
char * strerror_local(int errnum, char *buf, size_t size)
unsigned find_face(const char *name, unsigned error)
FILE * open_and_uncompress(const char *name, int flag, int *compressed)
static void check_faceset_fallback(int faceset, int togo)