| 100 | } |
| 101 | |
| 102 | command_result cleanitems (color_ostream &out) |
| 103 | { |
| 104 | // Invoked from clean(), already suspended |
| 105 | int cleaned_items = 0, cleaned_total = 0; |
| 106 | for (auto i : world->items.other.IN_PLAY) { |
| 107 | // currently, all item classes extend item_actual, so this should be safe |
| 108 | df::item_actual *item = virtual_cast<df::item_actual>(i); |
| 109 | if (item && item->contaminants && item->contaminants->size()) |
| 110 | { |
| 111 | std::vector<df::spatter*> saved; |
| 112 | for (size_t j = 0; j < item->contaminants->size(); j++) |
| 113 | { |
| 114 | auto obj = (*item->contaminants)[j]; |
| 115 | if (obj->flags.whole & 0x8000) // DFHack-generated contaminant |
| 116 | saved.push_back(obj); |
| 117 | else |
| 118 | delete obj; |
| 119 | } |
| 120 | cleaned_items++; |
| 121 | cleaned_total += item->contaminants->size() - saved.size(); |
| 122 | item->contaminants->swap(saved); |
| 123 | } |
| 124 | } |
| 125 | if (cleaned_total) |
| 126 | out.print("Removed {} contaminants from {} items.\n", cleaned_total, cleaned_items); |
| 127 | return CR_OK; |
| 128 | } |
| 129 | |
| 130 | command_result cleanunits (color_ostream &out) |
| 131 | { |