… | |
… | |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #ifndef FACE_H__ |
23 | #ifndef FACE_H__ |
24 | #define FACE_H__ |
24 | #define FACE_H__ |
25 | |
25 | |
26 | #include <string> |
26 | #include <util.h> |
27 | #include <tr1/unordered_map> |
27 | #include <tr1/unordered_map> |
28 | |
28 | |
29 | #define CHKSUM_MAXLEN 15 |
29 | #define CHKSUM_MAXLEN 15 |
30 | #define MAX_FACES 10000 // stupid gcfclient artificially limits |
30 | #define MAX_FACES 10000 // stupid gcfclient artificially limits |
31 | |
31 | |
… | |
… | |
33 | |
33 | |
34 | extern faceidx blank_face, empty_face, magicmouth_face; |
34 | extern faceidx blank_face, empty_face, magicmouth_face; |
35 | |
35 | |
36 | struct facedata |
36 | struct facedata |
37 | { |
37 | { |
38 | std::string data; |
38 | refcnt_buf data; // no need to be refcounted actually |
39 | uint8 chksum[CHKSUM_MAXLEN]; |
39 | uint8 chksum[CHKSUM_MAXLEN]; |
40 | uint8 chksum_len; |
40 | uint8 chksum_len; |
41 | |
41 | |
42 | facedata () |
42 | facedata () |
43 | : chksum_len (0) |
43 | : chksum_len (0) |
… | |
… | |
49 | * create a new face with that color. |
49 | * create a new face with that color. |
50 | */ |
50 | */ |
51 | struct faceinfo |
51 | struct faceinfo |
52 | { |
52 | { |
53 | faceinfo () |
53 | faceinfo () |
54 | : number (0), smooth (0), type (0), smoothlevel (0), visibility (0), magicmap (0) |
54 | : number (0), smooth (0), type (0), smoothlevel (0), visibility (0), magicmap (0), refcnt (1) |
55 | { |
55 | { |
56 | } |
56 | } |
57 | |
57 | |
58 | shstr name; |
58 | shstr name; |
59 | std::string meta; |
59 | std::string meta; |
… | |
… | |
65 | uint8 smoothlevel; // smoothlevel is per-face in 2.x servers |
65 | uint8 smoothlevel; // smoothlevel is per-face in 2.x servers |
66 | uint8 visibility; |
66 | uint8 visibility; |
67 | uint8 magicmap; /* Color to show this in magic map */ |
67 | uint8 magicmap; /* Color to show this in magic map */ |
68 | |
68 | |
69 | facedata *data (int faceset) const; |
69 | facedata *data (int faceset) const; |
|
|
70 | |
|
|
71 | int refcnt; // reference count - 1 |
|
|
72 | void ref () { ++refcnt; } |
|
|
73 | void unref (); |
70 | }; |
74 | }; |
71 | |
75 | |
72 | inline void |
76 | inline void |
73 | object_freezer::put (const keyword_string k, faceinfo *v) |
77 | object_freezer::put (const keyword_string k, faceinfo *v) |
74 | { |
78 | { |
… | |
… | |
92 | * If a face is not found, then defidx is returned. This can be useful |
96 | * If a face is not found, then defidx is returned. This can be useful |
93 | * if you want some default face used, or can be set to negative so that |
97 | * if you want some default face used, or can be set to negative so that |
94 | * it will be known that the face could not be found. |
98 | * it will be known that the face could not be found. |
95 | */ |
99 | */ |
96 | faceidx face_find (const char *name, faceidx defidx = 0); |
100 | faceidx face_find (const char *name, faceidx defidx = 0); |
|
|
101 | faceidx face_alloc (); |
97 | faceinfo *face_info (faceidx idx); |
102 | faceinfo *face_info (faceidx idx); |
98 | facedata *face_data (faceidx idx, int faceset); |
103 | facedata *face_data (faceidx idx, int faceset); |
99 | |
104 | |
100 | struct MapLook |
105 | struct MapLook |
101 | { |
106 | { |