1
0

Proper entity removal functions

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1386 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2013-04-13 21:28:55 +00:00
parent a49c004278
commit f5842062d3
5 changed files with 32 additions and 56 deletions

View File

@@ -1370,41 +1370,6 @@ 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)
{
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)
{
NewChunk->AddEntity(a_Entity);
}
}
void cChunkMap::RemoveEntityFromChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkZ)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, ZERO_CHUNK_Y, a_ChunkZ);
if ((Chunk == NULL) && !Chunk->IsValid())
{
return;
}
Chunk->RemoveEntity(a_Entity);
}
void cChunkMap::AddEntity(cEntity * a_Entity)
{
cCSLock Lock(m_CSLayers);
@@ -1437,6 +1402,21 @@ bool cChunkMap::HasEntity(int a_UniqueID)
void cChunkMap::RemoveEntity(cEntity * a_Entity)
{
cCSLock Lock(m_CSLayers);
cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ());
if ((Chunk == NULL) && !Chunk->IsValid())
{
return;
}
Chunk->RemoveEntity(a_Entity);
}
bool cChunkMap::ForEachEntity(cEntityCallback & a_Callback)
{
cCSLock Lock(m_CSLayers);