Removed unused code
git-svn-id: http://mc-server.googlecode.com/svn/trunk@249 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
a204e33250
commit
10752d2f35
@ -436,6 +436,10 @@ char cChunk::GetHeight( int a_X, int a_Z )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::CreateBlockEntities()
|
void cChunk::CreateBlockEntities()
|
||||||
{
|
{
|
||||||
m_pState->BlockListCriticalSection.Lock();
|
m_pState->BlockListCriticalSection.Lock();
|
||||||
@ -475,6 +479,10 @@ void cChunk::CreateBlockEntities()
|
|||||||
m_pState->BlockListCriticalSection.Unlock();
|
m_pState->BlockListCriticalSection.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::CalculateHeightmap()
|
void cChunk::CalculateHeightmap()
|
||||||
{
|
{
|
||||||
m_bCalculateHeightmap = false;
|
m_bCalculateHeightmap = false;
|
||||||
@ -495,6 +503,10 @@ void cChunk::CalculateHeightmap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::CalculateLighting()
|
void cChunk::CalculateLighting()
|
||||||
{
|
{
|
||||||
// Calculate sunlight
|
// Calculate sunlight
|
||||||
@ -538,6 +550,10 @@ void cChunk::CalculateLighting()
|
|||||||
m_bCalculateLighting = false;
|
m_bCalculateLighting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::SpreadLight(char* a_LightBuffer)
|
void cChunk::SpreadLight(char* a_LightBuffer)
|
||||||
{
|
{
|
||||||
// Spread the sunlight
|
// Spread the sunlight
|
||||||
@ -643,12 +659,20 @@ void cChunk::SpreadLight(char* a_LightBuffer)
|
|||||||
if( bCalcBack ) m_World->ReSpreadLighting( BackChunk );
|
if( bCalcBack ) m_World->ReSpreadLighting( BackChunk );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::AsyncUnload( cClientHandle* a_Client )
|
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.remove( a_Client ); // Make sure this client is only in the list once
|
||||||
m_pState->UnloadQuery.push_back( a_Client );
|
m_pState->UnloadQuery.push_back( a_Client );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::Send( cClientHandle* a_Client )
|
void cChunk::Send( cClientHandle* a_Client )
|
||||||
{
|
{
|
||||||
cPacket_PreChunk PreChunk;
|
cPacket_PreChunk PreChunk;
|
||||||
@ -666,12 +690,15 @@ void cChunk::Send( cClientHandle* a_Client )
|
|||||||
m_pState->BlockListCriticalSection.Unlock();
|
m_pState->BlockListCriticalSection.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
|
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);
|
int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
|
||||||
@ -681,50 +708,55 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
|
|||||||
|
|
||||||
SetLight( m_BlockMeta, index, a_BlockMeta );
|
SetLight( m_BlockMeta, index, a_BlockMeta );
|
||||||
|
|
||||||
if( OldBlockType != a_BlockType || OldBlockMeta != a_BlockMeta )
|
if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta))
|
||||||
{
|
{
|
||||||
//LOG("Old: %i %i New: %i %i", OldBlockType, OldBlockMeta, a_BlockType, a_BlockMeta );
|
return;
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
m_pState->BlockListCriticalSection.Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//RecalculateHeightmap();
|
//LOG("Old: %i %i New: %i %i", OldBlockType, OldBlockMeta, a_BlockType, a_BlockMeta );
|
||||||
//RecalculateLighting();
|
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 )
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
} // switch (a_BlockType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
|
void cChunk::FastSetBlock( 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)
|
||||||
@ -754,6 +786,10 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
|
|||||||
RecalculateHeightmap();
|
RecalculateHeightmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
|
void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
|
||||||
{
|
{
|
||||||
if( a_Client == 0 )
|
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 )
|
void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity )
|
||||||
{
|
{
|
||||||
m_pState->BlockListCriticalSection.Lock();
|
m_pState->BlockListCriticalSection.Lock();
|
||||||
@ -788,6 +828,10 @@ void cChunk::AddBlockEntity( cBlockEntity* a_BlockEntity )
|
|||||||
m_pState->BlockListCriticalSection.Unlock();
|
m_pState->BlockListCriticalSection.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
|
void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
|
||||||
{
|
{
|
||||||
m_pState->BlockListCriticalSection.Lock();
|
m_pState->BlockListCriticalSection.Lock();
|
||||||
@ -795,6 +839,10 @@ void cChunk::RemoveBlockEntity( cBlockEntity* a_BlockEntity )
|
|||||||
m_pState->BlockListCriticalSection.Unlock();
|
m_pState->BlockListCriticalSection.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::AddClient( cClientHandle* a_Client )
|
void cChunk::AddClient( cClientHandle* a_Client )
|
||||||
{
|
{
|
||||||
m_pState->LoadedByClient.remove( a_Client );
|
m_pState->LoadedByClient.remove( a_Client );
|
||||||
@ -809,6 +857,10 @@ void cChunk::AddClient( cClientHandle* a_Client )
|
|||||||
UnlockEntities();
|
UnlockEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::RemoveClient( cClientHandle* a_Client )
|
void cChunk::RemoveClient( cClientHandle* a_Client )
|
||||||
{
|
{
|
||||||
m_pState->LoadedByClient.remove( a_Client );
|
m_pState->LoadedByClient.remove( a_Client );
|
||||||
@ -826,6 +878,10 @@ void cChunk::RemoveClient( cClientHandle* a_Client )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::AddEntity( cEntity & a_Entity )
|
void cChunk::AddEntity( cEntity & a_Entity )
|
||||||
{
|
{
|
||||||
LockEntities();
|
LockEntities();
|
||||||
@ -833,6 +889,10 @@ void cChunk::AddEntity( cEntity & a_Entity )
|
|||||||
UnlockEntities();
|
UnlockEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
|
bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
|
||||||
{
|
{
|
||||||
LockEntities();
|
LockEntities();
|
||||||
@ -853,16 +913,28 @@ bool cChunk::RemoveEntity( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::LockEntities()
|
void cChunk::LockEntities()
|
||||||
{
|
{
|
||||||
m_EntitiesCriticalSection->Lock();
|
m_EntitiesCriticalSection->Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::UnlockEntities()
|
void cChunk::UnlockEntities()
|
||||||
{
|
{
|
||||||
m_EntitiesCriticalSection->Unlock();
|
m_EntitiesCriticalSection->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char cChunk::GetBlock( int a_X, int a_Y, int a_Z )
|
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
|
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];
|
return m_BlockType[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char cChunk::GetBlock( int a_BlockIdx )
|
char cChunk::GetBlock( int a_BlockIdx )
|
||||||
{
|
{
|
||||||
if( a_BlockIdx < 0 || a_BlockIdx >= c_NumBlocks ) return 0;
|
if( a_BlockIdx < 0 || a_BlockIdx >= c_NumBlocks ) return 0;
|
||||||
return m_BlockType[ a_BlockIdx ];
|
return m_BlockType[ a_BlockIdx ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cBlockEntity* cChunk::GetBlockEntity( int a_X, int a_Y, int a_Z )
|
cBlockEntity* cChunk::GetBlockEntity( int a_X, int a_Y, int a_Z )
|
||||||
{
|
{
|
||||||
m_pState->BlockListCriticalSection.Lock();
|
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
|
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 )
|
for( std::list< cClientHandle* >::const_iterator itr = m_pState->LoadedByClient.begin(); itr != m_pState->LoadedByClient.end(); ++itr )
|
||||||
|
@ -77,7 +77,6 @@ public:
|
|||||||
inline void RecalculateHeightmap() { m_bCalculateHeightmap = true; } // Recalculate heightmap next tick
|
inline void RecalculateHeightmap() { m_bCalculateHeightmap = true; } // Recalculate heightmap next tick
|
||||||
void SpreadLight(char* a_LightBuffer);
|
void SpreadLight(char* a_LightBuffer);
|
||||||
|
|
||||||
bool SaveToDisk();
|
|
||||||
bool LoadFromDisk();
|
bool LoadFromDisk();
|
||||||
|
|
||||||
// Broadcasts to all clients that have loaded this chunk
|
// Broadcasts to all clients that have loaded this chunk
|
||||||
@ -121,8 +120,6 @@ private:
|
|||||||
void LoadFromJson( const Json::Value & a_Value );
|
void LoadFromJson( const Json::Value & a_Value );
|
||||||
void SaveToJson( Json::Value & a_Value );
|
void SaveToJson( Json::Value & a_Value );
|
||||||
|
|
||||||
void GenerateTerrain();
|
|
||||||
void GenerateFoliage();
|
|
||||||
void CalculateLighting(); // Recalculate right now
|
void CalculateLighting(); // Recalculate right now
|
||||||
void CalculateHeightmap();
|
void CalculateHeightmap();
|
||||||
void SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
|
void SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff);
|
||||||
@ -152,6 +149,11 @@ private:
|
|||||||
cCriticalSection* m_EntitiesCriticalSection;
|
cCriticalSection* m_EntitiesCriticalSection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if C_CHUNK_USE_INLINE
|
#if C_CHUNK_USE_INLINE
|
||||||
# include "cChunk.inl.h"
|
# include "cChunk.inl.h"
|
||||||
#endif
|
#endif
|
@ -59,6 +59,7 @@ cChunkMap::cChunkMap(cWorld* a_World )
|
|||||||
|
|
||||||
cChunkMap::~cChunkMap()
|
cChunkMap::~cChunkMap()
|
||||||
{
|
{
|
||||||
|
// TODO: delete layers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,11 +128,6 @@ cChunkMap::cChunkLayer* cChunkMap::AddLayer( const cChunkLayer & a_Layer )
|
|||||||
|
|
||||||
void cChunkMap::AddChunk( cChunk* a_Chunk )
|
void cChunkMap::AddChunk( cChunk* a_Chunk )
|
||||||
{
|
{
|
||||||
/* // OLD
|
|
||||||
m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].push_back( a_Chunk );
|
|
||||||
*/
|
|
||||||
|
|
||||||
// NEW
|
|
||||||
const int LayerX = (int)(floorf((float)a_Chunk->GetPosX() / (float)(LAYER_SIZE)));
|
const int LayerX = (int)(floorf((float)a_Chunk->GetPosX() / (float)(LAYER_SIZE)));
|
||||||
const int LayerZ = (int)(floorf((float)a_Chunk->GetPosZ() / (float)(LAYER_SIZE)));
|
const int LayerZ = (int)(floorf((float)a_Chunk->GetPosZ() / (float)(LAYER_SIZE)));
|
||||||
cChunkLayer* FoundLayer = GetLayer( LayerX, LayerZ );
|
cChunkLayer* FoundLayer = GetLayer( LayerX, LayerZ );
|
||||||
@ -141,16 +137,20 @@ void cChunkMap::AddChunk( cChunk* a_Chunk )
|
|||||||
NewLayer.m_X = LayerX;
|
NewLayer.m_X = LayerX;
|
||||||
NewLayer.m_Z = LayerZ;
|
NewLayer.m_Z = LayerZ;
|
||||||
FoundLayer = AddLayer( NewLayer );
|
FoundLayer = AddLayer( NewLayer );
|
||||||
LOGWARN("Created new layer %i %i (total layers %i)", LayerX, LayerZ, m_NumLayers );
|
LOG("Created new layer [%i %i] (total layers %i)", LayerX, LayerZ, m_NumLayers );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get local coordinates in layer
|
//Get local coordinates in layer
|
||||||
const int LocalX = a_Chunk->GetPosX() - LayerX * LAYER_SIZE;
|
const int LocalX = a_Chunk->GetPosX() - LayerX * LAYER_SIZE;
|
||||||
const int LocalZ = a_Chunk->GetPosZ() - LayerZ * LAYER_SIZE;
|
const int LocalZ = a_Chunk->GetPosZ() - LayerZ * LAYER_SIZE;
|
||||||
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk )
|
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk )
|
||||||
|
{
|
||||||
LOGWARN("WARNING: Added chunk to layer while it was already loaded!");
|
LOGWARN("WARNING: Added chunk to layer while it was already loaded!");
|
||||||
|
}
|
||||||
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_Compressed )
|
if( FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_Compressed )
|
||||||
|
{
|
||||||
LOGWARN("WARNING: Added chunk to layer while a compressed version exists!");
|
LOGWARN("WARNING: Added chunk to layer while a compressed version exists!");
|
||||||
|
}
|
||||||
FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk = a_Chunk;
|
FoundLayer->m_Chunks[ LocalX + LocalZ * LAYER_SIZE ].m_LiveChunk = a_Chunk;
|
||||||
FoundLayer->m_NumChunksLoaded++;
|
FoundLayer->m_NumChunksLoaded++;
|
||||||
}
|
}
|
||||||
@ -161,11 +161,6 @@ void cChunkMap::AddChunk( cChunk* a_Chunk )
|
|||||||
|
|
||||||
void cChunkMap::RemoveChunk( cChunk* a_Chunk )
|
void cChunkMap::RemoveChunk( cChunk* a_Chunk )
|
||||||
{
|
{
|
||||||
/* // OLD
|
|
||||||
m_Nodes[ MakeHash( a_Chunk->GetPosX(), a_Chunk->GetPosZ() ) ].erase( a_Chunk );
|
|
||||||
*/
|
|
||||||
|
|
||||||
// NEW
|
|
||||||
cChunkLayer* Layer = GetLayerForChunk( a_Chunk->GetPosX(), a_Chunk->GetPosZ() );
|
cChunkLayer* Layer = GetLayerForChunk( a_Chunk->GetPosX(), a_Chunk->GetPosZ() );
|
||||||
if( Layer )
|
if( Layer )
|
||||||
{
|
{
|
||||||
@ -392,10 +387,8 @@ void cChunkMap::UnloadUnusedChunks()
|
|||||||
SaveLayer( &Layer );
|
SaveLayer( &Layer );
|
||||||
for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i ) // Free all chunk data for layer
|
for( int i = 0; i < LAYER_SIZE*LAYER_SIZE; ++i ) // Free all chunk data for layer
|
||||||
{
|
{
|
||||||
if( Layer.m_Chunks[i].m_Compressed )
|
delete [] Layer.m_Chunks[i].m_Compressed;
|
||||||
delete [] Layer.m_Chunks[i].m_Compressed;
|
delete Layer.m_Chunks[i].m_LiveChunk;
|
||||||
if( Layer.m_Chunks[i].m_LiveChunk )
|
|
||||||
delete Layer.m_Chunks[i].m_LiveChunk;
|
|
||||||
}
|
}
|
||||||
if( RemoveLayer( &Layer ) ) l--;
|
if( RemoveLayer( &Layer ) ) l--;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ public:
|
|||||||
~cChunkMap();
|
~cChunkMap();
|
||||||
|
|
||||||
void AddChunk( cChunk* a_Chunk );
|
void AddChunk( cChunk* a_Chunk );
|
||||||
unsigned int MakeHash( int a_X, int a_Z );
|
|
||||||
|
|
||||||
cChunk* GetChunk( int a_X, int a_Y, int a_Z );
|
cChunk* GetChunk( int a_X, int a_Y, int a_Z );
|
||||||
void RemoveChunk( cChunk* a_Chunk );
|
void RemoveChunk( cChunk* a_Chunk );
|
||||||
|
Loading…
Reference in New Issue
Block a user