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

Comparing deliantra/server/include/object.h (file contents):
Revision 1.50 by root, Wed Dec 13 00:42:04 2006 UTC vs.
Revision 1.53 by root, Wed Dec 13 18:08:01 2006 UTC

59}; 59};
60 60
61struct UUID 61struct UUID
62{ 62{
63 uint64 seq; 63 uint64 seq;
64
65 UUID () { }
66 UUID (uint64 seq) : seq(seq) { }
67 operator uint64() { return seq; }
68 void operator =(uint64 seq) { this->seq = seq; }
64}; 69};
65 70
66extern void init_uuid (); 71extern void init_uuid ();
67extern UUID gen_uuid (); 72extern UUID gen_uuid ();
68extern const uint64 UUID_SKIP; 73extern const uint64 UUID_SKIP;
250 void destroy (bool destroy_inventory = false); 255 void destroy (bool destroy_inventory = false);
251 void remove (); 256 void remove ();
252 object *insert (object *item); // insert into inventory 257 object *insert (object *item); // insert into inventory
253 258
254 static void free_mortals (); 259 static void free_mortals ();
260 static bool can_merge_slow (object *op1, object *op2);
261
262 // this is often used in time-critical code, so optimise
255 static bool can_merge (object *op1, object *op2); 263 static bool can_merge (object *op1, object *op2)
264 {
265 return op1->value == op2->value
266 && op1->name == op2->name
267 && can_merge_slow (op1, op2);
268 }
256 269
257 void clear (); 270 void clear ();
258 271
259 bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } 272 bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); }
273
274 void set_owner (object *owner);
260 275
261 void instantiate () 276 void instantiate ()
262 { 277 {
263 if (!uuid.seq) // HACK 278 if (!uuid.seq) // HACK
264 uuid = gen_uuid (); 279 uuid = gen_uuid ();
265 280
266 attachable<object>::instantiate (); 281 attachable<object>::instantiate ();
267 } 282 }
268
269 void set_owner (object *owner);
270 283
271 // info must hold 256 * 3 bytes currently 284 // info must hold 256 * 3 bytes currently
272 const char *debug_desc (char *info) const; 285 const char *debug_desc (char *info) const;
273 const char *debug_desc () const; 286 const char *debug_desc () const;
274 287
314 void unlink (); 327 void unlink ();
315 328
316 object (); 329 object ();
317 ~object (); 330 ~object ();
318}; 331};
319
320// compatibility functions/macros
321#define clear_owner(op) (op)->owner = 0
322#define copy_owner(op,other) (op)->owner = (other)->owner
323#define get_owner(op) (op)->owner
324#define clear_object(op) (op)->clear ()
325
326static inline void
327set_owner (object *op, object *owner)
328{
329 op->set_owner (owner);
330}
331
332#define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2)))
333 332
334typedef struct oblnk 333typedef struct oblnk
335{ /* Used to link together several objects */ 334{ /* Used to link together several objects */
336 object_ptr ob; 335 object_ptr ob;
337 struct oblnk *next; 336 struct oblnk *next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines