… | |
… | |
105 | struct object *ACC (RW, head); /* Points to the main object of a large body */ |
105 | struct object *ACC (RW, head); /* Points to the main object of a large body */ |
106 | struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */ |
106 | struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */ |
107 | }; |
107 | }; |
108 | |
108 | |
109 | // these are being copied |
109 | // these are being copied |
110 | struct object_copy:attachable<object> |
110 | struct object_copy : attachable<object> |
111 | { |
111 | { |
112 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
112 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
113 | * All fields beow this point are automatically copied by memcpy. If |
113 | * All fields beow this point are automatically copied by memcpy. If |
114 | * adding something that needs a refcount updated, make sure you modify |
114 | * adding something that needs a refcount updated, make sure you modify |
115 | * copy_object to do so. Everything below here also gets cleared |
115 | * copy_object to do so. Everything below here also gets cleared |
… | |
… | |
213 | uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ |
213 | uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ |
214 | sint8 ACC (RW, range); /* Range of the spell */ |
214 | sint8 ACC (RW, range); /* Range of the spell */ |
215 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
215 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
216 | |
216 | |
217 | /* Following are values used by any object */ |
217 | /* Following are values used by any object */ |
218 | struct archt *ACC (RW, arch); /* Pointer to archetype */ |
218 | struct archetype *ACC (RW, arch); /* Pointer to archetype */ |
219 | struct archt *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
219 | struct archetype *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
220 | /* this objects turns into or what this object creates */ |
220 | /* this objects turns into or what this object creates */ |
221 | uint32 flags[4]; /* various flags */ |
221 | uint32 flags[4]; /* various flags */ |
222 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
222 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
223 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
223 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
224 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
224 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
… | |
… | |
233 | MoveType ACC (RW, move_slow); /* Movement types this slows down */ |
233 | MoveType ACC (RW, move_slow); /* Movement types this slows down */ |
234 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
234 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
235 | key_value *key_values; /* Fields not explictly known by the loader. */ |
235 | key_value *key_values; /* Fields not explictly known by the loader. */ |
236 | }; |
236 | }; |
237 | |
237 | |
|
|
238 | #define get_object() object::create () |
|
|
239 | #define free_object(op) (op)->free (0) |
|
|
240 | #define free_object2(op, free_inv) (op)->free (free_inv) |
|
|
241 | |
238 | struct object : zero_initialised, object_keep, object_copy, object_pod |
242 | struct object : zero_initialised, object_keep, object_copy, object_pod |
239 | { |
243 | { |
|
|
244 | static object *create (); |
|
|
245 | void free (bool free_inventory = false); |
|
|
246 | |
|
|
247 | static void free_mortals (); |
240 | static bool can_merge (object * op1, object * op2); |
248 | static bool can_merge (object *op1, object *op2); |
241 | |
249 | |
242 | void clear (); |
250 | void clear (); |
243 | void clone (object * destination); |
251 | void clone (object *destination); |
|
|
252 | |
|
|
253 | protected: |
|
|
254 | friend struct archetype; |
|
|
255 | |
|
|
256 | void link (); |
|
|
257 | void unlink (); |
|
|
258 | |
|
|
259 | object (); |
|
|
260 | ~object (); |
244 | }; |
261 | }; |
245 | |
262 | |
246 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
263 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
247 | |
264 | |
248 | typedef struct oblnk |
265 | typedef struct oblnk |
… | |
… | |
267 | * object and pointers. This structure should get removed, and just replaced |
284 | * object and pointers. This structure should get removed, and just replaced |
268 | * by the object structure |
285 | * by the object structure |
269 | */ |
286 | */ |
270 | |
287 | |
271 | ACC_CLASS(archetype) |
288 | ACC_CLASS(archetype) |
272 | struct archt : zero_initialised |
289 | struct archetype : zero_initialised |
273 | { |
290 | { |
|
|
291 | archetype (); |
|
|
292 | ~archetype (); |
|
|
293 | |
274 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
294 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
275 | struct archt *ACC (RW, next); /* Next archetype in a linked list */ |
295 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
276 | struct archt *ACC (RW, head); /* The main part of a linked object */ |
296 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
277 | struct archt *ACC (RW, more); /* Next part of a linked object */ |
297 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
278 | object ACC (RO, clone); /* An object from which to do copy_object() */ |
298 | object ACC (RO, clone); /* An object from which to do copy_object() */ |
279 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
299 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
280 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
300 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
281 | * in comparison to the head. |
301 | * in comparison to the head. |
282 | */ |
302 | */ |
283 | } archetype; |
303 | }; |
284 | |
304 | |
285 | extern object *objects; |
305 | extern object *objects; |
286 | extern object *active_objects; |
306 | extern object *active_objects; |
287 | |
307 | |
288 | extern int nrofallocobjects; |
308 | extern int nrofallocobjects; |