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.214 by root, Thu Nov 5 15:57:16 2009 UTC vs.
Revision 1.222 by root, Sun Nov 29 09:41:28 2009 UTC

93 93
94struct UUID 94struct UUID
95{ 95{
96 uint64 seq; 96 uint64 seq;
97 97
98 enum { MAX_LEN = 3 + 16 + 1 + 1 }; // <1. + hex + > + \0
99
98 static UUID cur; // last uuid generated 100 static UUID cur; // last uuid generated
99 static void init (); 101 static void init ();
100 static UUID gen (); 102 static UUID gen ();
101 103
102 UUID () { } 104 UUID () { }
103 UUID (uint64 seq) : seq(seq) { } 105 UUID (uint64 seq) : seq(seq) { }
104 operator uint64() { return seq; } 106 operator uint64() { return seq; }
105 void operator =(uint64 seq) { this->seq = seq; } 107 void operator =(uint64 seq) { this->seq = seq; }
106 108
107 typedef char BUF [32];
108
109 bool parse (const char *s) 109 bool parse (const char *s);
110 { 110 char *append (char *buf) const;
111 return sscanf (s, "<1.%" SCNx64 ">", &seq) == 1;
112 }
113
114 const char *c_str (char *buf, int len) const
115 {
116 snprintf (buf, len, "<1.%" PRIx64 ">", seq);
117
118 return buf;
119 }
120
121 const char *c_str () const 111 char *c_str () const;
122 {
123 static BUF buf;
124
125 return c_str (buf, sizeof (buf));
126 }
127}; 112};
128 113
129//+GPL 114//+GPL
130 115
131/* Definition for WILL_APPLY values. Replaces having harcoded values 116/* Definition for WILL_APPLY values. Replaces having harcoded values
139#define WILL_APPLY_DOOR 0x08 124#define WILL_APPLY_DOOR 0x08
140#define WILL_APPLY_FOOD 0x10 125#define WILL_APPLY_FOOD 0x10
141 126
142struct body_slot 127struct body_slot
143{ 128{
129 signed char used:4; /* Calculated value based on items equipped */
144 signed char info:4; /* body info as loaded from the file */ 130 signed char info:4; /* body info as loaded from the file */
145 signed char used:4; /* Calculated value based on items equipped */
146}; 131};
147 132
148typedef struct oblnk 133typedef struct oblnk
149{ /* Used to link together several objects */ 134{ /* Used to link together several objects */
150 object_ptr ob; 135 object_ptr ob;
180 flags_t flag; /* various flags */ 165 flags_t flag; /* various flags */
181#if FOR_PERL 166#if FOR_PERL
182 bool ACC (RW, flag[NUM_FLAGS]); 167 bool ACC (RW, flag[NUM_FLAGS]);
183#endif 168#endif
184 169
185 shstr ACC (RW, materialname); /* specific material name */ 170 materialtype_t *material; // What material this object consists of //TODO, make perl-accessible
186 shstr ACC (RW, skill); /* Name of the skill this object uses/grants */ 171 shstr ACC (RW, skill); /* Name of the skill this object uses/grants */
187// materialtype_t *ACC (RW, material); /* What material this object consists of */
188 object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */ 172 object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */
189 object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ 173 object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */
190 object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ 174 object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */
191 object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ 175 object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */
192 object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ 176 object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */
227 uint8 ACC (RW, pick_up); /* See crossfire.doc */ 211 uint8 ACC (RW, pick_up); /* See crossfire.doc */
228 sint8 ACC (RW, gen_sp_armour);/* sp regen penalty this object has (was last_heal) */ 212 sint8 ACC (RW, gen_sp_armour);/* sp regen penalty this object has (was last_heal) */
229 sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ 213 sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */
230 uint8 ACC (RW, weapontype); /* type of weapon */ 214 uint8 ACC (RW, weapontype); /* type of weapon */
231 215
216 body_slot slot [NUM_BODY_LOCATIONS];
217
232 faceidx ACC (RW, face); /* the graphical face */ 218 faceidx ACC (RW, face); /* the graphical face */
233 219
234 faceidx ACC (RW, sound); /* the sound face */ 220 faceidx ACC (RW, sound); /* the sound face */
235 faceidx ACC (RW, sound_destroy); /* played on destroy */ 221 faceidx ACC (RW, sound_destroy); /* played on destroy */
236
237 body_slot slot [NUM_BODY_LOCATIONS];
238 222
239 sint32 ACC (RW, weight); /* Attributes of the object */ 223 sint32 ACC (RW, weight); /* Attributes of the object */
240 sint32 ACC (RW, weight_limit);/* Weight-limit of object */ 224 sint32 ACC (RW, weight_limit);/* Weight-limit of object */
241 225
242 sint32 ACC (RW, carrying); /* How much weight this object contains, must be 0 if nrof == 0 */ 226 sint32 ACC (RW, carrying); /* How much weight this object contains, must be 0 if nrof == 0 */
504 } 488 }
505 489
506 MTH void update_weight (); 490 MTH void update_weight ();
507 491
508 // return the dominant material of this item, always return something 492 // return the dominant material of this item, always return something
509 const materialtype_t *dominant_material () const; 493 const materialtype_t *dominant_material () const
494 {
495 return material;
496 }
510 497
511 // return the volume of this object in cm³ 498 // return the volume of this object in cm³
512 MTH uint64 volume () const 499 MTH uint64 volume () const
513 { 500 {
514 return (uint64)total_weight () 501 return (uint64)total_weight ()
515 * 1000 502 * 1024 // 1000 actually
516 * (type == CONTAINER ? 1000 : 1) 503 * (type == CONTAINER ? 128 : 1)
517 / dominant_material ()->density; 504 / dominant_material ()->density; // ugh, division
518 } 505 }
519 506
520 MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; } 507 MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; }
521 508
522 MTH bool is_wiz () const { return flag [FLAG_WIZ]; } 509 MTH bool is_wiz () const { return flag [FLAG_WIZ]; }
531 MTH bool is_arrow () const { return type == ARROW 518 MTH bool is_arrow () const { return type == ARROW
532 || (type == SPELL_EFFECT 519 || (type == SPELL_EFFECT
533 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } 520 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); }
534 MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } 521 MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; }
535 522
536 MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; } 523 MTH bool has_active_speed () const { return speed >= MIN_ACTIVE_SPEED; }
537 524
538 // temporary: wether the object can be saved in a map file 525 // temporary: wether the object can be saved in a map file
539 // contr => is a player 526 // contr => is a player
540 // head => only save head of a multitile object 527 // head => only save head of a multitile object
541 // owner => can not reference owner yet 528 // owner => can not reference owner yet
645 MTH void create_treasure (treasurelist *tl, int flags = 0); 632 MTH void create_treasure (treasurelist *tl, int flags = 0);
646 633
647 // insert object at same map position as 'where' 634 // insert object at same map position as 'where'
648 // handles both inventory and map "positions" 635 // handles both inventory and map "positions"
649 MTH object *insert_at (object *where, object *originator = 0, int flags = 0); 636 MTH object *insert_at (object *where, object *originator = 0, int flags = 0);
637 // check whether we can put this into the map, respect max_nrof, max_volume, max_items
638 MTH bool can_drop_at (maptile *m, int x, int y, object *originator = 0);
650 MTH void drop_unpaid_items (); 639 MTH void drop_unpaid_items ();
651 640
652 MTH void activate (); 641 MTH void activate ();
653 MTH void deactivate (); 642 MTH void deactivate ();
654 MTH void activate_recursive (); 643 MTH void activate_recursive ();
760 object (const object &); 749 object (const object &);
761}; 750};
762 751
763// move this object to the top of its env's inventory to speed up 752// move this object to the top of its env's inventory to speed up
764// searches for it. 753// searches for it.
765static object * 754static inline object *
766splay (object *ob) 755splay (object *ob)
767{ 756{
768 if (ob->above && ob->env) 757 if (ob->above && ob->env)
769 { 758 {
770 if (ob->above) ob->above->below = ob->below; 759 if (ob->above) ob->above->below = ob->below;
812 MTH void unlink (); 801 MTH void unlink ();
813 802
814 MTH static object *get (const char *name); // (find() || singularity)->instance() 803 MTH static object *get (const char *name); // (find() || singularity)->instance()
815 MTH object *instance (); 804 MTH object *instance ();
816 805
806 MTH void post_load_check (); // do some adjustments after parsing
807
817 object_vector_index ACC (RW, archid); // index in archvector 808 object_vector_index ACC (RW, archid); // index in archvector
818 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ 809 shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */
819 810
820 sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ 811 sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */
821 sint8 ACC (RW, max_x), ACC (RW, max_y); 812 sint8 ACC (RW, max_x), ACC (RW, max_y);
832{ 823{
833 return at->instance (); 824 return at->instance ();
834} 825}
835 826
836inline void 827inline void
837object_freezer::put (keyword k, archetype *v) 828object_freezer::put (const keyword_string k, archetype *v)
838{ 829{
839 put (k, v ? &v->archname : (const char *)0); 830 if (expect_true (v))
831 put (k, v->archname);
832 else
833 put (k);
840} 834}
841 835
842typedef object_vector<object, &object::index > objectvec; 836typedef object_vector<object, &object::index > objectvec;
843typedef object_vector<object, &object::active> activevec; 837typedef object_vector<object, &object::active> activevec;
844typedef object_vector<archetype, &archetype::archid> archvec; 838typedef object_vector<archetype, &archetype::archid> archvec;
902#define INS_ABOVE_FLOOR_ONLY 0x0002 896#define INS_ABOVE_FLOOR_ONLY 0x0002
903#define INS_NO_WALK_ON 0x0004 897#define INS_NO_WALK_ON 0x0004
904#define INS_ON_TOP 0x0008 898#define INS_ON_TOP 0x0008
905#define INS_BELOW_ORIGINATOR 0x0010 899#define INS_BELOW_ORIGINATOR 0x0010
906 900
907#define ARCH_DEPLETION "depletion"
908
909//-GPL 901//-GPL
910 902
911#endif 903#endif
912 904

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines