--- deliantra/server/include/object.h 2006/12/12 21:39:56 1.49 +++ deliantra/server/include/object.h 2006/12/15 20:08:45 1.55 @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at crossfire@schmorp.de */ #ifndef OBJECT_H @@ -61,6 +61,11 @@ struct UUID { uint64 seq; + + UUID () { } + UUID (uint64 seq) : seq(seq) { } + operator uint64() { return seq; } + void operator =(uint64 seq) { this->seq = seq; } }; extern void init_uuid (); @@ -246,17 +251,28 @@ static object *create (); void copy_to (object *dst); + object *clone (); // create + copy_to void destroy (bool destroy_inventory = false); void remove (); object *insert (object *item); // insert into inventory static void free_mortals (); - static bool can_merge (object *op1, object *op2); + static bool can_merge_slow (object *op1, object *op2); + + // this is often used in time-critical code, so optimise + static bool can_merge (object *op1, object *op2) + { + return op1->value == op2->value + && op1->name == op2->name + && can_merge_slow (op1, op2); + } void clear (); bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } + void set_owner (object *owner); + void instantiate () { if (!uuid.seq) // HACK @@ -265,8 +281,6 @@ attachable::instantiate (); } - void set_owner (object *owner); - // info must hold 256 * 3 bytes currently const char *debug_desc (char *info) const; const char *debug_desc () const; @@ -316,20 +330,6 @@ ~object (); }; -// compatibility functions/macros -#define clear_owner(op) (op)->owner = 0 -#define copy_owner(op,other) (op)->owner = (other)->owner -#define get_owner(op) (op)->owner -#define clear_object(op) (op)->clear () - -static inline void -set_owner (object *op, object *owner) -{ - op->set_owner (owner); -} - -#define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) - typedef struct oblnk { /* Used to link together several objects */ object_ptr ob;