… | |
… | |
63 | uint64 seq; |
63 | uint64 seq; |
64 | }; |
64 | }; |
65 | |
65 | |
66 | extern void init_uuid (); |
66 | extern void init_uuid (); |
67 | extern UUID gen_uuid (); |
67 | extern UUID gen_uuid (); |
|
|
68 | extern const uint64 UUID_SKIP; |
68 | |
69 | |
69 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
70 | /* Definition for WILL_APPLY values. Replaces having harcoded values |
70 | * sprinkled in the code. Note that some of these also replace fields |
71 | * sprinkled in the code. Note that some of these also replace fields |
71 | * that were in the can_apply area. What is the point of having both |
72 | * that were in the can_apply area. What is the point of having both |
72 | * can_apply and will_apply? |
73 | * can_apply and will_apply? |
… | |
… | |
81 | * don't just want it copied, so you'll need to add to common/object.C, |
82 | * don't just want it copied, so you'll need to add to common/object.C, |
82 | * e.g. copy_object. |
83 | * e.g. copy_object. |
83 | */ |
84 | */ |
84 | |
85 | |
85 | typedef refptr<object> object_ptr; |
86 | typedef refptr<object> object_ptr; |
|
|
87 | typedef refptr<archetype> arch_ptr; |
86 | |
88 | |
87 | // these are not being copied |
89 | // these are not being copied |
88 | ACC_CLASS (object) |
90 | ACC_CLASS (object) |
89 | struct object_keep : refcounted |
91 | struct object_keep : refcounted |
90 | { |
92 | { |
91 | tag_t ACC (RW, count); /* Generation count for this object */ |
93 | tag_t ACC (RW, count); /* Generation count for this object */ |
92 | UUID uuid; // Unique Identifier, survives saves etc. |
94 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
93 | |
95 | |
94 | /* These variables are not changed by copy_object() */ |
96 | /* These variables are not changed by copy_object() */ |
95 | player *ACC (RW, contr); /* Pointer to the player which control this object */ |
97 | player *ACC (RW, contr); /* Pointer to the player which control this object */ |
96 | object *ACC (RW, next); /* Pointer to the next object in the free/used list */ |
98 | object *ACC (RW, next); /* Pointer to the next object in the free/used list */ |
97 | object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ |
99 | object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ |
… | |
… | |
209 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
211 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
210 | char *ACC (RW, spellarg); |
212 | char *ACC (RW, spellarg); |
211 | |
213 | |
212 | /* Following are values used by any object */ |
214 | /* Following are values used by any object */ |
213 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
215 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
214 | archetype *ACC (RW, arch); /* Pointer to archetype */ |
216 | arch_ptr ACC (RW, arch); /* Pointer to archetype */ |
215 | archetype *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
217 | arch_ptr ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
216 | key_value *key_values; /* Fields not explictly known by the loader. */ |
218 | key_value *key_values; /* Fields not explictly known by the loader. */ |
217 | /* this objects turns into or what this object creates */ |
219 | /* this objects turns into or what this object creates */ |
218 | uint32 flags[4]; /* various flags */ |
220 | uint32 flags[4]; /* various flags */ |
219 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
221 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
220 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
222 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
… | |
… | |
240 | static vector active; // active objects, not yet used |
242 | static vector active; // active objects, not yet used |
241 | static vector objects; // not used yet, use first->next->... |
243 | static vector objects; // not used yet, use first->next->... |
242 | static object *first; // will be replaced by "objects" |
244 | static object *first; // will be replaced by "objects" |
243 | |
245 | |
244 | static object *create (); |
246 | static object *create (); |
245 | void free (bool free_inventory = false); |
247 | void destroy (bool destroy_inventory = false); |
246 | |
248 | |
247 | static void free_mortals (); |
249 | static void free_mortals (); |
248 | static bool can_merge (object *op1, object *op2); |
250 | static bool can_merge (object *op1, object *op2); |
249 | |
251 | |
250 | void clear (); |
252 | void clear (); |
… | |
… | |
310 | object (); |
312 | object (); |
311 | ~object (); |
313 | ~object (); |
312 | }; |
314 | }; |
313 | |
315 | |
314 | #define get_object() object::create () |
316 | #define get_object() object::create () |
315 | #define free_object(op) (op)->free (0) |
317 | #define free_object(op) (op)->destroy (0) |
316 | #define free_object2(op, free_inv) (op)->free (free_inv) |
318 | #define free_object2(op, free_inv) (op)->destroy (free_inv) |
317 | #define clear_owner(op) (op)->owner = 0 |
319 | #define clear_owner(op) (op)->owner = 0 |
318 | #define copy_owner(op,other) (op)->owner = (other)->owner |
320 | #define copy_owner(op,other) (op)->owner = (other)->owner |
319 | #define get_owner(op) (op)->owner |
321 | #define get_owner(op) (op)->owner |
320 | #define clear_object(op) (op)->clear () |
322 | #define clear_object(op) (op)->clear () |
321 | |
323 | |
… | |
… | |
327 | |
329 | |
328 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
330 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
329 | |
331 | |
330 | typedef struct oblnk |
332 | typedef struct oblnk |
331 | { /* Used to link together several objects */ |
333 | { /* Used to link together several objects */ |
332 | object *ob; |
334 | object_ptr ob; |
333 | struct oblnk *next; |
335 | struct oblnk *next; |
334 | tag_t id; |
|
|
335 | } objectlink; |
336 | } objectlink; |
336 | |
337 | |
337 | typedef struct oblinkpt |
338 | typedef struct oblinkpt |
338 | { /* Used to link together several object links */ |
339 | { /* Used to link together several object links */ |
339 | struct oblnk *link; |
340 | struct oblnk *link; |
… | |
… | |
348 | * be much left in the archetype - all it really is is a holder for the |
349 | * be much left in the archetype - all it really is is a holder for the |
349 | * object and pointers. This structure should get removed, and just replaced |
350 | * object and pointers. This structure should get removed, and just replaced |
350 | * by the object structure |
351 | * by the object structure |
351 | */ |
352 | */ |
352 | |
353 | |
353 | ACC_CLASS(archetype) |
354 | ACC_CLASS (archetype) |
354 | struct archetype : zero_initialised |
355 | struct archetype : zero_initialised, refcounted |
355 | { |
356 | { |
356 | archetype (); |
357 | archetype (); |
357 | ~archetype (); |
358 | ~archetype (); |
358 | |
359 | |
359 | static archetype *find (const char *arch); |
360 | static archetype *find (const char *arch); |
|
|
361 | |
|
|
362 | void hash_add (); // add to hastable |
|
|
363 | void hash_del (); // remove from hashtable |
360 | |
364 | |
361 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
365 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
362 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
366 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
363 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
367 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
364 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
368 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
… | |
… | |
426 | #define ARCH_DETECT_MAGIC "detect_magic" |
430 | #define ARCH_DETECT_MAGIC "detect_magic" |
427 | #define ARCH_DEPLETION "depletion" |
431 | #define ARCH_DEPLETION "depletion" |
428 | #define ARCH_SYMPTOM "symptom" |
432 | #define ARCH_SYMPTOM "symptom" |
429 | |
433 | |
430 | #endif |
434 | #endif |
|
|
435 | |