diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-06 18:58:31 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-06 18:58:31 +0200 |
commit | 4c370798d52b1b7c055c49ff4a38f73cf720c82e (patch) | |
tree | cb9c7233b4b55d8e6cb1fab410b81ea16f89d353 /source/ChunkMap.cpp | |
parent | Lua plugins can get player's equipped item (diff) | |
download | cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar.gz cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar.bz2 cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar.lz cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar.xz cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.tar.zst cuberite-4c370798d52b1b7c055c49ff4a38f73cf720c82e.zip |
Diffstat (limited to '')
-rw-r--r-- | source/ChunkMap.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index af8f09820..671eac708 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -10,6 +10,7 @@ #include "Pickup.h" #include "Chunk.h" #include "Generating/Trees.h" // used in cChunkMap::ReplaceTreeBlocks() for tree block discrimination +#include "BlockArea.h" #ifndef _WIN32 #include <cstdlib> // abs @@ -1493,6 +1494,44 @@ bool cChunkMap::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinCh +bool cChunkMap::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) +{ + // Convert block coords to chunks coords: + int MinChunkX, MaxChunkX; + int MinChunkZ, MaxChunkZ; + int MinBlockX = a_MinBlockX; + int MinBlockY = a_MinBlockY; + int MinBlockZ = a_MinBlockZ; + int MaxBlockX = a_MinBlockX + a_Area.GetSizeX(); + int MaxBlockY = a_MinBlockY + a_Area.GetSizeY(); + int MaxBlockZ = a_MinBlockZ + a_Area.GetSizeZ(); + cChunkDef::AbsoluteToRelative(MinBlockX, MinBlockY, MinBlockZ, MinChunkX, MinChunkZ); + cChunkDef::AbsoluteToRelative(MaxBlockX, MaxBlockY, MaxBlockZ, MaxChunkX, MaxChunkZ); + + // Iterate over chunks, write data into each: + bool Result = true; + cCSLock Lock(m_CSLayers); + for (int z = MinChunkZ; z <= MaxChunkZ; z++) + { + for (int x = MinChunkX; x <= MaxChunkX; x++) + { + cChunkPtr Chunk = GetChunkNoLoad(x, ZERO_CHUNK_Y, z); + if ((Chunk == NULL) || (!Chunk->IsValid())) + { + // Not present / not valid + Result = false; + continue; + } + Chunk->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes); + } // for x + } // for z + return Result; +} + + + + + void cChunkMap::GetChunkStats(int & a_NumChunksValid, int & a_NumChunksDirty) { a_NumChunksValid = 0; |