… | |
… | |
79 | |
79 | |
80 | /* However, if you're keeping a pointer of some sort, you probably |
80 | /* However, if you're keeping a pointer of some sort, you probably |
81 | * don't just want it copied, so you'll need to add to common/object.C, |
81 | * don't just want it copied, so you'll need to add to common/object.C, |
82 | * e.g. copy_object. |
82 | * e.g. copy_object. |
83 | */ |
83 | */ |
|
|
84 | |
|
|
85 | typedef refptr<object> object_ptr; |
84 | |
86 | |
85 | // these are not being copied |
87 | // these are not being copied |
86 | ACC_CLASS (object) |
88 | ACC_CLASS (object) |
87 | struct object_keep : refcounted |
89 | struct object_keep : refcounted |
88 | { |
90 | { |
… | |
… | |
125 | shstr ACC (RW, msg); /* If this is a book/sign/magic mouth/etc */ |
127 | shstr ACC (RW, msg); /* If this is a book/sign/magic mouth/etc */ |
126 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
128 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
127 | /* To get put into books and the like. */ |
129 | /* To get put into books and the like. */ |
128 | shstr ACC (RW, materialname); /* specific material name */ |
130 | shstr ACC (RW, materialname); /* specific material name */ |
129 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
131 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
130 | refptr<object> ACC (RW, owner); /* Pointer to the object which controls this one */ |
132 | object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */ |
131 | refptr<object> ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
133 | object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
132 | refptr<object> ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
134 | object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
133 | refptr<object> ACC (RW, chosen_skill); /* the skill chosen to use */ |
135 | object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ |
134 | refptr<object> ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
136 | object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
135 | refptr<object> ACC (RW, spell); /* Spell that was being cast */ |
137 | object_ptr ACC (RW, spell); /* Spell that was being cast */ |
136 | refptr<object> ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
138 | object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
137 | }; |
139 | }; |
138 | |
140 | |
139 | // these are being copied and also cleared |
141 | // these are being copied and also cleared |
140 | struct object_pod |
142 | struct object_pod |
141 | { |
143 | { |
… | |
… | |
238 | static vector active; // active objects, not yet used |
240 | static vector active; // active objects, not yet used |
239 | static vector objects; // not used yet, use first->next->... |
241 | static vector objects; // not used yet, use first->next->... |
240 | static object *first; // will be replaced by "objects" |
242 | static object *first; // will be replaced by "objects" |
241 | |
243 | |
242 | static object *create (); |
244 | static object *create (); |
243 | void free (bool free_inventory = false); |
245 | void destroy (bool destroy_inventory = false); |
244 | |
246 | |
245 | static void free_mortals (); |
247 | static void free_mortals (); |
246 | static bool can_merge (object *op1, object *op2); |
248 | static bool can_merge (object *op1, object *op2); |
247 | |
249 | |
248 | void clear (); |
250 | void clear (); |
… | |
… | |
308 | object (); |
310 | object (); |
309 | ~object (); |
311 | ~object (); |
310 | }; |
312 | }; |
311 | |
313 | |
312 | #define get_object() object::create () |
314 | #define get_object() object::create () |
313 | #define free_object(op) (op)->free (0) |
315 | #define free_object(op) (op)->destroy (0) |
314 | #define free_object2(op, free_inv) (op)->free (free_inv) |
316 | #define free_object2(op, free_inv) (op)->destroy (free_inv) |
315 | #define clear_owner(op) (op)->owner = 0 |
317 | #define clear_owner(op) (op)->owner = 0 |
316 | #define copy_owner(op,other) (op)->owner = (other)->owner |
318 | #define copy_owner(op,other) (op)->owner = (other)->owner |
317 | #define get_owner(op) (op)->owner |
319 | #define get_owner(op) (op)->owner |
318 | #define clear_object(op) (op)->clear () |
320 | #define clear_object(op) (op)->clear () |
319 | |
321 | |