diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 21:10:57 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-18 21:10:57 +0100 |
commit | 3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3 (patch) | |
tree | f33081a1326a09879b42e579ba4d6f560aeaeb19 /source/cChunkMap.cpp | |
parent | Fixed previous commit: forgot to remove a debugging setting (diff) | |
download | cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.gz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.bz2 cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.lz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.xz cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.tar.zst cuberite-3a8d2aa421fcfa11a84a911aaaa6b5aa4e16cab3.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cChunkMap.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index c5512dd68..0657f51d3 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -351,6 +351,57 @@ int cChunkMap::GetHeight(int a_BlockX, int a_BlockZ) +void cChunkMap::FastSetBlocks(sSetBlockList & a_BlockList)
+{
+ sSetBlockList Failed;
+
+ // Process all items from a_BlockList, either successfully or by placing into Failed
+ while (!a_BlockList.empty())
+ {
+ int ChunkX = a_BlockList.front().ChunkX;
+ int ChunkZ = a_BlockList.front().ChunkZ;
+ cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
+ if ((Chunk != NULL) && Chunk->IsValid())
+ {
+ for (sSetBlockList::iterator itr = a_BlockList.begin(); itr != a_BlockList.end();)
+ {
+ if ((itr->ChunkX == ChunkX) && (itr->ChunkZ == ChunkZ))
+ {
+ Chunk->FastSetBlock(itr->x, itr->y, itr->z, itr->BlockType, itr->BlockMeta);
+ itr = a_BlockList.erase(itr);
+ }
+ else
+ {
+ ++itr;
+ }
+ } // for itr - a_BlockList[]
+ }
+ else
+ {
+ // The chunk is not valid, move all blocks within this chunk to Failed
+ for (sSetBlockList::iterator itr = a_BlockList.begin(); itr != a_BlockList.end();)
+ {
+ if ((itr->ChunkX == ChunkX) && (itr->ChunkZ == ChunkZ))
+ {
+ Failed.push_back(*itr);
+ itr = a_BlockList.erase(itr);
+ }
+ else
+ {
+ ++itr;
+ }
+ } // for itr - a_BlockList[]
+ }
+ }
+
+ // Return the failed:
+ std::swap(Failed, a_BlockList);
+}
+
+
+
+
+
void cChunkMap::Tick( float a_Dt, MTRand & a_TickRandom )
{
cCSLock Lock(m_CSLayers);
|