ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/image.C
Revision: 1.29
Committed: Thu Nov 8 19:43:23 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_4, rel-2_5, rel-2_52, rel-2_53, rel-2_32, rel-2_43, rel-2_42, rel-2_41
Changes since 1.28: +4 -4 lines
Log Message:
update copyrights and other minor stuff to deliantra

File Contents

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