… | |
… | |
737 | } |
737 | } |
738 | |
738 | |
739 | mapspace &m = op->ms (); |
739 | mapspace &m = op->ms (); |
740 | |
740 | |
741 | if (!(m.flags_ & P_UPTODATE)) |
741 | if (!(m.flags_ & P_UPTODATE)) |
742 | /* nop */; |
742 | m.update_up (); // nothing to do except copy up |
743 | else if (action == UP_OBJ_INSERT) |
743 | else if (action == UP_OBJ_INSERT) |
744 | { |
744 | { |
745 | #if 0 |
745 | #if 0 |
746 | // this is likely overkill, TODO: revisit (schmorp) |
746 | // this is likely overkill, TODO: revisit (schmorp) |
747 | if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW)) |
747 | if ((op->flag [FLAG_BLOCKSVIEW] && !(m.flags_ & P_BLOCKSVIEW)) |
… | |
… | |
768 | * that is being removed. |
768 | * that is being removed. |
769 | */ |
769 | */ |
770 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
770 | else if (action == UP_OBJ_CHANGE || action == UP_OBJ_REMOVE) |
771 | m.invalidate (); |
771 | m.invalidate (); |
772 | else if (action == UP_OBJ_FACE) |
772 | else if (action == UP_OBJ_FACE) |
773 | /* Nothing to do for that case */ ; |
773 | m.update_up (); // nothing to do for that case, except copy up |
774 | else |
774 | else |
775 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
775 | LOG (llevError, "update_object called with invalid action: %d\n", action); |
776 | |
776 | |
777 | if (op->more) |
777 | if (op->more) |
778 | update_object (op->more, action); |
778 | update_object (op->more, action); |
… | |
… | |
898 | * if some form of movement is allowed, let objects |
898 | * if some form of movement is allowed, let objects |
899 | * drop on that space. |
899 | * drop on that space. |
900 | */ |
900 | */ |
901 | if (!drop_to_ground |
901 | if (!drop_to_ground |
902 | || !map |
902 | || !map |
903 | || map->in_memory != MAP_ACTIVE |
903 | || !map->linkable () |
904 | || map->no_drop |
904 | || map->no_drop |
905 | || ms ().move_block == MOVE_ALL) |
905 | || ms ().move_block == MOVE_ALL) |
906 | { |
906 | { |
907 | while (inv) |
907 | while (inv) |
908 | inv->destroy (); |
908 | inv->destroy (); |
… | |
… | |
1004 | li->count = count; |
1004 | li->count = count; |
1005 | |
1005 | |
1006 | freelist = li; |
1006 | freelist = li; |
1007 | ++free_count; |
1007 | ++free_count; |
1008 | } |
1008 | } |
1009 | |
|
|
1010 | static struct freed_map : maptile |
|
|
1011 | { |
|
|
1012 | freed_map () |
|
|
1013 | : maptile (3, 3) |
|
|
1014 | { |
|
|
1015 | path = "<freed objects map>"; |
|
|
1016 | name = "/internal/freed_objects_map"; |
|
|
1017 | no_drop = 1; |
|
|
1018 | no_reset = 1; |
|
|
1019 | |
|
|
1020 | in_memory = MAP_ACTIVE; |
|
|
1021 | } |
|
|
1022 | |
|
|
1023 | ~freed_map () |
|
|
1024 | { |
|
|
1025 | destroy (); |
|
|
1026 | } |
|
|
1027 | } freed_map; // freed objects are moved here to avoid crashes |
|
|
1028 | |
1009 | |
1029 | void |
1010 | void |
1030 | object::do_destroy () |
1011 | object::do_destroy () |
1031 | { |
1012 | { |
1032 | if (flag [FLAG_IS_LINKED]) |
1013 | if (flag [FLAG_IS_LINKED]) |
… | |
… | |
1198 | |
1179 | |
1199 | above = 0; |
1180 | above = 0; |
1200 | below = 0; |
1181 | below = 0; |
1201 | |
1182 | |
1202 | ms.invalidate (); |
1183 | ms.invalidate (); |
1203 | |
|
|
1204 | if (map->in_memory == MAP_SAVING) |
|
|
1205 | return; |
|
|
1206 | |
1184 | |
1207 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1185 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1208 | |
1186 | |
1209 | if (object *pl = ms.player ()) |
1187 | if (object *pl = ms.player ()) |
1210 | { |
1188 | { |
… | |
… | |
2413 | return /*who->flag [FLAG_WIZ]|| */ |
2391 | return /*who->flag [FLAG_WIZ]|| */ |
2414 | (item->weight > 0 && !item->flag [FLAG_NO_PICK] && |
2392 | (item->weight > 0 && !item->flag [FLAG_NO_PICK] && |
2415 | !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); |
2393 | !item->flag [FLAG_ALIVE] && !item->invisible && (who->is_player () || item->weight < who->weight / 3)); |
2416 | } |
2394 | } |
2417 | |
2395 | |
|
|
2396 | //-GPL |
|
|
2397 | |
2418 | /* |
2398 | /* |
2419 | * create clone from object to another |
2399 | * create clone from object to another |
2420 | */ |
2400 | */ |
2421 | object * |
2401 | object * |
2422 | object::deep_clone () |
2402 | object::deep_clone () |
… | |
… | |
2634 | object::region () const |
2614 | object::region () const |
2635 | { |
2615 | { |
2636 | return map ? map->region (x, y) |
2616 | return map ? map->region (x, y) |
2637 | : region::default_region (); |
2617 | : region::default_region (); |
2638 | } |
2618 | } |
|
|
2619 | |
|
|
2620 | //+GPL |
2639 | |
2621 | |
2640 | void |
2622 | void |
2641 | object::open_container (object *new_container) |
2623 | object::open_container (object *new_container) |
2642 | { |
2624 | { |
2643 | if (container == new_container) |
2625 | if (container == new_container) |
… | |
… | |
2701 | } |
2683 | } |
2702 | // else if (!old_container->env && contr && contr->ns) |
2684 | // else if (!old_container->env && contr && contr->ns) |
2703 | // contr->ns->floorbox_reset (); |
2685 | // contr->ns->floorbox_reset (); |
2704 | } |
2686 | } |
2705 | |
2687 | |
|
|
2688 | //-GPL |
|
|
2689 | |
|
|
2690 | // prefetch some flat area around the player |
|
|
2691 | static void |
|
|
2692 | prefetch_surrounding_area (object *op, maptile *map, int range) |
|
|
2693 | { |
|
|
2694 | for (maprect *rect = map->split_to_tiles (mapwalk_buf, |
|
|
2695 | op->x - range , op->y - range , |
|
|
2696 | op->x + range + 1, op->y + range + 1); |
|
|
2697 | rect->m; |
|
|
2698 | ++rect) |
|
|
2699 | { |
|
|
2700 | rect->m->touch (); |
|
|
2701 | rect->m->activate (); |
|
|
2702 | } |
|
|
2703 | } |
|
|
2704 | |
|
|
2705 | // prefetch a generous area around the player, also up and down |
|
|
2706 | void |
|
|
2707 | object::prefetch_surrounding_maps () |
|
|
2708 | { |
|
|
2709 | prefetch_surrounding_area (this, map, 40); |
|
|
2710 | |
|
|
2711 | if (maptile *m = map->tile_available (TILE_DOWN)) |
|
|
2712 | prefetch_surrounding_area (this, m, 20); |
|
|
2713 | |
|
|
2714 | if (maptile *m = map->tile_available (TILE_UP)) |
|
|
2715 | prefetch_surrounding_area (this, m, 20); |
|
|
2716 | } |
|
|
2717 | |
|
|
2718 | //+GPL |
|
|
2719 | |
2706 | object * |
2720 | object * |
2707 | object::force_find (shstr_tmp name) |
2721 | object::force_find (shstr_tmp name) |
2708 | { |
2722 | { |
2709 | /* cycle through his inventory to look for the MARK we want to |
2723 | /* cycle through his inventory to look for the MARK we want to |
2710 | * place |
2724 | * place |
… | |
… | |
2714 | return splay (tmp); |
2728 | return splay (tmp); |
2715 | |
2729 | |
2716 | return 0; |
2730 | return 0; |
2717 | } |
2731 | } |
2718 | |
2732 | |
2719 | //-GPL |
|
|
2720 | |
|
|
2721 | void |
2733 | void |
2722 | object::force_set_timer (int duration) |
2734 | object::force_set_timer (int duration) |
2723 | { |
2735 | { |
2724 | this->duration = 1; |
2736 | this->duration = 1; |
2725 | this->speed_left = -1.f; |
2737 | this->speed_left = -1.f; |