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.172 by root, Sat May 3 11:14:50 2008 UTC vs.
Revision 1.177 by root, Sat May 17 00:17:02 2008 UTC

338 338
339 MTH int slottype () const; 339 MTH int slottype () const;
340 MTH static object *create (); 340 MTH static object *create ();
341 const mapxy &operator =(const mapxy &pos); 341 const mapxy &operator =(const mapxy &pos);
342 MTH void copy_to (object *dst); 342 MTH void copy_to (object *dst);
343 MTH object *clone (); // create + copy_to 343 MTH object *clone (); // create + copy_to a single object
344 MTH object *deep_clone (); // copy whole more chain and inventory
344 void do_destroy (); 345 void do_destroy ();
345 void gather_callbacks (AV *&callbacks, event_type event) const; 346 void gather_callbacks (AV *&callbacks, event_type event) const;
346 MTH void destroy (bool destroy_inventory = false); 347 MTH void destroy (bool destroy_inventory = false);
347 348
348 // recursively destroy all objects in inventory, optionally dropping them to the ground instead 349 // recursively destroy all objects in inventory, optionally dropping them to the ground instead
536 // set the given flag on all objects in the inventory recursively 537 // set the given flag on all objects in the inventory recursively
537 MTH void set_flag_inv (int flag, int value = 1); 538 MTH void set_flag_inv (int flag, int value = 1);
538 539
539 void enter_exit (object *exit);//Perl 540 void enter_exit (object *exit);//Perl
540 MTH void enter_map (maptile *newmap, int x, int y); 541 MTH void enter_map (maptile *newmap, int x, int y);
542 void player_goto (const char *path, int x, int y); // only for players
541 543
542 // returns the mapspace this object is in 544 // returns the mapspace this object is in
543 mapspace &ms () const; 545 mapspace &ms () const;
544 546
545 // fully recursive iterator 547 // fully recursive iterator
676 MTH static archetype *find (const_utf8_string name); 678 MTH static archetype *find (const_utf8_string name);
677 679
678 MTH void link (); 680 MTH void link ();
679 MTH void unlink (); 681 MTH void unlink ();
680 682
681 MTH static object *get (const char *name); // find()->instance() 683 MTH static object *get (const char *name); // (find() || singularity)->instance()
682 MTH object *instance (); 684 MTH object *instance ();
683 685
684 object_vector_index ACC (RW, archid); // index in archvector 686 object_vector_index ACC (RW, archid); // index in archvector
685 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ 687 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */
686 688
691 static archetype *read (object_thawer &f); 693 static archetype *read (object_thawer &f);
692 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more 694 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more
693 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ 695 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */
694}; 696};
695 697
698// compatbiility, remove once replaced by ->instance
699inline object *
700arch_to_object (archetype *at)
701{
702 return at->instance ();
703}
704
696inline void 705inline void
697object_freezer::put (keyword k, archetype *v) 706object_freezer::put (keyword k, archetype *v)
698{ 707{
699 put (k, v ? &v->archname : (const char *)0); 708 put (k, v ? &v->archname : (const char *)0);
700} 709}
705 714
706extern objectvec objects; 715extern objectvec objects;
707extern activevec actives; 716extern activevec actives;
708extern archvec archetypes; 717extern archvec archetypes;
709 718
719// "safely" iterate over inv in a way such that the current item is removable
720// quite horrible, thats why its hidden in some macro
721#define for_inv_removable(op,var) \
722 for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; )
723
710#define for_all_objects(var) \ 724#define for_all_objects(var) \
711 for (unsigned _i = 0; _i < objects.size (); ++_i) \ 725 for (unsigned _i = 0; _i < objects.size (); ++_i) \
712 statementvar (object *, var, objects [_i]) 726 statementvar (object *, var, objects [_i])
713 727
714#define for_all_actives(var) \ 728#define for_all_actives(var) \
715 for (unsigned _i = 0; _i < actives.size (); ++_i) \ 729 for (unsigned _i = 0; _i < actives.size (); ++_i) \
716 statementvar (object *, var, actives [_i]) 730 statementvar (object *, var, actives [_i])
717 731
718#define for_all_archetypes(var) \ 732#define for_all_archetypes(var) \
719 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ 733 for (unsigned _i = 0; _i < archetypes.size (); ++_i) \
720 statementvar (archetype *, var, archetypes [_i]) 734 statementvar (archetype *, var, archetypes [_i])
721 735
722/* Used by update_object to know if the object being passed is 736/* Used by update_object to know if the object being passed is
723 * being added or removed. 737 * being added or removed.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines