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.240 by root, Sun Apr 11 00:34:05 2010 UTC vs.
Revision 1.254 by root, Fri Jul 2 16:24:24 2010 UTC

61 const char *nonuse_name; /* Name to describe objects we can't use */ 61 const char *nonuse_name; /* Name to describe objects we can't use */
62} Body_Locations; 62} Body_Locations;
63 63
64extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; 64extern Body_Locations body_locations[NUM_BODY_LOCATIONS];
65 65
66// for each set of directions (1 == up, 2 == right, 4 == down, 8 == left)
67// contaisn the wall suffix (0, 1_3, 1_4 and so on).
68extern const char *wall_suffix[16];
69
66#define NUM_COINS 4 /* number of coin types */ 70#define NUM_COINS 4 /* number of coin types */
67extern const char *const coins[NUM_COINS + 1]; 71extern const char *const coins[NUM_COINS + 1];
72
73// restart server when object_count reaches this value
74#define RESTART_COUNT 0xe0000000
68 75
69/* 76/*
70 * Each object (this also means archetypes!) could have a few of these 77 * Each object (this also means archetypes!) could have a few of these
71 * "dangling" from it; this could also end up containing 'parse errors'. 78 * "dangling" from it; this could also end up containing 'parse errors'.
72 * 79 *
293sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags); 300sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags);
294int SP_level_dam_adjust (object *caster, object *spob); 301int SP_level_dam_adjust (object *caster, object *spob);
295int SP_level_duration_adjust (object *caster, object *spob); 302int SP_level_duration_adjust (object *caster, object *spob);
296int SP_level_range_adjust (object *caster, object *spob); 303int SP_level_range_adjust (object *caster, object *spob);
297 304
305struct freelist_item
306{
307 freelist_item *next;
308 uint32_t count;
309};
310
298struct object : zero_initialised, object_copy 311struct object : object_copy
299{ 312{
300 // These variables are not changed by ->copy_to 313 // These variables are not changed by ->copy_to
301 maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ 314 maptile *ACC (RW, map); /* Pointer to the map in which this object is present */
302 315
303 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. 316 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc.
304 int ACC (RO, count); 317 uint32_t ACC (RO, count);
305 object_vector_index ACC (RO, index); // index into objects 318 object_vector_index ACC (RO, index); // index into objects
306 object_vector_index ACC (RO, active); // index into actives 319 object_vector_index ACC (RO, active); // index into actives
307 320
308 player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */ 321 player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */
309 322
561 574
562 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; } 575 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; }
563 576
564 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } 577 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); }
565 578
579 /* need_identify returns true if the item should be identified. This
580 * function really should not exist - by default, any item not identified
581 * should need it.
582 */
583 MTH bool need_identify () const;
584
566 // returns the outermost owner, never returns 0 585 // returns the outermost owner, never returns 0
567 MTH object *outer_owner () 586 MTH object *outer_owner ()
568 { 587 {
569 object *op; 588 object *op;
570 589
637 MTH bool has_carried_lights () const 656 MTH bool has_carried_lights () const
638 { 657 {
639 return glow_radius; 658 return glow_radius;
640 } 659 }
641 660
642 // returns the player that cna see this object, if any 661 // returns the player that can see this object, if any
643 MTH object *visible_to () const; 662 MTH object *visible_to () const;
644 663
645 MTH std::string long_desc (object *who = 0); // query_name . " " . describe 664 MTH std::string long_desc (object *who = 0); // query_name . " " . describe
646 MTH std::string describe_monster (object *who = 0); 665 MTH std::string describe_monster (object *who = 0);
647 MTH std::string describe_item (object *who = 0); 666 MTH std::string describe_item (object *who = 0);
657 // objects. This method only works on objects not inserted 676 // objects. This method only works on objects not inserted
658 // anywhere. 677 // anywhere.
659 MTH void expand_tail (); 678 MTH void expand_tail ();
660 679
661 MTH void create_treasure (treasurelist *tl, int flags = 0); 680 MTH void create_treasure (treasurelist *tl, int flags = 0);
681
682 // makes sure the player has the named skill,
683 // and also makes it innate if can_use is true.
684 // returns the new skill or 0 if no such skill exists.
685 MTH object *give_skill (shstr_cmp name, bool can_use = false);
686 MTH void become_follower (object *new_god);
662 687
663 // insert object at same map position as 'where' 688 // insert object at same map position as 'where'
664 // handles both inventory and map "positions" 689 // handles both inventory and map "positions"
665 MTH object *insert_at (object *where, object *originator = 0, int flags = 0); 690 MTH object *insert_at (object *where, object *originator = 0, int flags = 0);
666 // check whether we can put this into the map, respect max_nrof, max_volume, max_items 691 // check whether we can put this into the map, respect max_nrof, max_volume, max_items
673 MTH void deactivate_recursive (); 698 MTH void deactivate_recursive ();
674 699
675 // set the given flag on all objects in the inventory recursively 700 // set the given flag on all objects in the inventory recursively
676 MTH void set_flag_inv (int flag, int value = 1); 701 MTH void set_flag_inv (int flag, int value = 1);
677 702
678 void enter_exit (object *exit);//Perl 703 void enter_exit (object *exit); // perl
679 MTH void enter_map (maptile *newmap, int x, int y); 704 MTH bool enter_map (maptile *newmap, int x, int y);
680 void player_goto (const_utf8_string path, int x, int y); // only for players 705 void player_goto (const_utf8_string path, int x, int y); // only for players
681 MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 706 MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0
707
708 MTH object *mark () const;
682 709
683 // returns the mapspace this object is in 710 // returns the mapspace this object is in
684 mapspace &ms () const; 711 mapspace &ms () const;
685 712
686 // fully recursive iterator 713 // fully recursive iterator
737 return weight + carrying; 764 return weight + carrying;
738 } 765 }
739 766
740 MTH struct region *region () const; 767 MTH struct region *region () const;
741 768
742 void statusmsg (const_utf8_string msg, int color = NDI_BLACK); 769 MTH void statusmsg (const_utf8_string msg, int color = NDI_BLACK);
743 void failmsg (const_utf8_string msg, int color = NDI_RED); 770 MTH void failmsg (const_utf8_string msg, int color = NDI_RED);
744 void failmsgf (const_utf8_string format, ...); // always NDI_RED... 771 void failmsgf (const_utf8_string format, ...); // always NDI_RED...
745 772
746 const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); 773 MTH const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = "");
747 774
748 MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference 775 MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference
749 static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible 776 static object *deref (const_octet_string ref); // returns the object from the generated reference, if possible
750 777
751 // make some noise with given item into direction dir, 778 // make some noise with given item into direction dir,
752 // currently only used for players to make them temporarily visible 779 // currently only used for players to make them temporarily visible
753 // when they are invisible. 780 // when they are invisible.
754 MTH void make_noise (); 781 MTH void make_noise ();
766 MTH int anim_frames () const { return anim ().num_animations; } 793 MTH int anim_frames () const { return anim ().num_animations; }
767 MTH int anim_facings () const { return anim ().facings; } 794 MTH int anim_facings () const { return anim ().facings; }
768 795
769 MTH utf8_string as_string (); 796 MTH utf8_string as_string ();
770 797
798 // low-level management, statistics, ...
799 static uint32_t ACC (RW, object_count);
800 static uint32_t ACC (RW, free_count);
801 static uint32_t ACC (RW, create_count);
802 static uint32_t ACC (RW, destroy_count);
803 static freelist_item *freelist;
804 MTH static void freelist_free (int count);
805
771protected: 806protected:
772 void link (); 807 void link ();
773 void unlink (); 808 void unlink ();
809
810 void do_delete ();
774 811
775 object (); 812 object ();
776 ~object (); 813 ~object ();
777 814
778private: 815private:
815 */ 852 */
816 853
817//-GPL 854//-GPL
818 855
819INTERFACE_CLASS (archetype) 856INTERFACE_CLASS (archetype)
820struct archetype : object 857struct archetype : object, zero_initialised
821{ 858{
822 static arch_ptr empty; // the empty_archetype 859 static arch_ptr empty; // the empty_archetype
823 MTH static void gc (); 860 MTH static void gc ();
824 861
825 archetype (const_utf8_string name); 862 archetype (const_utf8_string name);
843 880
844 // support for archetype loading 881 // support for archetype loading
845 static archetype *read (object_thawer &f); 882 static archetype *read (object_thawer &f);
846 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more 883 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more
847 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ 884 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */
885
886protected:
887 void do_delete ();
848}; 888};
849 889
850// returns whether the object is a dragon player, which are often specialcased 890// returns whether the object is a dragon player, which are often specialcased
851inline bool 891inline bool
852object::is_dragon () const 892object::is_dragon () const
925#define INS_NO_MERGE 0x0001 965#define INS_NO_MERGE 0x0001
926#define INS_ABOVE_FLOOR_ONLY 0x0002 966#define INS_ABOVE_FLOOR_ONLY 0x0002
927#define INS_NO_WALK_ON 0x0004 967#define INS_NO_WALK_ON 0x0004
928#define INS_ON_TOP 0x0008 968#define INS_ON_TOP 0x0008
929#define INS_BELOW_ORIGINATOR 0x0010 969#define INS_BELOW_ORIGINATOR 0x0010
970#define INS_NO_AUTO_EXIT 0x0020 // temporary, fix exits instead
930 971
931//-GPL 972//-GPL
932 973
933#endif 974#endif
934 975

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines