diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-13 23:28:55 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-04-13 23:28:55 +0200 |
commit | f5842062d3f9594d8f22f8938915194d20ebdf5f (patch) | |
tree | 54a92af49ef0e3cff48a22259183399d409c3f89 /source/ChunkMap.cpp | |
parent | Rewritten entities so that they are owned by individual chunks and ticked within their chunk's Tick() (diff) | |
download | cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar.gz cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar.bz2 cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar.lz cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar.xz cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.tar.zst cuberite-f5842062d3f9594d8f22f8938915194d20ebdf5f.zip |
Diffstat (limited to '')
-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); } |