… | |
… | |
789 | { |
789 | { |
790 | /* Only if the space blocks everything do we not process - |
790 | /* Only if the space blocks everything do we not process - |
791 | * if some form of movement is allowed, let objects |
791 | * if some form of movement is allowed, let objects |
792 | * drop on that space. |
792 | * drop on that space. |
793 | */ |
793 | */ |
794 | if (!drop_to_ground || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) |
794 | if (!drop_to_ground |
|
|
795 | || !map |
|
|
796 | || map->in_memory != MAP_IN_MEMORY |
|
|
797 | || map->at (x, y).move_block == MOVE_ALL) |
795 | { |
798 | { |
796 | while (inv) |
799 | while (inv) |
|
|
800 | { |
|
|
801 | inv->destroy_inv (drop_to_ground); |
797 | inv->destroy (); |
802 | inv->destroy (); |
|
|
803 | } |
798 | } |
804 | } |
799 | else |
805 | else |
800 | { /* Put objects in inventory onto this space */ |
806 | { /* Put objects in inventory onto this space */ |
801 | while (inv) |
807 | while (inv) |
802 | { |
808 | { |
… | |
… | |
807 | || op->type == RUNE |
813 | || op->type == RUNE |
808 | || op->type == TRAP |
814 | || op->type == TRAP |
809 | || op->flag [FLAG_IS_A_TEMPLATE]) |
815 | || op->flag [FLAG_IS_A_TEMPLATE]) |
810 | op->destroy (); |
816 | op->destroy (); |
811 | else |
817 | else |
812 | { |
818 | map->insert (op, x, y); |
813 | op->remove (); |
|
|
814 | op->x = x; |
|
|
815 | op->y = y; |
|
|
816 | insert_ob_in_map (op, map, 0, 0); /* Insert in same map as the envir */ |
|
|
817 | } |
|
|
818 | } |
819 | } |
819 | } |
820 | } |
820 | } |
821 | } |
821 | |
822 | |
822 | object *object::create () |
823 | object *object::create () |
… | |
… | |
839 | remove (); |
840 | remove (); |
840 | |
841 | |
841 | if (flag [FLAG_FREED]) |
842 | if (flag [FLAG_FREED]) |
842 | return; |
843 | return; |
843 | |
844 | |
|
|
845 | set_speed (0); |
|
|
846 | |
844 | flag [FLAG_FREED] = 1; |
847 | flag [FLAG_FREED] = 1; |
845 | |
848 | |
846 | attachable::do_destroy (); |
849 | attachable::do_destroy (); |
847 | |
850 | |
848 | destroy_inv (true); |
851 | destroy_inv (true); |
849 | set_speed (0); |
|
|
850 | unlink (); |
852 | unlink (); |
851 | |
853 | |
852 | // hack to ensure that freed objects still have a valid map |
854 | // hack to ensure that freed objects still have a valid map |
853 | { |
855 | { |
854 | static maptile *freed_map; // freed objects are moved here to avoid crashes |
856 | static maptile *freed_map; // freed objects are moved here to avoid crashes |
… | |
… | |
1045 | { |
1047 | { |
1046 | move_apply (tmp, this, 0); |
1048 | move_apply (tmp, this, 0); |
1047 | |
1049 | |
1048 | if (destroyed ()) |
1050 | if (destroyed ()) |
1049 | LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); |
1051 | LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); |
1050 | LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); |
|
|
1051 | } |
1052 | } |
1052 | |
1053 | |
1053 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1054 | /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ |
1054 | |
1055 | |
1055 | if (tmp->above == tmp) |
1056 | if (tmp->above == tmp) |
… | |
… | |
1111 | * job preparing multi-part monsters |
1112 | * job preparing multi-part monsters |
1112 | */ |
1113 | */ |
1113 | object * |
1114 | object * |
1114 | insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) |
1115 | insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) |
1115 | { |
1116 | { |
1116 | object *tmp; |
|
|
1117 | |
|
|
1118 | if (op->head) |
|
|
1119 | op = op->head; |
|
|
1120 | |
|
|
1121 | for (tmp = op; tmp; tmp = tmp->more) |
1117 | for (object *tmp = op->head_ (); tmp; tmp = tmp->more) |
1122 | { |
1118 | { |
1123 | tmp->x = x + tmp->arch->clone.x; |
1119 | tmp->x = x + tmp->arch->clone.x; |
1124 | tmp->y = y + tmp->arch->clone.y; |
1120 | tmp->y = y + tmp->arch->clone.y; |
1125 | } |
1121 | } |
1126 | |
1122 | |
… | |
… | |
1440 | tmp1->x = op->x; |
1436 | tmp1->x = op->x; |
1441 | tmp1->y = op->y; |
1437 | tmp1->y = op->y; |
1442 | insert_ob_in_map (tmp1, op->map, op, 0); |
1438 | insert_ob_in_map (tmp1, op->map, op, 0); |
1443 | } |
1439 | } |
1444 | |
1440 | |
|
|
1441 | object * |
|
|
1442 | object::insert_at (object *where, object *originator, int flags) |
|
|
1443 | { |
|
|
1444 | where->map->insert (this, where->x, where->y, originator, flags); |
|
|
1445 | } |
|
|
1446 | |
1445 | /* |
1447 | /* |
1446 | * get_split_ob(ob,nr) splits up ob into two parts. The part which |
1448 | * get_split_ob(ob,nr) splits up ob into two parts. The part which |
1447 | * is returned contains nr objects, and the remaining parts contains |
1449 | * is returned contains nr objects, and the remaining parts contains |
1448 | * the rest (or is removed and freed if that number is 0). |
1450 | * the rest (or is removed and freed if that number is 0). |
1449 | * On failure, NULL is returned, and the reason put into the |
1451 | * On failure, NULL is returned, and the reason put into the |
1450 | * global static errmsg array. |
1452 | * global static errmsg array. |
1451 | */ |
1453 | */ |
1452 | |
|
|
1453 | object * |
1454 | object * |
1454 | get_split_ob (object *orig_ob, uint32 nr) |
1455 | get_split_ob (object *orig_ob, uint32 nr) |
1455 | { |
1456 | { |
1456 | object *newob; |
1457 | object *newob; |
1457 | int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); |
1458 | int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); |
… | |
… | |
1721 | * |
1722 | * |
1722 | * MSW 2001-07-08: Check all objects on space, not just those below |
1723 | * MSW 2001-07-08: Check all objects on space, not just those below |
1723 | * object being inserted. insert_ob_in_map may not put new objects |
1724 | * object being inserted. insert_ob_in_map may not put new objects |
1724 | * on top. |
1725 | * on top. |
1725 | */ |
1726 | */ |
1726 | |
|
|
1727 | int |
1727 | int |
1728 | check_move_on (object *op, object *originator) |
1728 | check_move_on (object *op, object *originator) |
1729 | { |
1729 | { |
1730 | object *tmp; |
1730 | object *tmp; |
1731 | maptile *m = op->map; |
1731 | maptile *m = op->map; |