diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-02 21:19:57 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2011-11-02 21:19:57 +0100 |
commit | dada2bea27bbc0b5dec68e8089ce5b8c296baabd (patch) | |
tree | c87790fa9c5ce89bddb126c94a3a90fb13ce9478 /source/cChunk.cpp | |
parent | Fixed player spawn teleport postion. (diff) | |
download | cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar.gz cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar.bz2 cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar.lz cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar.xz cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.tar.zst cuberite-dada2bea27bbc0b5dec68e8089ce5b8c296baabd.zip |
Diffstat (limited to 'source/cChunk.cpp')
-rw-r--r-- | source/cChunk.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp index 430fa6fc8..420ba078f 100644 --- a/source/cChunk.cpp +++ b/source/cChunk.cpp @@ -70,14 +70,19 @@ cChunk::~cChunk() m_pState->m_BlockEntities.clear();
LockEntities();
- for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr)
+ if( m_pState->m_Entities.size() > 0 )
{
- if( (*itr)->GetEntityType() != cEntity::E_PLAYER )
+ EntityList Entities = m_pState->m_Entities; // Copy list to a temporary list
+ for( EntityList::iterator itr = Entities.begin(); itr != Entities.end(); ++itr)
{
- m_World->AddToRemoveEntityQueue( **itr ); // World also destroys the entity
+ if( (*itr)->GetEntityType() != cEntity::E_PLAYER )
+ {
+ (*itr)->RemoveFromChunk( this );
+ (*itr)->Destroy();
+ }
}
+ m_pState->m_Entities.clear();
}
- m_pState->m_Entities.clear();
UnlockEntities();
if( m_EntitiesCriticalSection )
@@ -1027,14 +1032,17 @@ void cChunk::RemoveClient( cClientHandle* a_Client ) {
m_pState->m_LoadedByClient.remove( a_Client );
- LockEntities();
- for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr )
+ if( !a_Client->IsDestroyed() )
{
- LOG("%i %i %i Destroying on %s", m_PosX, m_PosY, m_PosZ, a_Client->GetUsername() );
- cPacket_DestroyEntity DestroyEntity( *itr );
- a_Client->Send( DestroyEntity );
+ LockEntities();
+ for( EntityList::iterator itr = m_pState->m_Entities.begin(); itr != m_pState->m_Entities.end(); ++itr )
+ {
+ LOG("%i %i %i Destroying on %s", m_PosX, m_PosY, m_PosZ, a_Client->GetUsername() );
+ cPacket_DestroyEntity DestroyEntity( *itr );
+ a_Client->Send( DestroyEntity );
+ }
+ UnlockEntities();
}
- UnlockEntities();
}
void cChunk::AddEntity( cEntity & a_Entity )
|