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.60 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.64 by root, Sat Dec 23 06:21:02 2006 UTC

88/* However, if you're keeping a pointer of some sort, you probably 88/* However, if you're keeping a pointer of some sort, you probably
89 * don't just want it copied, so you'll need to add to common/object.C, 89 * don't just want it copied, so you'll need to add to common/object.C,
90 * e.g. ->copy_to () 90 * e.g. ->copy_to ()
91 */ 91 */
92 92
93typedef refptr<object> object_ptr;
94typedef refptr<archetype> arch_ptr;
95
96// these are not being copied 93// these are not being copied
97ACC_CLASS (object) 94ACC_CLASS (object)
98struct object_keep : refcounted 95struct object_keep : refcounted
99{ 96{
100 /* These variables are not changed by ->copy_to */ 97 /* These variables are not changed by ->copy_to */
101 98
102 tag_t ACC (RW, count); /* Generation count for this object */ 99 tag_t ACC (RW, count); /* Generation count for this object */
103 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. 100 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc.
104 101
105 player *ACC (RW, contr); /* Pointer to the player which control this object */ 102 player_ptr ACC (RW, contr); /* Pointer to the player which control this object */
106 object *ACC (RW, next); /* Pointer to the next object in the free/used list */ 103 object *ACC (RW, next); /* Pointer to the next object in the free/used list */
107 object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ 104 object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */
108 object *ACC (RW, active_next);/* Next & previous object in the 'active' */ 105 object *ACC (RW, active_next);/* Next & previous object in the 'active' */
109 object *ACC (RW, active_prev);/* List. This is used in process_events */ 106 object *ACC (RW, active_prev);/* List. This is used in process_events */
110 /* so that the entire object list does not */ 107 /* so that the entire object list does not */
145 object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ 142 object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */
146 object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ 143 object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */
147 object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ 144 object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */
148 object_ptr ACC (RW, spell); /* Spell that was being cast */ 145 object_ptr ACC (RW, spell); /* Spell that was being cast */
149 object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ 146 object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */
147 arch_ptr ACC (RW, arch); /* Pointer to archetype */
148 arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */
150}; 149};
151 150
152// these are being copied and also cleared 151// these are being copied and also cleared
153struct object_pod 152struct object_pod
154{ 153{
154 typedef bitset<NUM_FLAGS> flags_t;
155
155 New_Face *ACC (RW, face); /* Face with colors */ 156 New_Face *ACC (RW, face); /* Face with colors */
156 sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */ 157 sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */
157 float ACC (RW, speed); /* The overall speed of this object */ 158 float ACC (RW, speed); /* The overall speed of this object */
158 float ACC (RW, speed_left); /* How much speed is left to spend this round */ 159 float ACC (RW, speed_left); /* How much speed is left to spend this round */
159 uint32 ACC (RW, nrof); /* How many of the objects */ 160 uint32 ACC (RW, nrof); /* How many of the objects */
221 char *ACC (RW, spellarg); 222 char *ACC (RW, spellarg);
222 223
223 /* Following are values used by any object */ 224 /* Following are values used by any object */
224 /* this objects turns into or what this object creates */ 225 /* this objects turns into or what this object creates */
225 treasurelist *ACC (RW, randomitems); /* Items to be generated */ 226 treasurelist *ACC (RW, randomitems); /* Items to be generated */
226 arch_ptr ACC (RW, arch); /* Pointer to archetype */
227 arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */
228 key_value *key_values; /* Fields not explictly known by the loader. */ 227 key_value *key_values; /* Fields not explictly known by the loader. */
229 std::bitset<NUM_FLAGS> flags; /* various flags */ 228 object_pod::flags_t flags; /* various flags */
230 uint16 ACC (RW, animation_id);/* An index into the animation array */ 229 uint16 ACC (RW, animation_id);/* An index into the animation array */
231 uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ 230 uint8 ACC (RW, anim_speed); /* ticks between animation-frames */
232 uint8 ACC (RW, last_anim); /* last sequence used to draw face */ 231 uint8 ACC (RW, last_anim); /* last sequence used to draw face */
233 sint32 ACC (RW, elevation); /* elevation of this terrain - not currently used */ 232 sint32 ACC (RW, elevation); /* elevation of this terrain - not currently used */
234 uint8 ACC (RW, smoothlevel); /* how to smooth this square around */ 233 uint8 ACC (RW, smoothlevel); /* how to smooth this square around */
243 float ACC (RW, move_slow_penalty); /* How much this slows down the object */ 242 float ACC (RW, move_slow_penalty); /* How much this slows down the object */
244}; 243};
245 244
246struct object : zero_initialised, object_keep, object_copy, object_pod 245struct object : zero_initialised, object_keep, object_copy, object_pod
247{ 246{
247 typedef object_pod::flags_t flags_t;
248 typedef unordered_vector<object *> vector; 248 typedef unordered_vector<object *> vector;
249 249
250 static vector mortals; 250 static vector mortals;
251 static vector active; // active objects, not yet used 251 static vector active; // active objects, not yet used
252 static vector objects; // not used yet, use first->next->... 252 static vector objects; // not used yet, use first->next->...
268 return op1->value == op2->value 268 return op1->value == op2->value
269 && op1->name == op2->name 269 && op1->name == op2->name
270 && can_merge_slow (op1, op2); 270 && can_merge_slow (op1, op2);
271 } 271 }
272 272
273 void clear ();
274
275 bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } 273 bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); }
276 274
277 void set_owner (object *owner); 275 void set_owner (object *owner);
278 276
279 void instantiate () 277 void instantiate ()
281 if (!uuid.seq) // HACK 279 if (!uuid.seq) // HACK
282 uuid = gen_uuid (); 280 uuid = gen_uuid ();
283 281
284 attachable<object>::instantiate (); 282 attachable<object>::instantiate ();
285 } 283 }
284
285 // recalculate all stats
286 void update_stats ();
287 void roll_stats ();
288 void swap_stats (int a, int b);
289 void add_statbonus ();
290 void remove_statbonus ();
291 void drain_stat ();
292 void drain_specific_stat (int deplete_stats);
293 void change_luck (int value);
286 294
287 // info must hold 256 * 3 bytes currently 295 // info must hold 256 * 3 bytes currently
288 const char *debug_desc (char *info) const; 296 const char *debug_desc (char *info) const;
289 const char *debug_desc () const; 297 const char *debug_desc () const;
290 298
312 if (op->type == PLAYER) 320 if (op->type == PLAYER)
313 return op; 321 return op;
314 322
315 return 0; 323 return 0;
316 } 324 }
325
326 // returns the mapspace this object is in
327 mapspace &ms () const;
317 328
318 // fully recursive iterator 329 // fully recursive iterator
319 struct iterator_base 330 struct iterator_base
320 { 331 {
321 object *item; 332 object *item;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines