1 |
/* |
2 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
* |
4 |
* Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
* |
6 |
* Deliantra is free software: you can redistribute it and/or modify it under |
7 |
* the terms of the Affero GNU General Public License as published by the |
8 |
* Free Software Foundation, either version 3 of the License, or (at your |
9 |
* option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the Affero GNU General Public License |
17 |
* and the GNU General Public License along with this program. If not, see |
18 |
* <http://www.gnu.org/licenses/>. |
19 |
* |
20 |
* The authors can be reached via e-mail to <support@deliantra.net> |
21 |
*/ |
22 |
|
23 |
#include <global.h> |
24 |
#include <stdio.h> |
25 |
|
26 |
#include "face.h" |
27 |
#include "crc.h" |
28 |
|
29 |
faceidx blank_face, empty_face, magicmouth_face; |
30 |
|
31 |
facehash_t facehash; |
32 |
std::vector<faceinfo> faces; |
33 |
|
34 |
faceidx |
35 |
face_find (const char *name, faceidx defidx) |
36 |
{ |
37 |
if (!name) |
38 |
return defidx; |
39 |
|
40 |
facehash_t::iterator i = facehash.find (name); |
41 |
|
42 |
return i == facehash.end () |
43 |
? defidx : i->second; |
44 |
} |
45 |
|
46 |
faceinfo * |
47 |
face_info (faceidx idx) |
48 |
{ |
49 |
assert (0 < (faceidx)-1); // faceidx must be unsigned |
50 |
|
51 |
if (idx >= faces.size ()) |
52 |
return 0; |
53 |
|
54 |
return &faces [idx]; |
55 |
} |
56 |
|
57 |
facedata * |
58 |
faceinfo::data (int faceset) const |
59 |
{ |
60 |
if (!face [faceset].data.size ()) |
61 |
faceset = 0; |
62 |
|
63 |
return (facedata *)(face + faceset); |
64 |
} |
65 |
|
66 |
facedata * |
67 |
face_data (faceidx idx, int faceset) |
68 |
{ |
69 |
if (faceinfo *f = face_info (idx)) |
70 |
return f->data (faceset); |
71 |
|
72 |
return 0; |
73 |
} |
74 |
|