1 | /* |
1 | /* |
2 | * static char *rcsid_object_h = |
2 | * static char *rcsid_object_h = |
3 | * "$Id: object.h,v 1.6 2006/08/26 08:44:06 root Exp $"; |
3 | * "$Id: object.h,v 1.7 2006/08/26 23:36:32 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
28 | |
28 | |
29 | #ifndef OBJECT_H |
29 | #ifndef OBJECT_H |
30 | #define OBJECT_H |
30 | #define OBJECT_H |
31 | |
31 | |
32 | #include "cfperl.h" |
32 | #include "cfperl.h" |
|
|
33 | #include "shstr.h" |
33 | |
34 | |
34 | typedef uint32 tag_t; |
35 | typedef uint32 tag_t; |
35 | #define NUM_BODY_LOCATIONS 12 |
36 | #define NUM_BODY_LOCATIONS 12 |
36 | #define BODY_ARMS 1 |
37 | #define BODY_ARMS 1 |
37 | |
38 | |
… | |
… | |
98 | * related ones, etc. |
99 | * related ones, etc. |
99 | * This structure is best viewed with about a 100 width screen. |
100 | * This structure is best viewed with about a 100 width screen. |
100 | * MSW 2002-07-05 |
101 | * MSW 2002-07-05 |
101 | */ |
102 | */ |
102 | |
103 | |
103 | struct object_simple { |
104 | struct object_simple : extendable<object> { |
|
|
105 | data_type get_dt () const { return DT_OBJECT; } |
|
|
106 | |
104 | /* These variables are not changed by copy_object() */ |
107 | /* These variables are not changed by copy_object() */ |
105 | struct pl *contr; /* Pointer to the player which control this object */ |
108 | struct pl *contr; /* Pointer to the player which control this object */ |
106 | struct object *next; /* Pointer to the next object in the free/used list */ |
109 | struct object *next; /* Pointer to the next object in the free/used list */ |
107 | struct object *prev; /* Pointer to the previous object in the free/used list*/ |
110 | struct object *prev; /* Pointer to the previous object in the free/used list*/ |
108 | struct object *active_next; /* Next & previous object in the 'active' */ |
111 | struct object *active_next; /* Next & previous object in the 'active' */ |
… | |
… | |
125 | |
128 | |
126 | tag_t count; /* Unique object number for this object */ |
129 | tag_t count; /* Unique object number for this object */ |
127 | uint16 refcount; /* How many objects points to this object */ |
130 | uint16 refcount; /* How many objects points to this object */ |
128 | }; |
131 | }; |
129 | |
132 | |
130 | struct object_special : extendable<object> { |
133 | struct object_special { |
131 | data_type get_dt () const { return DT_OBJECT; } |
|
|
132 | |
|
|
133 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
134 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
134 | * All fields beow this point are automatically copied by memcpy. If |
135 | * All fields beow this point are automatically copied by memcpy. If |
135 | * adding something that needs a refcount updated, make sure you modify |
136 | * adding something that needs a refcount updated, make sure you modify |
136 | * copy_object to do so. Everything below here also gets cleared |
137 | * copy_object to do so. Everything below here also gets cleared |
137 | * by clear_object() |
138 | * by clear_object() |
… | |
… | |
257 | const char *custom_name; /* Custom name assigned by player */ |
258 | const char *custom_name; /* Custom name assigned by player */ |
258 | key_value *key_values; /* Fields not explictly known by the loader. */ |
259 | key_value *key_values; /* Fields not explictly known by the loader. */ |
259 | }; |
260 | }; |
260 | |
261 | |
261 | struct object : object_special, object_simple { |
262 | struct object : object_special, object_simple { |
|
|
263 | void instantiate_ (); |
|
|
264 | void instantiate () |
|
|
265 | { |
|
|
266 | if (attach) |
|
|
267 | { |
|
|
268 | instantiate_ (); |
|
|
269 | free_string (attach); |
|
|
270 | attach = 0; |
|
|
271 | } |
|
|
272 | } |
|
|
273 | void clone (object *destination) |
|
|
274 | { |
|
|
275 | if (attach) |
|
|
276 | destination->attach = add_refcount (attach); |
|
|
277 | |
|
|
278 | if (self || cb) |
|
|
279 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); |
|
|
280 | } |
262 | }; |
281 | }; |
263 | |
282 | |
264 | typedef struct oblnk { /* Used to link together several objects */ |
283 | typedef struct oblnk { /* Used to link together several objects */ |
265 | object *ob; |
284 | object *ob; |
266 | struct oblnk *next; |
285 | struct oblnk *next; |