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

Method ensureTileBlock

library/modules/Maps.cpp:372–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372df::map_block *Maps::ensureTileBlock (int32_t x, int32_t y, int32_t z)
373{
374 if (!isValidTilePos(x,y,z))
375 return NULL;
376
377 auto column = world->map.block_index[x >> 4][y >> 4];
378 auto &slot = column[z];
379 if (slot)
380 return slot;
381
382 // Find another block below
383 int z2 = z;
384 while (z2 >= 0 && !column[z2]) z2--;
385 if (z2 < 0)
386 return NULL;
387
388 slot = new df::map_block();
389 slot->region_pos = column[z2]->region_pos;
390 slot->map_pos = column[z2]->map_pos;
391 slot->map_pos.z = z;
392
393 // Assume sky
394 df::tile_designation dsgn;
395 dsgn.bits.light = true;
396 dsgn.bits.outside = true;
397
398 for (int tx = 0; tx < 16; tx++)
399 for (int ty = 0; ty < 16; ty++) {
400 slot->designation[tx][ty] = dsgn;
401 slot->temperature_1[tx][ty] = column[z2]->temperature_1[tx][ty];
402 slot->temperature_2[tx][ty] = column[z2]->temperature_2[tx][ty];
403 }
404
405 df::global::world->map.map_blocks.push_back(slot);
406 return slot;
407}
408
409df::tiletype *Maps::getTileType(int32_t x, int32_t y, int32_t z)
410{

Callers

nothing calls this directly

Calls 1

isValidTilePosFunction · 0.85

Tested by

no test coverage detected