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

Function normalize_item_vector

plugins/fix-occupancy.cpp:154–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static void normalize_item_vector(color_ostream &out, df::map_block *block, bool dry_run) {
155 bool needs_sorting = false;
156 int32_t prev_id = -1;
157 for (auto item_id : block->items) {
158 // do we need to handle duplicates as well?
159 if (item_id < prev_id) {
160 needs_sorting = true;
161 break;
162 }
163 prev_id = item_id;
164 }
165 if (needs_sorting) {
166 INFO(log,out).print("{} item list for map block at ({}, {}, {})\n",
167 dry_run ? "would fix" : "fixing", block->map_pos.x, block->map_pos.y, block->map_pos.z);
168 if (!dry_run)
169 std::sort(block->items.begin(), block->items.end());
170 }
171}
172
173static void reconcile_map_tile(color_ostream &out, df::building * bld, const df::tile_occupancy & expected_occ,
174 df::tile_occupancy & block_occ, bool dry_run, int x, int y, int z)

Callers 2

fix_tileFunction · 0.85
fix_mapFunction · 0.85

Calls 4

sortFunction · 0.85
printMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected