diff options
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index aeae8f350..a11ceb060 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -2576,6 +2576,34 @@ bool cChunkMap::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinCh +bool cChunkMap::ForEachLoadedChunk(std::function<bool(int, int)> a_Callback) +{ + cCSLock Lock(m_CSLayers); + for (cChunkLayerList::const_iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) // iterate over ALL loaded layers + { + cChunkLayer * layer = *itr; + for (int x = 0; x < LAYER_SIZE; x++) + { + for (int z = 0; z < LAYER_SIZE; z++) + { + cChunkPtr p = layer->FindChunk(layer->GetX() * LAYER_SIZE + x, layer->GetZ() * LAYER_SIZE + z); + if ((p != nullptr) && p->IsValid()) // if chunk is loaded + { + if (a_Callback(p->GetPosX(), p->GetPosZ())) + { + return false; + } + } + } + } + } + return true; +} + + + + + bool cChunkMap::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) { // Convert block coords to chunks coords: |