diff options
Diffstat (limited to 'source/ChunkMap.cpp')
-rw-r--r-- | source/ChunkMap.cpp | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index 76835ee74..6be49e399 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -1370,42 +1370,39 @@ void cChunkMap::RemoveClientFromChunks(cClientHandle * a_Client) -// TODO: This function should not be needed, remove? -void cChunkMap::MoveEntityToChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkZ) +void cChunkMap::AddEntity(cEntity * a_Entity) { cCSLock Lock(m_CSLayers); - cChunkPtr OldChunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); - if (OldChunk != NULL) - { - OldChunk->RemoveEntity(a_Entity); - } - cChunkPtr NewChunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); - if (NewChunk != NULL) + cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); + if ((Chunk == NULL) && !Chunk->IsValid()) { - NewChunk->AddEntity(a_Entity); + return; } + Chunk->AddEntity(a_Entity); } -void cChunkMap::RemoveEntityFromChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkZ) +bool cChunkMap::HasEntity(int a_UniqueID) { cCSLock Lock(m_CSLayers); - cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ); - if ((Chunk == NULL) && !Chunk->IsValid()) + for (cChunkLayerList::const_iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) { - return; + if ((*itr)->HasEntity(a_UniqueID)) + { + return true; + } } - Chunk->RemoveEntity(a_Entity); + return false; } -void cChunkMap::AddEntity(cEntity * a_Entity) +void cChunkMap::RemoveEntity(cEntity * a_Entity) { cCSLock Lock(m_CSLayers); cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); @@ -1413,24 +1410,7 @@ void cChunkMap::AddEntity(cEntity * a_Entity) { return; } - Chunk->AddEntity(a_Entity); -} - - - - - -bool cChunkMap::HasEntity(int a_UniqueID) -{ - cCSLock Lock(m_CSLayers); - for (cChunkLayerList::const_iterator itr = m_Layers.begin(); itr != m_Layers.end(); ++itr) - { - if ((*itr)->HasEntity(a_UniqueID)) - { - return true; - } - } - return false; + Chunk->RemoveEntity(a_Entity); } |