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.207 by root, Wed Sep 16 23:22:50 2009 UTC

492 * 1000 492 * 1000
493 * (type == CONTAINER ? 1000 : 1) 493 * (type == CONTAINER ? 1000 : 1)
494 / dominant_material ()->density; 494 / dominant_material ()->density;
495 } 495 }
496 496
497 MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; }
498
497 MTH bool is_wiz () const { return flag [FLAG_WIZ]; } 499 MTH bool is_wiz () const { return flag [FLAG_WIZ]; }
498 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } 500 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 501 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET
500 || type == CLOAK || type == BOOTS || type == GLOVES 502 || type == CLOAK || type == BOOTS || type == GLOVES
501 || type == BRACERS || type == GIRDLE; } 503 || type == BRACERS || type == GIRDLE; }
533 535
534 return op; 536 return op;
535 } 537 }
536 538
537 // returns the outermost environment, never returns 0 539 // returns the outermost environment, never returns 0
538 MTH object *outer_env () const 540 MTH object *outer_env_or_self () const
539 { 541 {
540 const object *op; 542 const object *op;
541 543
542 for (op = this; op->env; op = op->env) 544 for (op = this; op->env; op = op->env)
543 ; 545 ;
544 546
545 return const_cast<object *>(op); 547 return const_cast<object *>(op);
548 }
549
550 // returns the outermost environment, may return 0
551 MTH object *outer_env () const
552 {
553 return env ? outer_env_or_self () : 0;
546 } 554 }
547 555
548 // returns the player that has this object in his inventory, or 0 556 // returns the player that has this object in his inventory, or 0
549 // we assume the player is always the outer env 557 // we assume the player is always the outer env
550 MTH object *in_player () const 558 MTH object *in_player () const
551 { 559 {
552 object *op = outer_env (); 560 object *op = outer_env_or_self ();
553 561
554 return op->type == PLAYER ? op : 0; 562 return op->type == PLAYER ? op : 0;
555 } 563 }
556 564
557 // "temporary" helper function 565 // "temporary" helper function
591 } 599 }
592 600
593 // returns the player that cna see this object, if any 601 // returns the player that cna see this object, if any
594 MTH object *visible_to () const; 602 MTH object *visible_to () const;
595 603
596 MTH std::string long_desc (object *who = 0); 604 MTH std::string long_desc (object *who = 0); // query_name . " " . describe
597 MTH std::string describe_monster (object *who = 0); 605 MTH std::string describe_monster (object *who = 0);
598 MTH std::string describe_item (object *who = 0); 606 MTH std::string describe_item (object *who = 0);
599 MTH std::string describe (object *who = 0); 607 MTH std::string describe (object *who = 0); // long description, without name
600 608
601 MTH const char *query_weight () { return ::query_weight (this); } 609 MTH const char *query_weight () { return ::query_weight (this); }
602 MTH const char *query_name () { return ::query_name (this); } 610 MTH const char *query_name () { return ::query_name (this); }
603 MTH const char *query_short_name () { return ::query_short_name (this); } 611 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); } 612 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines