… | |
… | |
383 | remove (); |
383 | remove (); |
384 | *this = pos; |
384 | *this = pos; |
385 | insert_at (this, this); |
385 | insert_at (this, this); |
386 | } |
386 | } |
387 | |
387 | |
|
|
388 | // high-level move functions, return true if successful |
|
|
389 | int move (int dir, object *originator); |
|
|
390 | |
|
|
391 | int move (int dir) |
|
|
392 | { |
|
|
393 | return move (dir, this); |
|
|
394 | } |
|
|
395 | |
388 | static bool can_merge_slow (object *op1, object *op2); |
396 | static bool can_merge_slow (object *op1, object *op2); |
389 | |
397 | |
390 | // this is often used in time-critical code, so optimise |
398 | // this is often used in time-critical code, so optimise |
391 | MTH static bool can_merge (object *op1, object *op2) |
399 | MTH static bool can_merge (object *op1, object *op2) |
392 | { |
400 | { |
… | |
… | |
405 | { |
413 | { |
406 | open_container (0); |
414 | open_container (0); |
407 | } |
415 | } |
408 | |
416 | |
409 | MTH object *force_find (const shstr name); |
417 | MTH object *force_find (const shstr name); |
410 | MTH void force_add (const shstr name, int duration = 0); |
418 | MTH object *force_add (const shstr name, int duration = 0); |
411 | |
419 | |
412 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
420 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
413 | bool should_invoke (event_type event) |
421 | bool should_invoke (event_type event) |
414 | { |
422 | { |
415 | return ev_want_event [event] || ev_want_type [type] || cb; |
423 | return ev_want_event [event] || ev_want_type [type] || cb; |
… | |
… | |
451 | const materialtype_t *dominant_material () const; |
459 | const materialtype_t *dominant_material () const; |
452 | |
460 | |
453 | // return the volume of this object in cm³ |
461 | // return the volume of this object in cm³ |
454 | MTH uint64 volume () const |
462 | MTH uint64 volume () const |
455 | { |
463 | { |
456 | return total_weight () |
464 | return (uint64)total_weight () |
457 | * 1000 |
465 | * 1000 |
458 | * (type == CONTAINER ? 1000 : 1) |
466 | * (type == CONTAINER ? 1000 : 1) |
459 | / dominant_material ()->density; |
467 | / dominant_material ()->density; |
460 | } |
468 | } |
461 | |
469 | |
… | |
… | |
538 | MTH bool is_inserted () const |
546 | MTH bool is_inserted () const |
539 | { |
547 | { |
540 | return !flag [FLAG_REMOVED]; |
548 | return !flag [FLAG_REMOVED]; |
541 | } |
549 | } |
542 | |
550 | |
|
|
551 | MTH bool is_player () const |
|
|
552 | { |
|
|
553 | return !!contr; |
|
|
554 | } |
|
|
555 | |
|
|
556 | MTH bool affects_los () const |
|
|
557 | { |
|
|
558 | return glow_radius || flag [FLAG_BLOCKSVIEW]; |
|
|
559 | } |
|
|
560 | |
543 | // returns the player that cna see this object, if any |
561 | // returns the player that cna see this object, if any |
544 | MTH object *visible_to () const; |
562 | MTH object *visible_to () const; |
545 | |
563 | |
546 | MTH std::string long_desc (object *who = 0); |
564 | MTH std::string long_desc (object *who = 0); |
547 | MTH std::string describe_monster (object *who = 0); |
565 | MTH std::string describe_monster (object *who = 0); |
… | |
… | |
637 | |
655 | |
638 | const char *query_inventory (object *who = 0, const char *indent = ""); |
656 | const char *query_inventory (object *who = 0, const char *indent = ""); |
639 | |
657 | |
640 | MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference |
658 | MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference |
641 | static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible |
659 | static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible |
|
|
660 | |
|
|
661 | // make some noise with given item into direction dir, |
|
|
662 | // currently only used for players to make them temporarily visible |
|
|
663 | // when they are invisible. |
|
|
664 | MTH void make_noise (); |
642 | |
665 | |
643 | protected: |
666 | protected: |
644 | void link (); |
667 | void link (); |
645 | void unlink (); |
668 | void unlink (); |
646 | |
669 | |
… | |
… | |
747 | extern objectvec objects; |
770 | extern objectvec objects; |
748 | extern activevec actives; |
771 | extern activevec actives; |
749 | extern archvec archetypes; |
772 | extern archvec archetypes; |
750 | |
773 | |
751 | // "safely" iterate over inv in a way such that the current item is removable |
774 | // "safely" iterate over inv in a way such that the current item is removable |
752 | // quite horrible, thats why its hidden in some macro |
775 | // quite horrible, that's why its hidden in some macro |
753 | #define for_inv_removable(op,var) \ |
776 | #define for_inv_removable(op,var) \ |
754 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
777 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
755 | |
778 | |
756 | #define for_all_objects(var) \ |
779 | #define for_all_objects(var) \ |
757 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
780 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |