diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-15 21:18:11 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-15 21:18:11 +0100 |
commit | 8090c13cde2d61a0330f1e262de7526318a0965d (patch) | |
tree | 8a5f53d6113c25ee49caacea5c52548dc1585f91 /source/Chunk.cpp | |
parent | Doxygen: Alpha-sorted class member docs (diff) | |
download | cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.gz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.bz2 cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.lz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.xz cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.tar.zst cuberite-8090c13cde2d61a0330f1e262de7526318a0965d.zip |
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r-- | source/Chunk.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 8165ee5b6..d8dfb79f8 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -509,18 +509,17 @@ void cChunk::CheckBlocks(void) { return; } - std::deque< unsigned int > ToTickBlocks = m_ToTickBlocks; - m_ToTickBlocks.clear(); + std::vector<unsigned int> ToTickBlocks; + std::swap(m_ToTickBlocks, ToTickBlocks); Lock2.Unlock(); - for (std::deque< unsigned int >::const_iterator itr = ToTickBlocks.begin(); itr != ToTickBlocks.end(); ++itr) + for (std::vector<unsigned int>::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) { unsigned int index = (*itr); Vector3i BlockPos = IndexToCoordinate(index); - Vector3i WorldPos = PositionToWorldPosition( BlockPos ); cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(m_World, WorldPos.x, WorldPos.y, WorldPos.z); + Handler->Check(BlockPos.x, BlockPos.y, BlockPos.z, *this); } // for itr - ToTickBlocks[] } @@ -827,9 +826,9 @@ void cChunk::GrowCactus(int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks) -bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) +bool cChunk::UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const { - if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) + if ((a_RelY < 0) || (a_RelY >= cChunkDef::Height)) { LOGWARNING("UnboundedRelGetBlock(): requesting a block with a_RelY out of range: %d", a_RelY); return false; @@ -1821,20 +1820,33 @@ bool cChunk::GetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_ -BLOCKTYPE cChunk::GetBlock( int a_X, int a_Y, int a_Z ) +BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { - if ((a_X < 0) || (a_X >= Width) || (a_Y < 0) || (a_Y >= Height) || (a_Z < 0) || (a_Z >= Width)) return 0; // Clip + if ( + (a_RelX < 0) || (a_RelX >= Width) || + (a_RelY < 0) || (a_RelY >= Height) || + (a_RelZ < 0) || (a_RelZ >= Width) + ) + { + ASSERT(!"GetBlock(x, y, z) out of bounds!"); + return 0; // Clip + } - return m_BlockTypes[ MakeIndexNoCheck( a_X, a_Y, a_Z ) ]; + return m_BlockTypes[MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ)]; } -BLOCKTYPE cChunk::GetBlock( int a_BlockIdx ) +BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const { - if( a_BlockIdx < 0 || a_BlockIdx >= NumBlocks ) return 0; + if ((a_BlockIdx < 0) || (a_BlockIdx >= NumBlocks)) + { + ASSERT(!"GetBlock(idx) out of bounds!"); + return 0; + } + return m_BlockTypes[ a_BlockIdx ]; } |