ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.23 by root, Sat Dec 23 16:05:19 2006 UTC vs.
Revision 1.25 by root, Sat Dec 30 10:16:10 2006 UTC

6#else 6#else
7# define is_constant(c) 0 7# define is_constant(c) 0
8#endif 8#endif
9 9
10#include <cstddef> 10#include <cstddef>
11#include <new>
12#include <vector>
11 13
12#include <glib.h> 14#include <glib.h>
15
16#include <shstr.h>
17#include <traits.h>
13 18
14// use a gcc extension for auto declarations until ISO C++ sanctifies them 19// use a gcc extension for auto declarations until ISO C++ sanctifies them
15#define AUTODECL(var,expr) typeof(expr) var = (expr) 20#define AUTODECL(var,expr) typeof(expr) var = (expr)
16 21
17// makes dynamically allocated objects zero-initialised 22// makes dynamically allocated objects zero-initialised
120 { 125 {
121 p->~Tp (); 126 p->~Tp ();
122 } 127 }
123}; 128};
124 129
125struct 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
134private:
135 static refcounted *rc_first;
136 refcounted *rc_next;
137#endif
138};
139
140template<class T> 130template<class T>
141struct refptr 131struct refptr
142{ 132{
143 T *p; 133 T *p;
144 134
166 T *operator ->() const { return p; } 156 T *operator ->() const { return p; }
167 157
168 operator T *() const { return p; } 158 operator T *() const { return p; }
169}; 159};
170 160
171typedef refptr<player> player_ptr; 161typedef refptr<maptile> maptile_ptr;
172typedef refptr<object> object_ptr; 162typedef refptr<object> object_ptr;
173typedef refptr<archetype> arch_ptr; 163typedef refptr<archetype> arch_ptr;
164typedef refptr<client> client_ptr;
165typedef refptr<player> player_ptr;
174 166
175struct str_hash 167struct str_hash
176{ 168{
177 std::size_t operator ()(const char *s) const 169 std::size_t operator ()(const char *s) const
178 { 170 {
204 { 196 {
205 return !strcmp (a, b); 197 return !strcmp (a, b);
206 } 198 }
207}; 199};
208 200
209#include <vector>
210
211template<class obj> 201template<class obj>
212struct unordered_vector : std::vector<obj, slice_allocator<obj> > 202struct unordered_vector : std::vector<obj, slice_allocator<obj> >
213{ 203{
214 typedef typename unordered_vector::iterator iterator; 204 typedef typename unordered_vector::iterator iterator;
215 205
246typedef double tstamp; 236typedef double tstamp;
247 237
248// return current time as timestampe 238// return current time as timestampe
249tstamp now (); 239tstamp now ();
250 240
241int similar_direction (int a, int b);
242
251#endif 243#endif
252 244

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines