ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/image.C
(Generate patch)

Comparing deliantra/server/common/image.C (file contents):
Revision 1.10 by pippijn, Sat Jan 6 14:42:28 2007 UTC vs.
Revision 1.13 by root, Fri Jan 19 17:50:10 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) 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 *
8 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
9 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
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 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,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 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
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The maintainer of this code can be reached at <crossfire@schmorp.de> 22 * The maintainer of this code can be reached at <crossfire@schmorp.de>
23*/ 23 */
24 24
25 25
26#include <global.h> 26#include <global.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29New_Face *new_faces; 29facetile *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.
51static struct bmappair *xbm = NULL; 51static struct bmappair *xbm = NULL;
52 52
53/* Following can just as easily be pointers, but 53/* Following can just as easily be pointers, but
54 * it is easier to keep them like this. 54 * it is easier to keep them like this.
55 */ 55 */
56New_Face *blank_face, *dark_faces[3], *empty_face, *smooth_face; 56facetile *blank_face, *dark_faces[3], *empty_face, *smooth_face;
57 57
58 58
59/* nroffiles is the actual number of bitmaps defined. 59/* nroffiles is the actual number of bitmaps defined.
60 * nrofpixmaps is the number of bitmaps loaded. With 60 * nrofpixmaps is the number of bitmaps loaded. With
61 * the automatic generation of the bmaps file, this is now equal 61 * the automatic generation of the bmaps file, this is now equal
112static int 112static int
113compar (const struct bmappair *a, const struct bmappair *b) 113compar (const struct bmappair *a, const struct bmappair *b)
114{ 114{
115 return strcmp (a->name, b->name); 115 return strcmp (a->name, b->name);
116} 116}
117
117static int 118static int
118compar_smooth (const struct smoothing *a, const struct smoothing *b) 119compar_smooth (const struct smoothing *a, const struct smoothing *b)
119{ 120{
120 if (a->id < b->id) 121 if (a->id < b->id)
121 return -1; 122 return -1;
122 if (b->id < a->id) 123 if (b->id < a->id)
123 return 1; 124 return 1;
124 return 0; 125 return 0;
125} 126}
126 127
127
128/* 128/*
129 * Returns the matching color in the coloralias if found, 129 * Returns the matching color in the coloralias if found,
130 * 0 otherwise. Note that 0 will actually be black, so there is no 130 * 0 otherwise. Note that 0 will actually be black, so there is no
131 * way the calling function can tell if an error occurred or not 131 * way the calling function can tell if an error occurred or not
132 */ 132 */
133
134static uint8 133static uint8
135find_color (const char *name) 134find_color (const char *name)
136{ 135{
137 uint8 i; 136 uint8 i;
138 137
144} 143}
145 144
146/* This reads the lib/faces file, getting color and visibility information. 145/* This reads the lib/faces file, getting color and visibility information.
147 * it is called by ReadBmapNames. 146 * it is called by ReadBmapNames.
148 */ 147 */
149
150static void 148static void
151ReadFaceData (void) 149ReadFaceData (void)
152{ 150{
153 char buf[MAX_BUF], *cp; 151 char buf[MAX_BUF], *cp;
154 New_Face *on_face = NULL; 152 facetile *on_face = NULL;
155 FILE *fp; 153 FILE *fp;
156 154
157 sprintf (buf, "%s/faces", settings.datadir); 155 sprintf (buf, "%s/faces", settings.datadir);
158 LOG (llevDebug, "Reading faces from %s...\n", buf); 156 LOG (llevDebug, "Reading faces from %s...\n", buf);
159 if ((fp = fopen (buf, "r")) == NULL) 157 if ((fp = fopen (buf, "r")) == NULL)
217 on_face->magicmap |= FACE_FLOOR; 215 on_face->magicmap |= FACE_FLOOR;
218 } 216 }
219 else 217 else
220 LOG (llevDebug, "Got unknown line in faces file: %s\n", buf); 218 LOG (llevDebug, "Got unknown line in faces file: %s\n", buf);
221 } 219 }
220
222 LOG (llevDebug, "done\n"); 221 LOG (llevDebug, "done\n");
223 fclose (fp); 222 fclose (fp);
224} 223}
225 224
226/* This reads the bmaps file to get all the bitmap names and 225/* This reads the bmaps file to get all the bitmap names and
227 * stuff. It only needs to be done once, because it is player 226 * stuff. It only needs to be done once, because it is player
228 * independent (ie, what display the person is on will not make a 227 * independent (ie, what display the person is on will not make a
229 * difference.) 228 * difference.)
230 */ 229 */
231
232void 230void
233ReadBmapNames (void) 231ReadBmapNames (void)
234{ 232{
235 char buf[MAX_BUF], *p, *q; 233 char buf[MAX_BUF], *p, *q;
236 FILE *fp; 234 FILE *fp;
297 } 295 }
298 fclose (fp); 296 fclose (fp);
299 297
300 LOG (llevDebug, "done (got %d/%d/%d)\n", nrofpixmaps, nrofbmaps, nroffiles); 298 LOG (llevDebug, "done (got %d/%d/%d)\n", nrofpixmaps, nrofbmaps, nroffiles);
301 299
302 new_faces = new New_Face[nrofpixmaps]; 300 new_faces = new facetile[nrofpixmaps];
303 301
304 for (i = 0; i < nrofpixmaps; i++) 302 for (i = 0; i < nrofpixmaps; i++)
305 { 303 {
306 new_faces[i].name = ""; 304 new_faces[i].name = "";
307 new_faces[i].number = i; 305 new_faces[i].number = i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines