… | |
… | |
244 | static vector objects; // not used yet, use first->next->... |
244 | static vector objects; // not used yet, use first->next->... |
245 | static object *first; // will be replaced by "objects" |
245 | static object *first; // will be replaced by "objects" |
246 | |
246 | |
247 | static object *create (); |
247 | static object *create (); |
248 | void copy_to (object *dst); |
248 | void copy_to (object *dst); |
|
|
249 | object *clone (); // create + copy_to |
249 | void destroy (bool destroy_inventory = false); |
250 | void destroy (bool destroy_inventory = false); |
250 | void remove (); |
251 | void remove (); |
251 | object *insert (object *item); // insert into inventory |
252 | object *insert (object *item); // insert into inventory |
252 | |
253 | |
253 | 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 |
254 | 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 | } |
255 | |
264 | |
256 | void clear (); |
265 | void clear (); |
257 | |
266 | |
258 | bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } |
267 | bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } |
|
|
268 | |
|
|
269 | void set_owner (object *owner); |
259 | |
270 | |
260 | void instantiate () |
271 | void instantiate () |
261 | { |
272 | { |
262 | if (!uuid.seq) // HACK |
273 | if (!uuid.seq) // HACK |
263 | uuid = gen_uuid (); |
274 | uuid = gen_uuid (); |
264 | |
275 | |
265 | attachable<object>::instantiate (); |
276 | attachable<object>::instantiate (); |
266 | } |
277 | } |
267 | |
|
|
268 | void set_owner (object *owner); |
|
|
269 | |
278 | |
270 | // info must hold 256 * 3 bytes currently |
279 | // info must hold 256 * 3 bytes currently |
271 | const char *debug_desc (char *info) const; |
280 | const char *debug_desc (char *info) const; |
272 | const char *debug_desc () const; |
281 | const char *debug_desc () const; |
273 | |
282 | |
… | |
… | |
313 | void unlink (); |
322 | void unlink (); |
314 | |
323 | |
315 | object (); |
324 | object (); |
316 | ~object (); |
325 | ~object (); |
317 | }; |
326 | }; |
318 | |
|
|
319 | // compatibility functions/macros |
|
|
320 | #define clear_owner(op) (op)->owner = 0 |
|
|
321 | #define copy_owner(op,other) (op)->owner = (other)->owner |
|
|
322 | #define get_owner(op) (op)->owner |
|
|
323 | #define clear_object(op) (op)->clear () |
|
|
324 | |
|
|
325 | static inline void |
|
|
326 | set_owner (object *op, object *owner) |
|
|
327 | { |
|
|
328 | op->set_owner (owner); |
|
|
329 | } |
|
|
330 | |
|
|
331 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
|
|
332 | |
327 | |
333 | typedef struct oblnk |
328 | typedef struct oblnk |
334 | { /* Used to link together several objects */ |
329 | { /* Used to link together several objects */ |
335 | object_ptr ob; |
330 | object_ptr ob; |
336 | struct oblnk *next; |
331 | struct oblnk *next; |