diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-16 10:35:07 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-06-16 10:35:07 +0200 |
commit | ada984facf47465b7a081eaf75d5541110c12f60 (patch) | |
tree | ebf09e32018e76a20df35e49965e15f8235cd6e2 /source/cWorld.cpp | |
parent | Lua binding for cVine fixed (diff) | |
download | cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar.gz cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar.bz2 cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar.lz cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar.xz cuberite-ada984facf47465b7a081eaf75d5541110c12f60.tar.zst cuberite-ada984facf47465b7a081eaf75d5541110c12f60.zip |
Diffstat (limited to 'source/cWorld.cpp')
-rw-r--r-- | source/cWorld.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp index 82243a8a9..0616fcf44 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -1602,14 +1602,32 @@ void cWorld::SendPlayerList(cPlayer * a_DestPlayer) -bool cWorld::DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback ) +void cWorld::RemoveEntityFromChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkY, int a_ChunkZ) +{ + m_ChunkMap->RemoveEntityFromChunk(a_Entity, a_ChunkX, a_ChunkY, a_ChunkZ); +} + + + + + +void cWorld::MoveEntityToChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkY, int a_ChunkZ) +{ + m_ChunkMap->MoveEntityToChunk(a_Entity, a_ChunkX, a_ChunkY, a_ChunkZ); +} + + + + + +bool cWorld::ForEachEntity(cEntityCallback & a_Callback) { cCSLock Lock(m_CSEntities); for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end(); ++itr ) { - if( (*itr)->GetUniqueID() == a_UniqueID ) + if (a_Callback.Item(*itr)) { - return a_Callback.Item(*itr); + return false; } } // for itr - m_AllEntities[] return false; @@ -1619,18 +1637,26 @@ bool cWorld::DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback ) -void cWorld::RemoveEntityFromChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkY, int a_ChunkZ) +bool cWorld::ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback) { - m_ChunkMap->RemoveEntityFromChunk(a_Entity, a_ChunkX, a_ChunkY, a_ChunkZ); + return m_ChunkMap->ForEachEntityInChunk(a_ChunkX, a_ChunkZ, a_Callback); } -void cWorld::MoveEntityToChunk(cEntity * a_Entity, int a_ChunkX, int a_ChunkY, int a_ChunkZ) +bool cWorld::DoWithEntityByID( int a_UniqueID, cEntityCallback & a_Callback ) { - m_ChunkMap->MoveEntityToChunk(a_Entity, a_ChunkX, a_ChunkY, a_ChunkZ); + cCSLock Lock(m_CSEntities); + for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end(); ++itr ) + { + if( (*itr)->GetUniqueID() == a_UniqueID ) + { + return a_Callback.Item(*itr); + } + } // for itr - m_AllEntities[] + return false; } |