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.23 by root, Sat Sep 9 21:48:28 2006 UTC vs.
Revision 1.28 by root, Mon Sep 11 20:28:37 2006 UTC

62/* Definition for WILL_APPLY values. Replaces having harcoded values 62/* Definition for WILL_APPLY values. Replaces having harcoded values
63 * sprinkled in the code. Note that some of these also replace fields 63 * sprinkled in the code. Note that some of these also replace fields
64 * that were in the can_apply area. What is the point of having both 64 * that were in the can_apply area. What is the point of having both
65 * can_apply and will_apply? 65 * can_apply and will_apply?
66 */ 66 */
67#define WILL_APPLY_HANDLE 0x1 67#define WILL_APPLY_HANDLE 0x01
68#define WILL_APPLY_TREASURE 0x2 68#define WILL_APPLY_TREASURE 0x02
69#define WILL_APPLY_EARTHWALL 0x4 69#define WILL_APPLY_EARTHWALL 0x04
70#define WILL_APPLY_DOOR 0x8 70#define WILL_APPLY_DOOR 0x08
71#define WILL_APPLY_FOOD 0x10 71#define WILL_APPLY_FOOD 0x10
72 72
73 73
74/* However, if you're keeping a pointer of some sort, you probably 74/* However, if you're keeping a pointer of some sort, you probably
75 * don't just want it copied, so you'll need to add to common/object.C, 75 * don't just want it copied, so you'll need to add to common/object.C,
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 uint16 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 */
105 struct object *ACC (RW, head); /* Points to the main object of a large body */ 104 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 */ 105 struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */
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 */
151 uint32 ACC (RW, path_denied); /* Paths the object is denied access to */ 145 uint32 ACC (RW, path_denied); /* Paths the object is denied access to */
152 uint16 ACC (RW, material); /* What materials this object consist of */ 146 uint16 ACC (RW, material); /* What materials this object consist of */
153 sint8 ACC (RW, magic); /* Any magical bonuses to this item */ 147 sint8 ACC (RW, magic); /* Any magical bonuses to this item */
154 uint8 ACC (RW, state); /* How the object was last drawn (animation) */ 148 uint8 ACC (RW, state); /* How the object was last drawn (animation) */
155 sint32 ACC (RW, value); /* How much money it is worth (or contains) */ 149 sint32 ACC (RW, value); /* How much money it is worth (or contains) */
156 sint16 ACC (RW, level); /* Level of creature or object */
157 /* Note that the last_.. values are sometimes used for non obvious 150 /* Note that the last_.. values are sometimes used for non obvious
158 * meanings by some objects, eg, sp penalty, permanent exp. 151 * meanings by some objects, eg, sp penalty, permanent exp.
159 */ 152 */
160 sint32 ACC (RW, last_heal); /* Last healed. Depends on constitution */ 153 sint32 ACC (RW, last_heal); /* Last healed. Depends on constitution */
161 sint32 ACC (RW, last_sp); /* As last_heal, but for spell points */ 154 sint32 ACC (RW, last_sp); /* As last_heal, but for spell points */
162 sint16 ACC (RW, last_grace); /* as last_sp, except for grace */ 155 sint16 ACC (RW, last_grace); /* as last_sp, except for grace */
163 sint16 ACC (RW, last_eat); /* How long since we last ate */ 156 sint16 ACC (RW, last_eat); /* How long since we last ate */
164 sint16 ACC (RW, invisible); /* How much longer the object will be invis */ 157 sint16 ACC (RW, invisible); /* How much longer the object will be invis */
158 sint16 ACC (RW, level); /* Level of creature or object */
165 uint8 ACC (RW, pick_up); /* See crossfire.doc */ 159 uint8 ACC (RW, pick_up); /* See crossfire.doc */
166 sint8 ACC (RW, item_power); /* power rating of the object */ 160 sint8 ACC (RW, item_power); /* power rating of the object */
167 sint8 ACC (RW, gen_sp_armour); /* sp regen penalty this object has (was last_heal) */ 161 sint8 ACC (RW, gen_sp_armour); /* sp regen penalty this object has (was last_heal) */
162 sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */
168 sint32 ACC (RW, weight); /* Attributes of the object */ 163 sint32 ACC (RW, weight); /* Attributes of the object */
169 sint32 ACC (RW, weight_limit); /* Weight-limit of object */ 164 sint32 ACC (RW, weight_limit); /* Weight-limit of object */
170 sint32 ACC (RW, carrying); /* How much weight this object contains */ 165 sint32 ACC (RW, carrying); /* How much weight this object contains */
171 sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */
172 living ACC (RO, stats); /* Str, Con, Dex, etc */ 166 living ACC (RO, stats); /* Str, Con, Dex, etc */
173 sint64 ACC (RW, perm_exp); /* Permanent exp */ 167 sint64 ACC (RW, perm_exp); /* Permanent exp */
174 struct object *ACC (RW, current_weapon); /* Pointer to the weapon currently used */ 168 struct object *ACC (RW, current_weapon); /* Pointer to the weapon currently used */
175 uint32 ACC (RW, weapontype); /* type of weapon */ 169 uint32 ACC (RW, weapontype); /* type of weapon */
176 uint32 ACC (RW, tooltype); /* type of tool or build facility */ 170 uint32 ACC (RW, tooltype); /* type of tool or build facility */
177 sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ 171 sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */
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 */
173 uint8 ACC (RW, will_apply); /* See crossfire.doc */
179 /* See the doc/Developers/objects for more info about body locations */ 174 /* See the doc/Developers/objects for more info about body locations */
180 175
181 /* Following mostly refers to fields only used for monsters */ 176 /* Following mostly refers to fields only used for monsters */
182 struct object *ACC (RW, owner); /* Pointer to the object which controls this one */
183 /* Owner should not be referred to directly - */
184 /* get_owner should be used instead. */
185 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
186 /* has been freed) */
187 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 */
188 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 */
189 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 */
190 struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */ 181 struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */
191 uint16 ACC (RW, run_away); /* Monster runs away if it's hp goes below this percentage. */
192 struct object *ACC (RW, chosen_skill); /* the skill chosen to use */ 182 struct object *ACC (RW, chosen_skill); /* the skill chosen to use */
193 uint32 ACC (RW, hide); /* The object is hidden, not invisible */ 183 uint32 ACC (RW, hide); /* The object is hidden, not invisible */
194 /* changes made by kholland@sunlab.cit.cornell.edu */ 184 /* changes made by kholland@sunlab.cit.cornell.edu */
195 /* allows different movement patterns for attackers */ 185 /* allows different movement patterns for attackers */
196 sint32 ACC (RW, move_status); /* What stage in attack mode */ 186 sint32 ACC (RW, move_status); /* What stage in attack mode */
197 uint16 ACC (RW, attack_movement); /* What kind of attack movement */ 187 uint16 ACC (RW, attack_movement); /* What kind of attack movement */
198 uint8 ACC (RW, will_apply); /* See crossfire.doc */ 188 uint16 ACC (RW, run_away); /* Monster runs away if it's hp goes below this percentage. */
199 struct object *ACC (RW, spellitem); /* Spell ability monster is choosing to use */ 189 struct object *ACC (RW, spellitem); /* Spell ability monster is choosing to use */
200 double ACC (RW, expmul); /* needed experience = (calc_exp*expmul) - means some */ 190 float ACC (RW, expmul); /* needed experience = (calc_exp*expmul) - means some */
201 /* races/classes can need less/more exp to gain levels */ 191 /* races/classes can need less/more exp to gain levels */
202 192
203 /* Spell related information, may be useful elsewhere 193 /* Spell related information, may be useful elsewhere
204 * Note that other fields are used - these files are basically 194 * Note that other fields are used - these files are basically
205 * only used in spells. 195 * only used in spells.
206 */ 196 */
207 sint16 ACC (RW, duration); /* How long the spell lasts */ 197 sint16 ACC (RW, duration); /* How long the spell lasts */
198 sint16 ACC (RW, casting_time); /* time left before spell goes off */
199 uint16 ACC (RW, start_holding);
200 struct object *ACC (RW, spell); /* Spell that was being cast */
201 char *ACC (RW, spellarg);
208 uint8 ACC (RW, duration_modifier); /* how level modifies duration */ 202 uint8 ACC (RW, duration_modifier); /* how level modifies duration */
209 sint16 ACC (RW, casting_time); /* time left before spell goes off */
210 struct object *ACC (RW, spell); /* Spell that was being cast */
211 uint16 ACC (RW, start_holding);
212 char *ACC (RW, spellarg);
213 uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ 203 uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */
214 sint8 ACC (RW, range); /* Range of the spell */ 204 sint8 ACC (RW, range); /* Range of the spell */
215 uint8 ACC (RW, range_modifier); /* How going up in level effects range */ 205 uint8 ACC (RW, range_modifier); /* How going up in level effects range */
216 206
217 /* Following are values used by any object */ 207 /* Following are values used by any object */
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 void mortalise ();
247 264
248 static void free_mortals (); 265static inline void
249 static bool can_merge (object *op1, object *op2); 266set_owner (object *op, object *owner)
250 267{
251 void clear (); 268 op->set_owner (owner);
252 void clone (object *destination); 269}
253
254protected:
255 friend struct archetype;
256
257 object ();
258 ~object ();
259};
260 270
261#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)))
262 272
263typedef struct oblnk 273typedef struct oblnk
264{ /* Used to link together several objects */ 274{ /* Used to link together several objects */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines