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.235 by root, Tue Apr 6 21:11:48 2010 UTC vs.
Revision 1.241 by root, Mon Apr 12 05:22:38 2010 UTC

293sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags); 293sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags);
294int SP_level_dam_adjust (object *caster, object *spob); 294int SP_level_dam_adjust (object *caster, object *spob);
295int SP_level_duration_adjust (object *caster, object *spob); 295int SP_level_duration_adjust (object *caster, object *spob);
296int SP_level_range_adjust (object *caster, object *spob); 296int SP_level_range_adjust (object *caster, object *spob);
297 297
298struct freelist_item
299{
300 freelist_item *next;
301 uint32_t count;
302};
303
298struct object : zero_initialised, object_copy 304struct object : object_copy
299{ 305{
300 // These variables are not changed by ->copy_to 306 // These variables are not changed by ->copy_to
301 maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ 307 maptile *ACC (RW, map); /* Pointer to the map in which this object is present */
302 308
303 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. 309 UUID ACC (RW, uuid); // Unique Identifier, survives saves etc.
304 int ACC (RO, count); 310 uint32_t ACC (RO, count);
305 object_vector_index ACC (RO, index); // index into objects 311 object_vector_index ACC (RO, index); // index into objects
306 object_vector_index ACC (RO, active); // index into actives 312 object_vector_index ACC (RO, active); // index into actives
307 313
308 player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */ 314 player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */
309 315
321 */ 327 */
322 object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ 328 object *ACC (RW, more); /* Pointer to the rest of a large body of objects */
323 object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different 329 object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different
324 key_value *key_values; /* Fields not explictly known by the loader. */ 330 key_value *key_values; /* Fields not explictly known by the loader. */
325 331
332 MTH void set_flag (int flagnum)
333 {
334 flag [flagnum] = true;
335 }
336
337 MTH void clr_flag (int flagnum)
338 {
339 flag [flagnum] = false;
340 }
341
326 // privates / perl 342 // privates / perl
327 shstr_tmp kv_get (shstr_tmp key) const; 343 shstr_tmp kv_get (shstr_tmp key) const;
328 void kv_del (shstr_tmp key); 344 void kv_del (shstr_tmp key);
329 void kv_set (shstr_tmp key, shstr_tmp value); 345 void kv_set (shstr_tmp key, shstr_tmp value);
330 346
379 destroy (); 395 destroy ();
380 } 396 }
381 397
382 // recursively destroy all objects in inventory, optionally dropping them to the ground instead 398 // recursively destroy all objects in inventory, optionally dropping them to the ground instead
383 MTH void destroy_inv (bool drop_to_ground = false); 399 MTH void destroy_inv (bool drop_to_ground = false);
400 MTH void destroy_inv_fast (); // like destroy_inv (false), but only works when *this is destroyed, too
384 MTH object *insert (object *item); // insert into inventory 401 MTH object *insert (object *item); // insert into inventory
385 MTH void play_sound (faceidx sound) const; 402 MTH void play_sound (faceidx sound) const;
386 MTH void say_msg (const_utf8_string msg) const; 403 MTH void say_msg (const_utf8_string msg) const;
387 404
388 void do_remove (); 405 void do_remove ();
431 } 448 }
432 449
433 MTH void set_owner (object *owner); 450 MTH void set_owner (object *owner);
434 MTH void set_speed (float speed); 451 MTH void set_speed (float speed);
435 MTH void set_glow_radius (sint8 rad); 452 MTH void set_glow_radius (sint8 rad);
436 MTH bool change_skill (object *ob); // deprecated?
437 453
438 MTH void open_container (object *new_container); 454 MTH void open_container (object *new_container);
439 MTH void close_container () 455 MTH void close_container ()
440 { 456 {
441 open_container (0); 457 open_container (0);
532 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } 548 && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); }
533 MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } 549 MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; }
534 550
535 MTH bool is_dragon () const; 551 MTH bool is_dragon () const;
536 552
553 MTH bool is_immunity () const { return invisible && type == SIGN; }
554
537 MTH bool has_active_speed () const { return speed >= MIN_ACTIVE_SPEED; } 555 MTH bool has_active_speed () const { return speed >= MIN_ACTIVE_SPEED; }
538 556
539 // temporary: wether the object can be saved in a map file 557 // temporary: wether the object can be saved in a map file
540 // contr => is a player 558 // contr => is a player
541 // head => only save head of a multitile object 559 // head => only save head of a multitile object
727 745
728 MTH struct region *region () const; 746 MTH struct region *region () const;
729 747
730 void statusmsg (const_utf8_string msg, int color = NDI_BLACK); 748 void statusmsg (const_utf8_string msg, int color = NDI_BLACK);
731 void failmsg (const_utf8_string msg, int color = NDI_RED); 749 void failmsg (const_utf8_string msg, int color = NDI_RED);
750 void failmsgf (const_utf8_string format, ...); // always NDI_RED...
732 751
733 const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); 752 const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = "");
734 753
735 MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference 754 MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference
736 static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible 755 static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible
753 MTH int anim_frames () const { return anim ().num_animations; } 772 MTH int anim_frames () const { return anim ().num_animations; }
754 MTH int anim_facings () const { return anim ().facings; } 773 MTH int anim_facings () const { return anim ().facings; }
755 774
756 MTH utf8_string as_string (); 775 MTH utf8_string as_string ();
757 776
777 // low-level management, statistics, ...
778 static uint32_t ACC (RW, object_count);
779 static uint32_t ACC (RW, free_count);
780 static uint32_t ACC (RW, create_count);
781 static uint32_t ACC (RW, destroy_count);
782 static freelist_item *freelist;
783 MTH static void freelist_free (int count);
784
758protected: 785protected:
759 void link (); 786 void link ();
760 void unlink (); 787 void unlink ();
788
789 void do_delete ();
761 790
762 object (); 791 object ();
763 ~object (); 792 ~object ();
764 793
765private: 794private:
802 */ 831 */
803 832
804//-GPL 833//-GPL
805 834
806INTERFACE_CLASS (archetype) 835INTERFACE_CLASS (archetype)
807struct archetype : object 836struct archetype : object, zero_initialised
808{ 837{
809 static arch_ptr empty; // the empty_archetype 838 static arch_ptr empty; // the empty_archetype
810 MTH static void gc (); 839 MTH static void gc ();
811 840
812 archetype (const_utf8_string name); 841 archetype (const_utf8_string name);
830 859
831 // support for archetype loading 860 // support for archetype loading
832 static archetype *read (object_thawer &f); 861 static archetype *read (object_thawer &f);
833 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more 862 MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more
834 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ 863 static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */
864
865protected:
866 void do_delete ();
835}; 867};
836 868
837// returns whether the object is a dragon player, which are often specialcased 869// returns whether the object is a dragon player, which are often specialcased
838inline bool 870inline bool
839object::is_dragon () const 871object::is_dragon () const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines