… | |
… | |
120 | { |
120 | { |
121 | p->~Tp (); |
121 | p->~Tp (); |
122 | } |
122 | } |
123 | }; |
123 | }; |
124 | |
124 | |
125 | struct refcounted |
|
|
126 | { |
|
|
127 | refcounted () : refcnt (0) { } |
|
|
128 | virtual ~refcounted (); |
|
|
129 | void refcnt_inc () { ++refcnt; } |
|
|
130 | void refcnt_dec () { --refcnt; } |
|
|
131 | bool dead () { return refcnt == 0; } |
|
|
132 | mutable int refcnt; |
|
|
133 | #if 0 |
|
|
134 | private: |
|
|
135 | static refcounted *rc_first; |
|
|
136 | refcounted *rc_next; |
|
|
137 | #endif |
|
|
138 | }; |
|
|
139 | |
|
|
140 | template<class T> |
125 | template<class T> |
141 | struct refptr |
126 | struct refptr |
142 | { |
127 | { |
143 | T *p; |
128 | T *p; |
144 | |
129 | |
… | |
… | |
166 | T *operator ->() const { return p; } |
151 | T *operator ->() const { return p; } |
167 | |
152 | |
168 | operator T *() const { return p; } |
153 | operator T *() const { return p; } |
169 | }; |
154 | }; |
170 | |
155 | |
171 | typedef refptr<player> player_ptr; |
156 | typedef refptr<maptile> maptile_ptr; |
172 | typedef refptr<object> object_ptr; |
157 | typedef refptr<object> object_ptr; |
173 | typedef refptr<archetype> arch_ptr; |
158 | typedef refptr<archetype> arch_ptr; |
|
|
159 | typedef refptr<client> client_ptr; |
|
|
160 | typedef refptr<player> player_ptr; |
174 | |
161 | |
175 | struct str_hash |
162 | struct str_hash |
176 | { |
163 | { |
177 | std::size_t operator ()(const char *s) const |
164 | std::size_t operator ()(const char *s) const |
178 | { |
165 | { |