ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/image.C
(Generate patch)

Comparing deliantra/server/common/image.C (file contents):
Revision 1.33 by root, Thu Nov 19 04:29:08 2009 UTC vs.
Revision 1.45 by root, Sat Nov 17 23:40:00 2018 UTC

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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 6 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 7 * 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 * 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 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 10 * option) any later version.
10 * 11 *
11 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 15 * GNU General Public License for more details.
15 * 16 *
16 * You should have received a copy of the Affero GNU General Public License 17 * 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 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 19 * <http://www.gnu.org/licenses/>.
19 * 20 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 22 */
22 23
23#include <global.h> 24#include <global.h>
24#include <stdio.h> 25#include <stdio.h>
25 26
26#include "face.h" 27#include "face.h"
27#include "crc.h" 28#include "crc.h"
28 29
29faceidx blank_face, empty_face; 30faceidx blank_face, empty_face, magicmouth_face;
30 31
31facehash_t facehash; 32facehash_t facehash;
32std::vector<faceinfo> faces; 33std::vector<faceinfo> faces;
34
35static std::vector<faceidx> faces_freelist;
36
37faceidx face_alloc ()
38{
39 faceidx idx;
40
41 if (!faces_freelist.empty ())
42 {
43 idx = faces_freelist.back ();
44 faces_freelist.pop_back ();
45 }
46 else
47 {
48 idx = faces.size ();
49
50 if (!idx) // skip index 0
51 idx = 1;
52
53 faces.resize (idx + 1);
54 }
55
56 return idx;
57}
58
59void
60faceinfo::unref ()
61{
62 if (--refcnt)
63 return;
64
65 refcnt = 1;
66
67}
33 68
34faceidx 69faceidx
35face_find (const char *name, faceidx defidx) 70face_find (const char *name, faceidx defidx)
36{ 71{
37 if (!name) 72 if (!name)
55} 90}
56 91
57facedata * 92facedata *
58faceinfo::data (int faceset) const 93faceinfo::data (int faceset) const
59{ 94{
60 return (facedata *)&(faceset && !type && data64.data.size () ? data64 : data32); 95 if (!face [faceset].chksum_len)
96 faceset = 0;
97
98 return (facedata *)(face + faceset);
61} 99}
62 100
63facedata * 101facedata *
64face_data (faceidx idx, int faceset) 102face_data (faceidx idx, int faceset)
65{ 103{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines