| 35 | } |
| 36 | |
| 37 | command_result cleanmap (color_ostream &out, bool snow, bool mud, bool item_spatter) |
| 38 | { |
| 39 | // Invoked from clean(), already suspended |
| 40 | int num_blocks = 0; |
| 41 | for (auto block : world->map.map_blocks) |
| 42 | { |
| 43 | bool cleaned = false; |
| 44 | for(int x = 0; x < 16; x++) |
| 45 | { |
| 46 | for(int y = 0; y < 16; y++) |
| 47 | { |
| 48 | block->occupancy[x][y].bits.arrow_color = 0; |
| 49 | block->occupancy[x][y].bits.arrow_variant = 0; |
| 50 | } |
| 51 | } |
| 52 | for (size_t j = 0; j < block->block_events.size(); j++) |
| 53 | { |
| 54 | df::block_square_event *evt = block->block_events[j]; |
| 55 | if (evt->getType() == block_square_event_type::material_spatter) |
| 56 | { |
| 57 | // type verified - recast to subclass |
| 58 | df::block_square_event_material_spatterst *spatter = (df::block_square_event_material_spatterst *)evt; |
| 59 | |
| 60 | // filter snow |
| 61 | if(!snow |
| 62 | && spatter->mat_type == builtin_mats::WATER |
| 63 | && spatter->mat_state == (short)matter_state::Powder) |
| 64 | continue; |
| 65 | // filter mud |
| 66 | if(!mud |
| 67 | && spatter->mat_type == builtin_mats::MUD |
| 68 | && spatter->mat_state == (short)matter_state::Solid) |
| 69 | continue; |
| 70 | // save the farm plots |
| 71 | if(mud |
| 72 | && spatter->mat_type == builtin_mats::MUD |
| 73 | && spatter->mat_state == (short)matter_state::Solid) |
| 74 | { |
| 75 | for (size_t x = 0; x < 16; ++x) |
| 76 | for (size_t y = 0; y < 16; ++y) |
| 77 | clean_mud_safely(spatter, block->map_pos, df::coord(x, y, 0)); |
| 78 | continue; |
| 79 | } |
| 80 | } |
| 81 | else if (evt->getType() == block_square_event_type::item_spatter) |
| 82 | { |
| 83 | if (!item_spatter) |
| 84 | continue; |
| 85 | } |
| 86 | else |
| 87 | continue; |
| 88 | |
| 89 | delete evt; |
| 90 | block->block_events.erase(block->block_events.begin() + j); |
| 91 | j--; |
| 92 | cleaned = true; |
| 93 | } |
| 94 | num_blocks += cleaned; |