summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-09-24 16:43:31 +0200
committertycho <work.tycho@gmail.com>2015-09-24 16:54:32 +0200
commit6e86d20f730aa46e0fa6b13b26a3b2586d21e513 (patch)
treef9067a30d91f764c92a5b77c2bca2cf00dd53162 /src/ChunkMap.cpp
parentMerge pull request #2488 from cuberite/ChatFlag (diff)
downloadcuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar.gz
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar.bz2
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar.lz
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar.xz
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.tar.zst
cuberite-6e86d20f730aa46e0fa6b13b26a3b2586d21e513.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp28
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: