diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-13 10:56:12 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-13 10:56:12 +0200 |
commit | a2f6243b21b60d010be84c0747a98f731835e7ae (patch) | |
tree | 7750d88b2ac0d4c00f99f9b5a850c110c140c5a0 /source/World.cpp | |
parent | Core: Removed /home since other plugins want to use it (diff) | |
download | cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar.gz cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar.bz2 cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar.lz cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar.xz cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.tar.zst cuberite-a2f6243b21b60d010be84c0747a98f731835e7ae.zip |
Diffstat (limited to 'source/World.cpp')
-rw-r--r-- | source/World.cpp | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/source/World.cpp b/source/World.cpp index fd4f5af6e..7180213fe 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -1032,16 +1032,16 @@ int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ) -void cWorld::SetBlock( int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ) +void cWorld::SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { if(a_BlockType == E_BLOCK_AIR) { - BlockHandler(GetBlock(a_X, a_Y, a_Z))->OnDestroyed(this, a_X, a_Y, a_Z); + BlockHandler(GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnDestroyed(this, a_BlockX, a_BlockY, a_BlockZ); } - m_ChunkMap->SetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta); + m_ChunkMap->SetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); - GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z); - BlockHandler(a_BlockType)->OnPlaced(this, a_X, a_Y, a_Z, a_BlockMeta); + GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ); + BlockHandler(a_BlockType)->OnPlaced(this, a_BlockX, a_BlockY, a_BlockZ, a_BlockMeta); } @@ -2094,45 +2094,62 @@ void cWorld::GetChunkStats(int & a_NumValid, int & a_NumDirty, int & a_NumInLigh + void cWorld::TickQueuedBlocks(float a_Dt) { - if(m_BlockTickQueue.empty()) + if (m_BlockTickQueue.empty()) + { return; + } m_BlockTickQueueCopy.clear(); m_BlockTickQueue.swap(m_BlockTickQueueCopy); - for(std::vector<BlockTickQueueItem *>::iterator itr = m_BlockTickQueueCopy.begin(); itr != m_BlockTickQueueCopy.end(); itr++) + for (std::vector<BlockTickQueueItem *>::iterator itr = m_BlockTickQueueCopy.begin(); itr != m_BlockTickQueueCopy.end(); itr++) { BlockTickQueueItem *Block = (*itr); Block->ToWait -= a_Dt; - if(Block->ToWait <= 0) + if (Block->ToWait <= 0) { BlockHandler(GetBlock(Block->X, Block->Y, Block->Z))->OnUpdate(this, Block->X, Block->Y, Block->Z); - delete Block; //We donīt have to remove it from the vector, this will happen automatically on the next tick - }else{ + delete Block; //We don't have to remove it from the vector, this will happen automatically on the next tick + } + else + { m_BlockTickQueue.push_back(Block); //Keep the block in the queue } - } - + } // for itr - m_BlockTickQueueCopy[] } -void cWorld::QueueBlockForTick(int a_X, int a_Y, int a_Z, float a_Time) + + + +void cWorld::QueueBlockForTick(int a_BlockX, int a_BlockY, int a_BlockZ, float a_TimeToWait) { - BlockTickQueueItem *Block = new BlockTickQueueItem; - Block->X = a_X; - Block->Y = a_Y; - Block->Z = a_Z; - Block->ToWait = a_Time; + BlockTickQueueItem * Block = new BlockTickQueueItem; + Block->X = a_BlockX; + Block->Y = a_BlockY; + Block->Z = a_BlockZ; + Block->ToWait = a_TimeToWait; m_BlockTickQueue.push_back(Block); } -bool cWorld::IsBlockDirectlyWatered(int a_X, int a_Y, int a_Z) + + + +bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ) { - return IsBlockWater(GetBlock(a_X - 1, a_Y, a_Z)) - || IsBlockWater(GetBlock(a_X + 1, a_Y, a_Z)) - || IsBlockWater(GetBlock(a_X, a_Y, a_Z - 1)) - || IsBlockWater(GetBlock(a_X, a_Y, a_Z + 1)); -}
\ No newline at end of file + return ( + IsBlockWater(GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ)) || + IsBlockWater(GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ)) || + IsBlockWater(GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1)) || + IsBlockWater(GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1)) + ); +} + + + + + |