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

Function updateInvasionMap

plugins/infinite-sky.cpp:231–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231void updateInvasionMap(color_ostream &out, int32_t new_height, df::plot_invasion_mapst& map) {
232 if (map.blockz == 0)
233 return; // Unused invasion map
234 if (map.blockz >= new_height)
235 return; // No change required
236
237 cuboid blocks(0, 0, 0, map.blockx - 1, map.blocky - 1, 0);
238 blocks.forCoord([&](df::coord bpos) {
239 // Create new vertical block
240 df::pim_blockst **new_block = new df::pim_blockst *[new_height]();
241 memcpy(new_block, map.block_index[bpos.x][bpos.y], map.blockz * sizeof(df::pim_blockst*));
242 // Fill new block with nullptr (no information)
243 std::fill_n(&new_block[map.blockz], new_height - map.blockz, nullptr);
244 delete[] map.block_index[bpos.x][bpos.y];
245 map.block_index[bpos.x][bpos.y] = new_block;
246 return true;
247 });
248
249 map.blockz = new_height;
250}
251
252void doInfiniteSky(color_ostream &out, int32_t quantity) {
253 addBlockColumns(out, quantity);

Callers 1

doInfiniteSkyFunction · 0.85

Calls 1

forCoordMethod · 0.80

Tested by

no test coverage detected