- s16 height = scan_height - MAP_BLOCKSIZE;
- v3s16 blockpos_max, blockpos_min, relpos;
-
- getNodeBlockPosWithOffset(
- v3s16(pos.X, pos.Y - scan_height / 2, pos.Z),
- blockpos_min, relpos);
- getNodeBlockPosWithOffset(
- v3s16(pos.X, pos.Y + scan_height / 2, pos.Z),
- blockpos_max, relpos);
-
- for (s16 i = blockpos_max.Y; i > blockpos_min.Y - 1; i--) {
- std::map<v3s16, MinimapMapblock *>::iterator it =
- m_blocks_cache.find(v3s16(blockpos_max.X, i, blockpos_max.Z));
- if (it != m_blocks_cache.end()) {
- MinimapMapblock *mmblock = it->second;
- MinimapPixel *pixel = &mmblock->data[relpos.Z * MAP_BLOCKSIZE + relpos.X];
- if (pixel->n.param0 != CONTENT_AIR) {
- *pixel_height = height + pixel->height;
- return pixel;
- }
- }
-
- height -= MAP_BLOCKSIZE;
- }
-
- return NULL;
-}
-
-s16 MinimapUpdateThread::getAirCount(v3s16 pos, s16 height)
-{
- s16 air_count = 0;
- v3s16 blockpos_max, blockpos_min, relpos;
-
- getNodeBlockPosWithOffset(
- v3s16(pos.X, pos.Y - height / 2, pos.Z),
- blockpos_min, relpos);
- getNodeBlockPosWithOffset(
- v3s16(pos.X, pos.Y + height / 2, pos.Z),
- blockpos_max, relpos);
-
- for (s16 i = blockpos_max.Y; i > blockpos_min.Y - 1; i--) {
- std::map<v3s16, MinimapMapblock *>::iterator it =
- m_blocks_cache.find(v3s16(blockpos_max.X, i, blockpos_max.Z));
- if (it != m_blocks_cache.end()) {
- MinimapMapblock *mmblock = it->second;
- MinimapPixel *pixel = &mmblock->data[relpos.Z * MAP_BLOCKSIZE + relpos.X];
- air_count += pixel->air_count;
- }
+ v3s16 region(size, 0, size);
+ v3s16 pos_min(pos.X - size / 2, pos.Y - height / 2, pos.Z - size / 2);
+ v3s16 pos_max(pos_min.X + size - 1, pos.Y + height / 2, pos_min.Z + size - 1);
+ v3s16 blockpos_min = getNodeBlockPos(pos_min);
+ v3s16 blockpos_max = getNodeBlockPos(pos_max);
+
+// clear the map
+ for (int z = 0; z < size; z++)
+ for (int x = 0; x < size; x++) {
+ MinimapPixel &mmpixel = data->minimap_scan[x + z * size];
+ mmpixel.air_count = 0;
+ mmpixel.height = 0;
+ mmpixel.n = MapNode(CONTENT_AIR);