diff options
author | Mattes D <github@xoft.cz> | 2014-09-04 22:25:19 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-09-04 22:25:19 +0200 |
commit | e9dda864eae043da5664a683ab08910c3081e571 (patch) | |
tree | 040923a3d26266e1ccbce3f3ee44079c511702b9 /src/ChunkMap.cpp | |
parent | Merge pull request #1371 from DayBr3ak/master (diff) | |
parent | Fixed compilation after chunk Y removal. (diff) | |
download | cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.gz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.bz2 cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.lz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.xz cuberite-e9dda864eae043da5664a683ab08910c3081e571.tar.zst cuberite-e9dda864eae043da5664a683ab08910c3081e571.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index f14d680d4..8c765c8c9 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1775,6 +1775,38 @@ bool cChunkMap::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback +bool cChunkMap::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_Callback) +{ + // Calculate the chunk range for the box: + int MinChunkX = (int)floor(a_Box.GetMinX() / cChunkDef::Width); + int MinChunkZ = (int)floor(a_Box.GetMinZ() / cChunkDef::Width); + int MaxChunkX = (int)floor((a_Box.GetMaxX() + cChunkDef::Width) / cChunkDef::Width); + int MaxChunkZ = (int)floor((a_Box.GetMaxZ() + cChunkDef::Width) / cChunkDef::Width); + + // Iterate over each chunk in the range: + cCSLock Lock(m_CSLayers); + for (int z = MinChunkZ; z <= MaxChunkZ; z++) + { + for (int x = MinChunkX; x <= MaxChunkX; x++) + { + cChunkPtr Chunk = GetChunkNoGen(x, z); + if ((Chunk == NULL) || !Chunk->IsValid()) + { + continue; + } + if (!Chunk->ForEachEntityInBox(a_Box, a_Callback)) + { + return false; + } + } // for x + } // for z + return true; +} + + + + + void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, cVector3iArray & a_BlocksAffected) { // Don't explode if outside of Y range (prevents the following test running into unallocated memory): |