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.174 by root, Sun May 4 15:22:14 2008 UTC vs.
Revision 1.182 by root, Sat Sep 20 00:09:27 2008 UTC

175 arch_ptr ACC (RW, arch); /* Pointer to archetype */ 175 arch_ptr ACC (RW, arch); /* Pointer to archetype */
176 arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */ 176 arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */
177 177
178 float ACC (RW, speed); /* The overall speed of this object */ 178 float ACC (RW, speed); /* The overall speed of this object */
179 float ACC (RW, speed_left); /* How much speed is left to spend this round */ 179 float ACC (RW, speed_left); /* How much speed is left to spend this round */
180 uint32 ACC (RW, nrof); /* How many of the objects */ 180 sint32 ACC (RW, nrof); /* How many of the objects */
181 181
182 /* This next big block is basically used for monsters and equipment */ 182 /* This next big block is basically used for monsters and equipment */
183 uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */ 183 uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */
184 184
185 sint16 ACC (RW, resist[NROFATTACKS]); /* Resistance adjustments for attacks */ 185 sint16 ACC (RW, resist[NROFATTACKS]); /* Resistance adjustments for attacks */
260 bool ACC (RW, flag[NUM_FLAGS]); 260 bool ACC (RW, flag[NUM_FLAGS]);
261#endif 261#endif
262 uint16 ACC (RW, animation_id);/* An index into the animation array */ 262 uint16 ACC (RW, animation_id);/* An index into the animation array */
263 uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ 263 uint8 ACC (RW, anim_speed); /* ticks between animation-frames */
264 uint8 ACC (RW, last_anim); /* last sequence used to draw face */ 264 uint8 ACC (RW, last_anim); /* last sequence used to draw face */
265 sint16 ACC (RW, elevation); /* elevation of this terrain - not currently used */
266 uint8 ACC (RW, smoothlevel); /* how to smooth this square around */ 265 uint8 ACC (RW, smoothlevel); /* how to smooth this square around */
267 uint8 ACC (RW, will_apply); /* See crossfire.doc */ 266 uint8 ACC (RW, will_apply); /* See crossfire.doc */
267 uint16 ACC (RW, cached_sp); /* cached spell points used for a spell, used by esrv_update_spells */
268 uint16 ACC (RW, cached_grace);/* cached grace points used for a spell, used by esrv_update_spells */
269 uint16 ACC (RW, cached_eat); /* cached food, used by esrv_update_spells */
268}; 270};
269 271
270struct object : zero_initialised, object_copy 272struct object : zero_initialised, object_copy
271{ 273{
272 // These variables are not changed by ->copy_to 274 // These variables are not changed by ->copy_to
273 maptile_ptr ACC (RW, map); /* Pointer to the map in which this object is present */ 275 maptile *ACC (RW, map); /* Pointer to the map in which this object is present */
274 276
275 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. 277 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc.
276 int ACC (RO, count); 278 int ACC (RO, count);
277 object_vector_index ACC (RO, index); // index into objects 279 object_vector_index ACC (RO, index); // index into objects
278 object_vector_index ACC (RO, active); // index into actives 280 object_vector_index ACC (RO, active); // index into actives
465 /* This return true if object has still randomitems which 467 /* This return true if object has still randomitems which
466 * could be expanded. 468 * could be expanded.
467 */ 469 */
468 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } 470 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; }
469 471
472 MTH bool has_dialogue () const { return *&msg == '@'; }
473
470 // returns the outermost owner, never returns 0 474 // returns the outermost owner, never returns 0
471 MTH object *outer_owner () 475 MTH object *outer_owner ()
472 { 476 {
477 object *op;
478
473 for (object *op = this; ; op = op->owner) 479 for (op = this; op->owner; op = op->owner)
474 if (!op->owner) 480 ;
481
475 return op; 482 return op;
476 } 483 }
477 484
478 // returns the outermost environment, never returns 0 485 // returns the outermost environment, never returns 0
479 MTH object *outer_env () 486 MTH object *outer_env ()
480 { 487 {
488 object *op;
489
481 for (object *op = this; ; op = op->env) 490 for (op = this; op->env; op = op->env)
482 if (!op->env) 491 ;
492
483 return op; 493 return op;
484 } 494 }
485 495
486 // returns the player that has this object in his inventory, or 0 496 // returns the player that has this object in his inventory, or 0
487 // we assume the player is always the outer env 497 // we assume the player is always the outer env
488 MTH object *in_player () 498 MTH object *in_player ()
678 MTH static archetype *find (const_utf8_string name); 688 MTH static archetype *find (const_utf8_string name);
679 689
680 MTH void link (); 690 MTH void link ();
681 MTH void unlink (); 691 MTH void unlink ();
682 692
683 MTH static object *get (const char *name); // find()->instance() 693 MTH static object *get (const char *name); // (find() || singularity)->instance()
684 MTH object *instance (); 694 MTH object *instance ();
685 695
686 object_vector_index ACC (RW, archid); // index in archvector 696 object_vector_index ACC (RW, archid); // index in archvector
687 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ 697 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */
688 698
693 static archetype *read (object_thawer &f); 703 static archetype *read (object_thawer &f);
694 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more 704 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more
695 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ 705 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */
696}; 706};
697 707
708// compatbiility, remove once replaced by ->instance
709inline object *
710arch_to_object (archetype *at)
711{
712 return at->instance ();
713}
714
698inline void 715inline void
699object_freezer::put (keyword k, archetype *v) 716object_freezer::put (keyword k, archetype *v)
700{ 717{
701 put (k, v ? &v->archname : (const char *)0); 718 put (k, v ? &v->archname : (const char *)0);
702} 719}
707 724
708extern objectvec objects; 725extern objectvec objects;
709extern activevec actives; 726extern activevec actives;
710extern archvec archetypes; 727extern archvec archetypes;
711 728
729// "safely" iterate over inv in a way such that the current item is removable
730// quite horrible, thats why its hidden in some macro
731#define for_inv_removable(op,var) \
732 for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; )
733
712#define for_all_objects(var) \ 734#define for_all_objects(var) \
713 for (unsigned _i = 0; _i < objects.size (); ++_i) \ 735 for (unsigned _i = 0; _i < objects.size (); ++_i) \
714 statementvar (object *, var, objects [_i]) 736 statementvar (object *, var, objects [_i])
715 737
716#define for_all_actives(var) \ 738#define for_all_actives(var) \
717 for (unsigned _i = 0; _i < actives.size (); ++_i) \ 739 for (unsigned _i = 0; _i < actives.size (); ++_i) \
718 statementvar (object *, var, actives [_i]) 740 statementvar (object *, var, actives [_i])
719 741
720#define for_all_archetypes(var) \ 742#define for_all_archetypes(var) \
721 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ 743 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \
722 statementvar (archetype *, var, archetypes [_i]) 744 statementvar (archetype *, var, archetypes [_i])
723 745
724/* Used by update_object to know if the object being passed is 746/* Used by update_object to know if the object being passed is
725 * being added or removed. 747 * being added or removed.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines