| 935 | } |
| 936 | |
| 937 | static void post_process_dug_tiles(color_ostream &out, |
| 938 | const std::vector<DFCoord> &dug_coords) { |
| 939 | for (DFCoord pos : dug_coords) { |
| 940 | if (needs_flood_unhide(pos)) { |
| 941 | // set current tile to hidden to allow flood_unhide to work on tiles |
| 942 | // that were already visible but that reveal hidden tiles when dug. |
| 943 | Maps::getTileDesignation(pos)->bits.hidden = true; |
| 944 | Lua::CallLuaModuleFunction(out, "plugins.reveal", "unhideFlood", std::make_tuple(pos)); |
| 945 | } |
| 946 | |
| 947 | df::tile_occupancy &to = *Maps::getTileOccupancy(pos); |
| 948 | if (to.bits.unit || to.bits.item) { |
| 949 | DFCoord resting_pos = simulate_fall(pos); |
| 950 | if (resting_pos == pos) |
| 951 | continue; |
| 952 | |
| 953 | if (!Maps::ensureTileBlock(resting_pos)) { |
| 954 | out.printerr("No valid tile beneath ({},{},{}) can't move" |
| 955 | " units and items to floor", |
| 956 | pos.x, pos.y, pos.z); |
| 957 | continue; |
| 958 | } |
| 959 | |
| 960 | if (to.bits.unit) { |
| 961 | std::vector<df::unit*> units; |
| 962 | Units::getUnitsInBox(units, pos.x, pos.y, pos.z, |
| 963 | pos.x, pos.y, pos.z); |
| 964 | for (auto unit : units) |
| 965 | Units::teleport(unit, resting_pos); |
| 966 | } |
| 967 | |
| 968 | if (to.bits.item) { |
| 969 | std::vector<df::item*> items; |
| 970 | if (auto b = Maps::ensureTileBlock(pos)) { |
| 971 | for (auto item_id : b->items) { |
| 972 | auto item = df::item::find(item_id); |
| 973 | if (item && item->pos == pos) |
| 974 | items.emplace_back(item); |
| 975 | } |
| 976 | } |
| 977 | if (!items.empty()) { |
| 978 | for (auto item : items) |
| 979 | Items::moveToGround(item, resting_pos); |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | // refresh block metadata and flows |
| 985 | Maps::enableBlockUpdates(Maps::getTileBlock(pos), true, true); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | static bool get_options(color_ostream &out, |
| 990 | dig_now_options &opts, |
no test coverage detected