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,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 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; |
34 | static std::vector<faceidx> faces_freelist; |
35 | |
35 | |
36 | faceidx face_alloc () |
36 | faceidx face_alloc () |
37 | { |
37 | { |
38 | faceidx idx; |
38 | faceidx idx; |
39 | |
39 | |
40 | if (faces_freelist.empty ()) |
40 | if (!faces_freelist.empty ()) |
41 | { |
41 | { |
42 | idx = faces_free.back (); |
42 | idx = faces_freelist.back (); |
43 | faces_free.pop_back (); |
43 | faces_freelist.pop_back (); |
44 | } |
44 | } |
45 | else |
45 | else |
46 | { |
46 | { |
47 | idx = faces.size (); |
47 | idx = faces.size (); |
48 | |
48 | |
… | |
… | |
53 | } |
53 | } |
54 | |
54 | |
55 | return idx; |
55 | return idx; |
56 | } |
56 | } |
57 | |
57 | |
|
|
58 | void |
58 | faceinfo::unref () |
59 | faceinfo::unref () |
59 | { |
60 | { |
60 | if (--refcnt) |
61 | if (--refcnt) |
61 | return; |
62 | return; |
62 | |
63 | |