MCPcopy Create free account
hub / github.com/DFHack/dfhack / reconcile_block_items

Function reconcile_block_items

plugins/fix-occupancy.cpp:271–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271static void reconcile_block_items(color_ostream &out, std::set<int32_t> * expected_items, df::map_block * block, bool dry_run) {
272 vector<int32_t> & block_items = block->items;
273
274 if (!expected_items) {
275 if (block_items.size()) {
276 INFO(log,out).print("{} stale item references in map block at ({}, {}, {})\n",
277 dry_run ? "would fix" : "fixing", block->map_pos.x, block->map_pos.y, block->map_pos.z);
278 if (!dry_run)
279 block_items.resize(0);
280 }
281 return;
282 }
283
284 if (!std::equal(expected_items->begin(), expected_items->end(), block_items.begin(), block_items.end())) {
285 INFO(log,out).print("{} stale item references in map block at ({}, {}, {})\n",
286 dry_run ? "would fix" : "fixing", block->map_pos.x, block->map_pos.y, block->map_pos.z);
287 if (!dry_run) {
288 block_items.resize(expected_items->size());
289 std::copy(expected_items->begin(), expected_items->end(), block_items.begin());
290 }
291 }
292}
293
294static void fix_map(color_ostream &out, bool dry_run) {
295 static const uint32_t occ_mask = df::tile_occupancy::mask_building | df::tile_occupancy::mask_unit |

Callers 1

fix_mapFunction · 0.85

Calls 5

sizeMethod · 0.45
printMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected