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.40 by root, Tue Jan 3 11:59:14 2012 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 (©) 2005,2006,2007,2008,2009 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.
24#include <stdio.h> 24#include <stdio.h>
25 25
26#include "face.h" 26#include "face.h"
27#include "crc.h" 27#include "crc.h"
28 28
29faceidx blank_face, empty_face; 29faceidx blank_face, empty_face, magicmouth_face;
30 30
31facehash_t facehash; 31facehash_t facehash;
32std::vector<faceinfo> faces; 32std::vector<faceinfo> faces;
33
34static std::vector<faceidx> faces_freelist;
35
36faceidx face_alloc ()
37{
38 faceidx idx;
39
40 if (!faces_freelist.empty ())
41 {
42 idx = faces_freelist.back ();
43 faces_freelist.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
58void
59faceinfo::unref ()
60{
61 if (--refcnt)
62 return;
63
64 refcnt = 1;
65
66}
33 67
34faceidx 68faceidx
35face_find (const char *name, faceidx defidx) 69face_find (const char *name, faceidx defidx)
36{ 70{
37 if (!name) 71 if (!name)
55} 89}
56 90
57facedata * 91facedata *
58faceinfo::data (int faceset) const 92faceinfo::data (int faceset) const
59{ 93{
60 return (facedata *)&(faceset && !type && data64.data.size () ? data64 : data32); 94 if (!face [faceset].data.size ())
95 faceset = 0;
96
97 return (facedata *)(face + faceset);
61} 98}
62 99
63facedata * 100facedata *
64face_data (faceidx idx, int faceset) 101face_data (faceidx idx, int faceset)
65{ 102{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines