From 10752d2f35b729b1e84219b4075c9e77727ab1b4 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 8 Feb 2012 19:49:57 +0000 Subject: Removed unused code git-svn-id: http://mc-server.googlecode.com/svn/trunk@249 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 157 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 44 deletions(-) (limited to 'source/cChunk.cpp') diff --git a/source/cChunk.cpp b/source/cChunk.cpp index 6bf5172ae..3b0dd519c 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -436,6 +436,10 @@ char cChunk::GetHeight( int a_X, int a_Z ) return 0; } + + + + void cChunk::CreateBlockEntities() { m_pState->BlockListCriticalSection.Lock(); @@ -475,6 +479,10 @@ void cChunk::CreateBlockEntities() m_pState->BlockListCriticalSection.Unlock(); } + + + + void cChunk::CalculateHeightmap() { m_bCalculateHeightmap = false; @@ -495,6 +503,10 @@ void cChunk::CalculateHeightmap() } } + + + + void cChunk::CalculateLighting() { // Calculate sunlight @@ -538,6 +550,10 @@ void cChunk::CalculateLighting() m_bCalculateLighting = false; } + + + + void cChunk::SpreadLight(char* a_LightBuffer) { // Spread the sunlight @@ -643,12 +659,20 @@ void cChunk::SpreadLight(char* a_LightBuffer) if( bCalcBack ) m_World->ReSpreadLighting( BackChunk ); } + + + + void cChunk::AsyncUnload( cClientHandle* a_Client ) { m_pState->UnloadQuery.remove( a_Client ); // Make sure this client is only in the list once m_pState->UnloadQuery.push_back( a_Client ); } + + + + void cChunk::Send( cClientHandle* a_Client ) { cPacket_PreChunk PreChunk; @@ -666,12 +690,15 @@ void cChunk::Send( cClientHandle* a_Client ) m_pState->BlockListCriticalSection.Unlock(); } + + + + void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ) { - if(a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16) + if (a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16) { - //printf(">>>>>>>>>>>>>>>> CLIPPED SETBLOCK %i %i %i\n", a_X, a_Y, a_Z ); - return; // Clip + return; // Clip } int index = a_Y + (a_Z * 128) + (a_X * 128 * 16); @@ -681,49 +708,54 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block SetLight( m_BlockMeta, index, a_BlockMeta ); - if( OldBlockType != a_BlockType || OldBlockMeta != a_BlockMeta ) + if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta)) + { + return; + } + + //LOG("Old: %i %i New: %i %i", OldBlockType, OldBlockMeta, a_BlockType, a_BlockMeta ); + cCSLock Lock(m_pState->BlockListCriticalSection); + m_pState->PendingSendBlocks.push_back( index ); + + m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X+1, a_Y, a_Z ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X-1, a_Y, a_Z ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y+1, a_Z ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y-1, a_Z ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z+1 ) ]++; + m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z-1 ) ]++; + + cBlockEntity* BlockEntity = GetBlockEntity( a_X + m_PosX*16, a_Y+m_PosY*128, a_Z+m_PosZ*16 ); + if( BlockEntity ) + { + BlockEntity->Destroy(); + RemoveBlockEntity( BlockEntity ); + delete BlockEntity; + } + switch( a_BlockType ) { - //LOG("Old: %i %i New: %i %i", OldBlockType, OldBlockMeta, a_BlockType, a_BlockMeta ); - m_pState->BlockListCriticalSection.Lock(); - m_pState->PendingSendBlocks.push_back( index ); - - m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X+1, a_Y, a_Z ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X-1, a_Y, a_Z ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y+1, a_Z ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y-1, a_Z ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z+1 ) ]++; - m_pState->ToTickBlocks[ MakeIndex( a_X, a_Y, a_Z-1 ) ]++; - - cBlockEntity* BlockEntity = GetBlockEntity( a_X + m_PosX*16, a_Y+m_PosY*128, a_Z+m_PosZ*16 ); - if( BlockEntity ) - { - BlockEntity->Destroy(); - RemoveBlockEntity( BlockEntity ); - delete BlockEntity; - } - switch( a_BlockType ) - { case E_BLOCK_CHEST: + { AddBlockEntity( new cChestEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) ); break; + } case E_BLOCK_FURNACE: + { AddBlockEntity( new cFurnaceEntity( a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) ); break; + } case E_BLOCK_SIGN_POST: case E_BLOCK_WALLSIGN: + { AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX*16, a_Y + m_PosY*128, a_Z + m_PosZ*16, this ) ); break; - default: - break; - }; + } + } // switch (a_BlockType) +} + + - m_pState->BlockListCriticalSection.Unlock(); - } - //RecalculateHeightmap(); - //RecalculateLighting(); -} void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ) { @@ -754,6 +786,10 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B RecalculateHeightmap(); } + + + + void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client ) { if( a_Client == 0 ) @@ -781,6 +817,10 @@ void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client ) } } + + + + void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity ) { m_pState->BlockListCriticalSection.Lock(); @@ -788,6 +828,10 @@ void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity ) m_pState->BlockListCriticalSection.Unlock(); } + + + + void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity ) { m_pState->BlockListCriticalSection.Lock(); @@ -795,6 +839,10 @@ void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity ) m_pState->BlockListCriticalSection.Unlock(); } + + + + void cChunk::AddClient( cClientHandle* a_Client ) { m_pState->LoadedByClient.remove( a_Client ); @@ -809,6 +857,10 @@ void cChunk::AddClient( cClientHandle* a_Client ) UnlockEntities(); } + + + + void cChunk::RemoveClient( cClientHandle* a_Client ) { m_pState->LoadedByClient.remove( a_Client ); @@ -826,6 +878,10 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) } } + + + + void cChunk::AddEntity( cEntity & a_Entity ) { LockEntities(); @@ -833,6 +889,10 @@ void cChunk::AddEntity( cEntity & a_Entity ) UnlockEntities(); } + + + + bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ ) { LockEntities(); @@ -853,16 +913,28 @@ bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ ) return true; } + + + + void cChunk::LockEntities() { m_EntitiesCriticalSection->Lock(); } + + + + void cChunk::UnlockEntities() { m_EntitiesCriticalSection->Unlock(); } + + + + char cChunk::GetBlock( int a_X, int a_Y, int a_Z ) { if(a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16) return 0; // Clip @@ -871,12 +943,20 @@ char cChunk::GetBlock( int a_X, int a_Y, int a_Z ) return m_BlockType[index]; } + + + + char cChunk::GetBlock( int a_BlockIdx ) { if( a_BlockIdx < 0 || a_BlockIdx >= c_NumBlocks ) return 0; return m_BlockType[ a_BlockIdx ]; } + + + + cBlockEntity* cChunk::GetBlockEntity( int a_X, int a_Y, int a_Z ) { m_pState->BlockListCriticalSection.Lock(); @@ -992,17 +1072,6 @@ bool cChunk::LoadFromDisk() -bool cChunk::SaveToDisk() -{ - assert(!"Old save format not supported anymore"); // Remove the call to this function - - return false; //no more saving old format! -} - - - - - void cChunk::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ ) const { for( std::list< cClientHandle* >::const_iterator itr = m_pState->LoadedByClient.begin(); itr != m_pState->LoadedByClient.end(); ++itr ) -- cgit v1.2.3