… | |
… | |
623 | /* |
623 | /* |
624 | * Updates the speed of an object. If the speed changes from 0 to another |
624 | * Updates the speed of an object. If the speed changes from 0 to another |
625 | * value, or vice versa, then add/remove the object from the active list. |
625 | * value, or vice versa, then add/remove the object from the active list. |
626 | * This function needs to be called whenever the speed of an object changes. |
626 | * This function needs to be called whenever the speed of an object changes. |
627 | */ |
627 | */ |
628 | |
|
|
629 | void |
628 | void |
630 | update_ob_speed (object *op) |
629 | update_ob_speed (object *op) |
631 | { |
630 | { |
632 | extern int arch_init; |
631 | extern int arch_init; |
633 | |
632 | |
… | |
… | |
642 | abort (); |
641 | abort (); |
643 | #else |
642 | #else |
644 | op->speed = 0; |
643 | op->speed = 0; |
645 | #endif |
644 | #endif |
646 | } |
645 | } |
|
|
646 | |
647 | if (arch_init) |
647 | if (arch_init) |
648 | { |
|
|
649 | return; |
648 | return; |
650 | } |
649 | |
651 | if (FABS (op->speed) > MIN_ACTIVE_SPEED) |
650 | if (FABS (op->speed) > MIN_ACTIVE_SPEED) |
652 | { |
651 | { |
653 | /* If already on active list, don't do anything */ |
652 | /* If already on active list, don't do anything */ |
654 | if (op->active_next || op->active_prev || op == active_objects) |
653 | if (op->active_next || op->active_prev || op == active_objects) |
655 | return; |
654 | return; |
656 | |
655 | |
657 | /* process_events() expects us to insert the object at the beginning |
656 | /* process_events() expects us to insert the object at the beginning |
658 | * of the list. */ |
657 | * of the list. */ |
659 | op->active_next = active_objects; |
658 | op->active_next = active_objects; |
|
|
659 | |
660 | if (op->active_next != NULL) |
660 | if (op->active_next != NULL) |
661 | op->active_next->active_prev = op; |
661 | op->active_next->active_prev = op; |
|
|
662 | |
662 | active_objects = op; |
663 | active_objects = op; |
663 | } |
664 | } |
664 | else |
665 | else |
665 | { |
666 | { |
666 | /* If not on the active list, nothing needs to be done */ |
667 | /* If not on the active list, nothing needs to be done */ |
… | |
… | |
668 | return; |
669 | return; |
669 | |
670 | |
670 | if (op->active_prev == NULL) |
671 | if (op->active_prev == NULL) |
671 | { |
672 | { |
672 | active_objects = op->active_next; |
673 | active_objects = op->active_next; |
|
|
674 | |
673 | if (op->active_next != NULL) |
675 | if (op->active_next != NULL) |
674 | op->active_next->active_prev = NULL; |
676 | op->active_next->active_prev = NULL; |
675 | } |
677 | } |
676 | else |
678 | else |
677 | { |
679 | { |
678 | op->active_prev->active_next = op->active_next; |
680 | op->active_prev->active_next = op->active_next; |
|
|
681 | |
679 | if (op->active_next) |
682 | if (op->active_next) |
680 | op->active_next->active_prev = op->active_prev; |
683 | op->active_next->active_prev = op->active_prev; |
681 | } |
684 | } |
|
|
685 | |
682 | op->active_next = NULL; |
686 | op->active_next = NULL; |
683 | op->active_prev = NULL; |
687 | op->active_prev = NULL; |
684 | } |
688 | } |
685 | } |
689 | } |
686 | |
690 | |
… | |
… | |
901 | objects = next; |
905 | objects = next; |
902 | } |
906 | } |
903 | |
907 | |
904 | object *object::create () |
908 | object *object::create () |
905 | { |
909 | { |
906 | object * |
910 | object *op; |
907 | op; |
|
|
908 | |
911 | |
909 | if (freed.empty ()) |
912 | if (freed.empty ()) |
910 | op = new object; |
913 | op = new object; |
911 | else |
914 | else |
912 | { |
915 | { |
… | |
… | |
934 | void object::free (bool free_inventory) |
937 | void object::free (bool free_inventory) |
935 | { |
938 | { |
936 | if (QUERY_FLAG (this, FLAG_FREED)) |
939 | if (QUERY_FLAG (this, FLAG_FREED)) |
937 | return; |
940 | return; |
938 | |
941 | |
|
|
942 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
|
|
943 | remove_friendly_object (this); |
|
|
944 | |
939 | if (!QUERY_FLAG (this, FLAG_REMOVED)) |
945 | if (!QUERY_FLAG (this, FLAG_REMOVED)) |
940 | remove_ob (this); |
946 | remove_ob (this); |
941 | |
|
|
942 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
|
|
943 | remove_friendly_object (this); |
|
|
944 | |
947 | |
945 | SET_FLAG (this, FLAG_FREED); |
948 | SET_FLAG (this, FLAG_FREED); |
946 | |
949 | |
947 | if (more) |
950 | if (more) |
948 | { |
951 | { |
… | |
… | |
954 | { |
957 | { |
955 | /* Only if the space blocks everything do we not process - |
958 | /* Only if the space blocks everything do we not process - |
956 | * if some form of movement is allowed, let objects |
959 | * if some form of movement is allowed, let objects |
957 | * drop on that space. |
960 | * drop on that space. |
958 | */ |
961 | */ |
959 | if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || (GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)) |
962 | if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) |
960 | { |
963 | { |
961 | object *op = inv; |
964 | object *op = inv; |
962 | |
965 | |
963 | while (op) |
966 | while (op) |
964 | { |
967 | { |
… | |
… | |
2840 | { |
2843 | { |
2841 | shstr key_ (key); |
2844 | shstr key_ (key); |
2842 | |
2845 | |
2843 | return set_ob_key_value_s (op, key_, value, add_key); |
2846 | return set_ob_key_value_s (op, key_, value, add_key); |
2844 | } |
2847 | } |
|
|
2848 | |
|
|
2849 | void |
|
|
2850 | object::deep_iterator::next () |
|
|
2851 | { |
|
|
2852 | if (item->inv) |
|
|
2853 | item = item->inv; |
|
|
2854 | else if (item->below) |
|
|
2855 | item = item->below; |
|
|
2856 | else |
|
|
2857 | item = item->env->below; |
|
|
2858 | } |