ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/image.C
Revision: 1.25
Committed: Sun Jul 1 04:08:14 2007 UTC (16 years, 10 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.24: +1 -1 lines
Log Message:
- support priority as second argument of askface
- send images of same priority in fifo order,
  but higher priorities first.

File Contents

# Content
1 /*
2 * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */
24
25 #include <global.h>
26 #include <stdio.h>
27
28 #include "face.h"
29 #include "crc.h"
30
31 faceidx blank_face, empty_face;
32
33 facehash_t facehash;
34 std::vector<faceinfo> faces;
35
36 /* the only thing this table is used for now is to
37 * translate the colorname in the magicmap field of the
38 * face into a numeric index that is then sent to the
39 * client for magic map commands. The order of this table
40 * must match that of the NDI colors in include/newclient.h.
41 */
42 static const char *const colorname[] = {
43 "black", /* 0 */
44 "white", /* 1 */
45 "blue", /* 2 */
46 "red", /* 3 */
47 "orange", /* 4 */
48 "light_blue", /* 5 */
49 "dark_orange", /* 6 */
50 "green", /* 7 */
51 "light_green", /* 8 */
52 "grey", /* 9 */
53 "brown", /* 10 */
54 "yellow", /* 11 */
55 "khaki" /* 12 */
56 };
57
58 /*
59 * Returns the matching color in the coloralias if found,
60 * 0 otherwise. Note that 0 will actually be black, so there is no
61 * way the calling function can tell if an error occurred or not
62 */
63 static uint8
64 find_color (const char *name)
65 {
66 uint8 i;
67
68 for (i = 0; i < sizeof (colorname) / sizeof (*colorname); i++)
69 if (!strcmp (name, colorname[i]))
70 return i;
71
72 LOG (llevError, "Unknown color: %s\n", name);
73 return 0;
74 }
75
76 faceidx
77 face_find (const char *name, faceidx defidx)
78 {
79 if (!name)
80 return defidx;
81
82 facehash_t::iterator i = facehash.find (name);
83
84 return i == facehash.end ()
85 ? defidx : i->second;
86 }
87
88 faceinfo *
89 face_info (faceidx idx)
90 {
91 assert (0 < (faceidx)-1); // faceidx must be unsigned
92
93 if (idx >= faces.size ())
94 return 0;
95
96 return &faces [idx];
97 }
98
99 facedata *
100 face_data (faceidx idx, int faceset)
101 {
102 if (faceinfo *f = face_info (idx))
103 return &(faceset && !f->type ? f->data64 : f->data32);
104
105 return 0;
106 }
107