1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
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 |
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 |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
29 | faceidx blank_face, empty_face, magicmouth_face; |
29 | faceidx blank_face, empty_face, magicmouth_face; |
30 | |
30 | |
31 | facehash_t facehash; |
31 | facehash_t facehash; |
32 | std::vector<faceinfo> faces; |
32 | std::vector<faceinfo> faces; |
33 | |
33 | |
|
|
34 | static std::vector<faceidx> faces_free; |
|
|
35 | |
|
|
36 | faceidx face_alloc () |
|
|
37 | { |
|
|
38 | faceidx idx; |
|
|
39 | |
|
|
40 | if (faces_freelist.empty ()) |
|
|
41 | { |
|
|
42 | idx = faces_free.back (); |
|
|
43 | faces_free.pop_back (); |
|
|
44 | } |
|
|
45 | else |
|
|
46 | { |
|
|
47 | idx = faces.size (); |
|
|
48 | |
|
|
49 | if (!idx) // skip index 0 |
|
|
50 | idx = 1; |
|
|
51 | |
|
|
52 | faces.resize (idx + 1); |
|
|
53 | } |
|
|
54 | |
|
|
55 | return idx; |
|
|
56 | } |
|
|
57 | |
|
|
58 | faceinfo::unref () |
|
|
59 | { |
|
|
60 | if (--refcnt) |
|
|
61 | return; |
|
|
62 | |
|
|
63 | refcnt = 1; |
|
|
64 | |
|
|
65 | } |
|
|
66 | |
34 | faceidx |
67 | faceidx |
35 | face_find (const char *name, faceidx defidx) |
68 | face_find (const char *name, faceidx defidx) |
36 | { |
69 | { |
37 | if (!name) |
70 | if (!name) |
38 | return defidx; |
71 | return defidx; |
… | |
… | |
55 | } |
88 | } |
56 | |
89 | |
57 | facedata * |
90 | facedata * |
58 | faceinfo::data (int faceset) const |
91 | faceinfo::data (int faceset) const |
59 | { |
92 | { |
60 | return (facedata *)&(faceset && !type && data64.data.size () ? data64 : data32); |
93 | if (!face [faceset].data.size ()) |
|
|
94 | faceset = 0; |
|
|
95 | |
|
|
96 | return (facedata *)(face + faceset); |
61 | } |
97 | } |
62 | |
98 | |
63 | facedata * |
99 | facedata * |
64 | face_data (faceidx idx, int faceset) |
100 | face_data (faceidx idx, int faceset) |
65 | { |
101 | { |