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.203 by root, Sat Jun 27 08:35:03 2009 UTC vs.
Revision 1.211 by sf-marcmagus, Sun Oct 11 05:43:35 2009 UTC

436 { 436 {
437 open_container (0); 437 open_container (0);
438 } 438 }
439 439
440 MTH object *force_find (shstr_tmp name); 440 MTH object *force_find (shstr_tmp name);
441 MTH void force_set_timer (int duration);
441 MTH object *force_add (shstr_tmp name, int duration = 0); 442 MTH object *force_add (shstr_tmp name, int duration = 0);
442 443
443 oblinkpt *find_link () const; 444 oblinkpt *find_link () const;
444 MTH void add_link (maptile *map, shstr_tmp id); 445 MTH void add_link (maptile *map, shstr_tmp id);
445 MTH void remove_link (); 446 MTH void remove_link ();
491 return (uint64)total_weight () 492 return (uint64)total_weight ()
492 * 1000 493 * 1000
493 * (type == CONTAINER ? 1000 : 1) 494 * (type == CONTAINER ? 1000 : 1)
494 / dominant_material ()->density; 495 / dominant_material ()->density;
495 } 496 }
497
498 MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; }
496 499
497 MTH bool is_wiz () const { return flag [FLAG_WIZ]; } 500 MTH bool is_wiz () const { return flag [FLAG_WIZ]; }
498 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } 501 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; }
499 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET 502 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET
500 || type == CLOAK || type == BOOTS || type == GLOVES 503 || type == CLOAK || type == BOOTS || type == GLOVES
519 /* This return true if object has still randomitems which 522 /* This return true if object has still randomitems which
520 * could be expanded. 523 * could be expanded.
521 */ 524 */
522 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } 525 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; }
523 526
524 MTH bool has_dialogue () const { return *&msg == '@'; } 527 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; }
528
529 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); }
525 530
526 // returns the outermost owner, never returns 0 531 // returns the outermost owner, never returns 0
527 MTH object *outer_owner () 532 MTH object *outer_owner ()
528 { 533 {
529 object *op; 534 object *op;
533 538
534 return op; 539 return op;
535 } 540 }
536 541
537 // returns the outermost environment, never returns 0 542 // returns the outermost environment, never returns 0
538 MTH object *outer_env () const 543 MTH object *outer_env_or_self () const
539 { 544 {
540 const object *op; 545 const object *op;
541 546
542 for (op = this; op->env; op = op->env) 547 for (op = this; op->env; op = op->env)
543 ; 548 ;
544 549
545 return const_cast<object *>(op); 550 return const_cast<object *>(op);
551 }
552
553 // returns the outermost environment, may return 0
554 MTH object *outer_env () const
555 {
556 return env ? outer_env_or_self () : 0;
546 } 557 }
547 558
548 // returns the player that has this object in his inventory, or 0 559 // returns the player that has this object in his inventory, or 0
549 // we assume the player is always the outer env 560 // we assume the player is always the outer env
550 MTH object *in_player () const 561 MTH object *in_player () const
551 { 562 {
552 object *op = outer_env (); 563 object *op = outer_env_or_self ();
553 564
554 return op->type == PLAYER ? op : 0; 565 return op->type == PLAYER ? op : 0;
555 } 566 }
556 567
557 // "temporary" helper function 568 // "temporary" helper function
591 } 602 }
592 603
593 // returns the player that cna see this object, if any 604 // returns the player that cna see this object, if any
594 MTH object *visible_to () const; 605 MTH object *visible_to () const;
595 606
596 MTH std::string long_desc (object *who = 0); 607 MTH std::string long_desc (object *who = 0); // query_name . " " . describe
597 MTH std::string describe_monster (object *who = 0); 608 MTH std::string describe_monster (object *who = 0);
598 MTH std::string describe_item (object *who = 0); 609 MTH std::string describe_item (object *who = 0);
599 MTH std::string describe (object *who = 0); 610 MTH std::string describe (object *who = 0); // long description, without name
600 611
601 MTH const char *query_weight () { return ::query_weight (this); } 612 MTH const char *query_weight () { return ::query_weight (this); }
602 MTH const char *query_name () { return ::query_name (this); } 613 MTH const char *query_name () { return ::query_name (this); }
603 MTH const char *query_short_name () { return ::query_short_name (this); } 614 MTH const char *query_short_name () { return ::query_short_name (this); }
604 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } 615 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); }
699 // currently only used for players to make them temporarily visible 710 // currently only used for players to make them temporarily visible
700 // when they are invisible. 711 // when they are invisible.
701 MTH void make_noise (); 712 MTH void make_noise ();
702 713
703 /* animation */ 714 /* animation */
704 bool has_anim () { return animation_id; } 715 MTH bool has_anim () const { return animation_id; }
705 const animation &anim () const { return animations [animation_id]; } 716 const animation &anim () const { return animations [animation_id]; }
706 faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; } 717 MTH faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; }
707 void set_anim_frame (int frame) { face = get_anim_frame (frame); } 718 MTH void set_anim_frame (int frame) { face = get_anim_frame (frame); }
708 /* anim_frames () returns the number of animations allocated. The last 719 /* anim_frames () returns the number of animations allocated. The last
709 * usuable animation will be anim_frames () - 1 (for example, if an object 720 * usuable animation will be anim_frames () - 1 (for example, if an object
710 * has 8 animations, anim_frames () will return 8, but the values will 721 * has 8 animations, anim_frames () will return 8, but the values will
711 * range from 0 through 7. 722 * range from 0 through 7.
712 */ 723 */
713 int anim_frames () const { return anim ().num_animations; } 724 MTH int anim_frames () const { return anim ().num_animations; }
714 int anim_facings () const { return anim ().facings; } 725 MTH int anim_facings () const { return anim ().facings; }
726
727 MTH char *as_string ();
715 728
716protected: 729protected:
717 void link (); 730 void link ();
718 void unlink (); 731 void unlink ();
719 732
728// move this object to the top of its env's inventory to speed up 741// move this object to the top of its env's inventory to speed up
729// searches for it. 742// searches for it.
730static object * 743static object *
731splay (object *ob) 744splay (object *ob)
732{ 745{
733 if (ob->env && ob->env->inv != ob) 746 if (ob->above && ob->env)
734 { 747 {
735 if (ob->above) ob->above->below = ob->below; 748 if (ob->above) ob->above->below = ob->below;
736 if (ob->below) ob->below->above = ob->above; 749 if (ob->below) ob->below->above = ob->above;
737 750
738 ob->above = 0; 751 ob->above = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines