ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/object.h
(Generate patch)

Comparing deliantra/server/include/object.h (file contents):
Revision 1.27 by root, Mon Sep 11 12:08:01 2006 UTC vs.
Revision 1.28 by root, Mon Sep 11 20:28:37 2006 UTC

76 * e.g. copy_object. 76 * e.g. copy_object.
77 */ 77 */
78 78
79// these are not being copied 79// these are not being copied
80ACC_CLASS (object) 80ACC_CLASS (object)
81struct object_keep 81struct object_keep : refcounted
82{ 82{
83 tag_t ACC (RW, count); /* Unique object number for this object */ 83 tag_t ACC (RW, count); /* Unique object number for this object */
84 sint32 ACC (RW, refcount); /* How many objects points to this object */
85 84
86 /* These variables are not changed by copy_object() */ 85 /* These variables are not changed by copy_object() */
87 struct pl *ACC (RW, contr); /* Pointer to the player which control this object */ 86 struct pl *ACC (RW, contr); /* Pointer to the player which control this object */
88 struct object *ACC (RW, next); /* Pointer to the next object in the free/used list */ 87 struct object *ACC (RW, next); /* Pointer to the next object in the free/used list */
89 struct object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ 88 struct object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */
107}; 106};
108 107
109// these are being copied 108// these are being copied
110struct object_copy : attachable<object> 109struct object_copy : attachable<object>
111{ 110{
112 /* These get an extra add_refcount(), after having been copied by memcpy(). 111 refptr<object> ACC (RW, owner); /* Pointer to the object which controls this one */
113 * All fields beow this point are automatically copied by memcpy. If
114 * adding something that needs a refcount updated, make sure you modify
115 * copy_object to do so. Everything below here also gets cleared
116 * by clear_object()
117 */
118 shstr ACC (RW, name); /* The name of the object, obviously... */ 112 shstr ACC (RW, name); /* The name of the object, obviously... */
119 shstr ACC (RW, name_pl); /* The plural name of the object */ 113 shstr ACC (RW, name_pl); /* The plural name of the object */
120 shstr ACC (RW, title); /* Of foo, etc */ 114 shstr ACC (RW, title); /* Of foo, etc */
121 shstr ACC (RW, race); /* human, goblin, dragon, etc */ 115 shstr ACC (RW, race); /* human, goblin, dragon, etc */
122 shstr ACC (RW, slaying); /* Which race to do double damage to */ 116 shstr ACC (RW, slaying); /* Which race to do double damage to */
178 sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ 172 sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */
179 uint8 ACC (RW, will_apply); /* See crossfire.doc */ 173 uint8 ACC (RW, will_apply); /* See crossfire.doc */
180 /* See the doc/Developers/objects for more info about body locations */ 174 /* See the doc/Developers/objects for more info about body locations */
181 175
182 /* Following mostly refers to fields only used for monsters */ 176 /* Following mostly refers to fields only used for monsters */
183 struct object *ACC (RW, owner); /* Pointer to the object which controls this one */
184 /* Owner should not be referred to directly - */
185 /* get_owner should be used instead. */
186 tag_t ACC (RW, ownercount); /* What count the owner had (in case owner */ 177 tag_t ACC (RW, ownercount); /* What count the owner had (in case owner has been freed) *///TODO: remove/fix
187 /* has been freed) */
188 struct object *ACC (RW, enemy); /* Monster/player to follow even if not closest */ 178 struct object *ACC (RW, enemy); /* Monster/player to follow even if not closest */
189 struct object *ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ 179 struct object *ACC (RW, attacked_by); /* This object start to attack us! only player & monster */
190 tag_t ACC (RW, attacked_by_count); /* the tag of attacker, so we can be sure */ 180 tag_t ACC (RW, attacked_by_count); /* the tag of attacker, so we can be sure */
191 struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */ 181 struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */
192 struct object *ACC (RW, chosen_skill); /* the skill chosen to use */ 182 struct object *ACC (RW, chosen_skill); /* the skill chosen to use */
233 MoveType ACC (RW, move_slow); /* Movement types this slows down */ 223 MoveType ACC (RW, move_slow); /* Movement types this slows down */
234 float ACC (RW, move_slow_penalty); /* How much this slows down the object */ 224 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. */ 225 key_value *key_values; /* Fields not explictly known by the loader. */
236}; 226};
237 227
228struct object : zero_initialised, object_keep, object_copy, object_pod
229{
230 static object *create ();
231 void free (bool free_inventory = false);
232
233 static void free_mortals ();
234 static bool can_merge (object *op1, object *op2);
235
236 void clear ();
237 void clone (object *destination);
238
239 void set_owner (object *owner);
240 object *get_owner ();
241
242protected:
243 friend struct archetype;
244
245 void link ();
246 void unlink ();
247
248 object ();
249 ~object ();
250};
251
238#define get_object() object::create () 252#define get_object() object::create ()
239#define free_object(op) (op)->free (0) 253#define free_object(op) (op)->free (0)
240#define free_object2(op, free_inv) (op)->free (free_inv) 254#define free_object2(op, free_inv) (op)->free (free_inv)
255#define clear_owner(op) (op)->owner = 0
256#define copy_owner(op,other) (op)->owner = (other)->owner
257#define clear_object(op) (op)->clear ()
241 258
242struct object : zero_initialised, object_keep, object_copy, object_pod 259static inline object *
260get_owner (object *op)
243{ 261{
244 static object *create (); 262 return op->get_owner ();
245 void free (bool free_inventory = false); 263}
246 264
247 static void free_mortals (); 265static inline void
248 static bool can_merge (object *op1, object *op2); 266set_owner (object *op, object *owner)
249 267{
250 void clear (); 268 op->set_owner (owner);
251 void clone (object *destination); 269}
252
253protected:
254 friend struct archetype;
255
256 void link ();
257 void unlink ();
258
259 object ();
260 ~object ();
261};
262 270
263#define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) 271#define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2)))
264 272
265typedef struct oblnk 273typedef struct oblnk
266{ /* Used to link together several objects */ 274{ /* Used to link together several objects */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines