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) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
24 | |
24 | |
25 | |
25 | |
26 | #include <global.h> |
26 | #include <global.h> |
27 | #include <stdio.h> |
27 | #include <stdio.h> |
28 | |
28 | |
29 | New_Face *new_faces; |
29 | facetile *new_faces; |
30 | |
30 | |
31 | /* bmappair and xbm are used when looking for the image id numbers |
31 | /* bmappair and xbm are used when looking for the image id numbers |
32 | * of a face by name. xbm is sorted alphabetically so that bsearch |
32 | * of a face by name. xbm is sorted alphabetically so that bsearch |
33 | * can be used to quickly find the entry for a name. the number is |
33 | * can be used to quickly find the entry for a name. the number is |
34 | * then an index into the new_faces array. |
34 | * then an index into the new_faces array. |
… | |
… | |
44 | { |
44 | { |
45 | char *name; |
45 | char *name; |
46 | unsigned int number; |
46 | unsigned int number; |
47 | }; |
47 | }; |
48 | |
48 | |
49 | void free (bmappair *); // guard to catch free when delete should be used |
|
|
50 | |
|
|
51 | static struct bmappair *xbm = NULL; |
49 | static struct bmappair *xbm = NULL; |
52 | |
50 | |
53 | /* Following can just as easily be pointers, but |
|
|
54 | * it is easier to keep them like this. |
|
|
55 | */ |
|
|
56 | New_Face *blank_face, *dark_faces[3], *empty_face, *smooth_face; |
51 | facetile *blank_face, *dark_faces[3], *empty_face, *smooth_face; |
57 | |
|
|
58 | |
52 | |
59 | /* nroffiles is the actual number of bitmaps defined. |
53 | /* nroffiles is the actual number of bitmaps defined. |
60 | * nrofpixmaps is the number of bitmaps loaded. With |
54 | * nrofpixmaps is the number of bitmaps loaded. With |
61 | * the automatic generation of the bmaps file, this is now equal |
55 | * the automatic generation of the bmaps file, this is now equal |
62 | * to nroffiles. |
56 | * to nroffiles. |
… | |
… | |
70 | int nrofpixmaps = 0; |
64 | int nrofpixmaps = 0; |
71 | |
65 | |
72 | /** |
66 | /** |
73 | * id is the face to smooth, smooth is the 16x2 face used to smooth id. |
67 | * id is the face to smooth, smooth is the 16x2 face used to smooth id. |
74 | */ |
68 | */ |
75 | struct smoothing:zero_initialised |
69 | struct smoothing : zero_initialised |
76 | { |
70 | { |
77 | uint16 id; |
71 | uint16 id; |
78 | uint16 smooth; |
72 | uint16 smooth; |
79 | }; |
73 | }; |
80 | |
|
|
81 | void free (smoothing *); // guard to catch free when delete should be used |
|
|
82 | |
74 | |
83 | /** |
75 | /** |
84 | * Contains all defined smoothing entries. smooth is an array of nrofsmooth |
76 | * Contains all defined smoothing entries. smooth is an array of nrofsmooth |
85 | * entries. It is sorted by smooth[].id. |
77 | * entries. It is sorted by smooth[].id. |
86 | */ |
78 | */ |
… | |
… | |
147 | */ |
139 | */ |
148 | static void |
140 | static void |
149 | ReadFaceData (void) |
141 | ReadFaceData (void) |
150 | { |
142 | { |
151 | char buf[MAX_BUF], *cp; |
143 | char buf[MAX_BUF], *cp; |
152 | New_Face *on_face = NULL; |
144 | facetile *on_face = NULL; |
153 | FILE *fp; |
145 | FILE *fp; |
154 | |
146 | |
155 | sprintf (buf, "%s/faces", settings.datadir); |
147 | sprintf (buf, "%s/faces", settings.datadir); |
156 | LOG (llevDebug, "Reading faces from %s...\n", buf); |
148 | LOG (llevDebug, "Reading faces from %s...\n", buf); |
157 | if ((fp = fopen (buf, "r")) == NULL) |
149 | if ((fp = fopen (buf, "r")) == NULL) |
… | |
… | |
295 | } |
287 | } |
296 | fclose (fp); |
288 | fclose (fp); |
297 | |
289 | |
298 | LOG (llevDebug, "done (got %d/%d/%d)\n", nrofpixmaps, nrofbmaps, nroffiles); |
290 | LOG (llevDebug, "done (got %d/%d/%d)\n", nrofpixmaps, nrofbmaps, nroffiles); |
299 | |
291 | |
300 | new_faces = new New_Face[nrofpixmaps]; |
292 | new_faces = new facetile[nrofpixmaps]; |
301 | |
293 | |
302 | for (i = 0; i < nrofpixmaps; i++) |
294 | for (i = 0; i < nrofpixmaps; i++) |
303 | { |
295 | { |
304 | new_faces[i].name = ""; |
296 | new_faces[i].name = ""; |
305 | new_faces[i].number = i; |
297 | new_faces[i].number = i; |