… | |
… | |
250 | void destroy (bool destroy_inventory = false); |
250 | void destroy (bool destroy_inventory = false); |
251 | void remove (); |
251 | void remove (); |
252 | object *insert (object *item); // insert into inventory |
252 | object *insert (object *item); // insert into inventory |
253 | |
253 | |
254 | static void free_mortals (); |
254 | static void free_mortals (); |
|
|
255 | static bool can_merge_slow (object *op1, object *op2); |
|
|
256 | |
|
|
257 | // this is often used in time-critical code, so optimise |
255 | static bool can_merge (object *op1, object *op2); |
258 | static bool can_merge (object *op1, object *op2) |
|
|
259 | { |
|
|
260 | return op1->value != op2->value |
|
|
261 | && op1->name != op2->name |
|
|
262 | && can_merge_slow (op1, op2); |
|
|
263 | } |
256 | |
264 | |
257 | void clear (); |
265 | void clear (); |
258 | |
266 | |
259 | bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } |
267 | bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } |
|
|
268 | |
|
|
269 | void set_owner (object *owner); |
260 | |
270 | |
261 | void instantiate () |
271 | void instantiate () |
262 | { |
272 | { |
263 | if (!uuid.seq) // HACK |
273 | if (!uuid.seq) // HACK |
264 | uuid = gen_uuid (); |
274 | uuid = gen_uuid (); |
265 | |
275 | |
266 | attachable<object>::instantiate (); |
276 | attachable<object>::instantiate (); |
267 | } |
277 | } |
268 | |
|
|
269 | void set_owner (object *owner); |
|
|
270 | |
278 | |
271 | // info must hold 256 * 3 bytes currently |
279 | // info must hold 256 * 3 bytes currently |
272 | const char *debug_desc (char *info) const; |
280 | const char *debug_desc (char *info) const; |
273 | const char *debug_desc () const; |
281 | const char *debug_desc () const; |
274 | |
282 | |
… | |
… | |
314 | void unlink (); |
322 | void unlink (); |
315 | |
323 | |
316 | object (); |
324 | object (); |
317 | ~object (); |
325 | ~object (); |
318 | }; |
326 | }; |
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 | |
|
|
326 | static inline void |
|
|
327 | set_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 | |
327 | |
334 | typedef struct oblnk |
328 | typedef struct oblnk |
335 | { /* Used to link together several objects */ |
329 | { /* Used to link together several objects */ |
336 | object_ptr ob; |
330 | object_ptr ob; |
337 | struct oblnk *next; |
331 | struct oblnk *next; |