Add new "ForEach" function: ForEachLoadedChunk.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user