… | |
… | |
29 | #include <stdio.h> |
29 | #include <stdio.h> |
30 | #include <sys/types.h> |
30 | #include <sys/types.h> |
31 | #include <sys/uio.h> |
31 | #include <sys/uio.h> |
32 | #include <object.h> |
32 | #include <object.h> |
33 | #include <funcpoint.h> |
33 | #include <funcpoint.h> |
34 | #include <skills.h> |
|
|
35 | #include <loader.h> |
34 | #include <loader.h> |
36 | |
35 | |
37 | int nrofallocobjects = 0; |
36 | int nrofallocobjects = 0; |
38 | |
37 | |
39 | object *objects; /* Pointer to the list of used objects */ |
38 | object *objects; /* Pointer to the list of used objects */ |
… | |
… | |
905 | objects = next; |
904 | objects = next; |
906 | } |
905 | } |
907 | |
906 | |
908 | object *object::create () |
907 | object *object::create () |
909 | { |
908 | { |
910 | object * |
909 | object *op; |
911 | op; |
|
|
912 | |
910 | |
913 | if (freed.empty ()) |
911 | if (freed.empty ()) |
914 | op = new object; |
912 | op = new object; |
915 | else |
913 | else |
916 | { |
914 | { |
… | |
… | |
938 | void object::free (bool free_inventory) |
936 | void object::free (bool free_inventory) |
939 | { |
937 | { |
940 | if (QUERY_FLAG (this, FLAG_FREED)) |
938 | if (QUERY_FLAG (this, FLAG_FREED)) |
941 | return; |
939 | return; |
942 | |
940 | |
|
|
941 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
|
|
942 | remove_friendly_object (this); |
|
|
943 | |
943 | if (!QUERY_FLAG (this, FLAG_REMOVED)) |
944 | if (!QUERY_FLAG (this, FLAG_REMOVED)) |
944 | remove_ob (this); |
945 | remove_ob (this); |
945 | |
|
|
946 | if (QUERY_FLAG (this, FLAG_FRIENDLY)) |
|
|
947 | remove_friendly_object (this); |
|
|
948 | |
946 | |
949 | SET_FLAG (this, FLAG_FREED); |
947 | SET_FLAG (this, FLAG_FREED); |
950 | |
948 | |
951 | if (more) |
949 | if (more) |
952 | { |
950 | { |
… | |
… | |
958 | { |
956 | { |
959 | /* Only if the space blocks everything do we not process - |
957 | /* Only if the space blocks everything do we not process - |
960 | * if some form of movement is allowed, let objects |
958 | * if some form of movement is allowed, let objects |
961 | * drop on that space. |
959 | * drop on that space. |
962 | */ |
960 | */ |
963 | if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || (GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL)) |
961 | if (free_inventory || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) |
964 | { |
962 | { |
965 | object *op = inv; |
963 | object *op = inv; |
966 | |
964 | |
967 | while (op) |
965 | while (op) |
968 | { |
966 | { |
… | |
… | |
2845 | shstr key_ (key); |
2843 | shstr key_ (key); |
2846 | |
2844 | |
2847 | return set_ob_key_value_s (op, key_, value, add_key); |
2845 | return set_ob_key_value_s (op, key_, value, add_key); |
2848 | } |
2846 | } |
2849 | |
2847 | |
|
|
2848 | object::depth_iterator::depth_iterator (object *container) |
|
|
2849 | : iterator_base (container) |
|
|
2850 | { |
|
|
2851 | while (item->inv) |
|
|
2852 | item = item->inv; |
|
|
2853 | } |
|
|
2854 | |
2850 | void |
2855 | void |
2851 | object::deep_iterator::next () |
2856 | object::depth_iterator::next () |
2852 | { |
2857 | { |
2853 | if (item->inv) |
|
|
2854 | item = item->inv; |
|
|
2855 | else if (item->below) |
2858 | if (item->below) |
|
|
2859 | { |
2856 | item = item->below; |
2860 | item = item->below; |
|
|
2861 | |
|
|
2862 | while (item->inv) |
|
|
2863 | item = item->inv; |
|
|
2864 | } |
2857 | else |
2865 | else |
2858 | item = item->env->below; |
2866 | item = item->env; |
2859 | } |
2867 | } |
|
|
2868 | |