summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authortycho <tycho@localhost>2015-03-21 18:17:26 +0100
committertycho <tycho@localhost>2015-05-07 04:47:46 +0200
commit448df85e569e85e1b4da4eac685950273f30ae1f (patch)
tree045241fff430ae2ffe0b97d7151e44293ad76467 /src/ChunkMap.cpp
parentMerge pull request #1946 from SafwatHalaby/lean (diff)
downloadcuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar.gz
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar.bz2
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar.lz
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar.xz
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.tar.zst
cuberite-448df85e569e85e1b4da4eac685950273f30ae1f.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index b84b8dc3d..edff6baf1 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -791,6 +791,28 @@ bool cChunkMap::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callb
}
+bool cChunkMap::DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback)
+{
+ int ChunkX, ChunkZ;
+ cChunkDef::BlockToChunk(a_BlockPos.x, a_BlockPos.z, ChunkX, ChunkZ);
+ struct cCallBackWrapper : cChunkCallback
+ {
+ cCallBackWrapper(std::function<bool(cChunk &)> a_InnerCallback) :
+ m_Callback(a_InnerCallback)
+ {
+ }
+
+ virtual bool Item(cChunk * a_Chunk)
+ {
+ return m_Callback(*a_Chunk);
+ }
+
+ private:
+ std::function<bool(cChunk &)> m_Callback;
+ } callback(a_Callback);
+ return DoWithChunk(ChunkX, ChunkZ, callback);
+}
+