diff options
author | Tycho <work.tycho+git@gmail.com> | 2014-06-14 18:19:28 +0200 |
---|---|---|
committer | Tycho <work.tycho+git@gmail.com> | 2014-06-14 18:19:28 +0200 |
commit | 039c1a75f391b078f2b27a388e73bb203afed58e (patch) | |
tree | f4f213b794eb0c3a2713358c3d5bdd3f0b931486 /src/ChunkMap.cpp | |
parent | Fixed bad merge (diff) | |
parent | Merge pull request #1093 from mc-server/BindingsFix (diff) | |
download | cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.gz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.bz2 cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.lz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.xz cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.zst cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.zip |
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r-- | src/ChunkMap.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index bf2b09342..586d7a65e 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -1253,7 +1253,7 @@ void cChunkMap::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYP -void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta) +void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients) { cChunkInterface ChunkInterface(this); if (a_BlockType == E_BLOCK_AIR) @@ -1268,7 +1268,7 @@ void cChunkMap::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a cChunkPtr Chunk = GetChunk( ChunkX, ZERO_CHUNK_Y, ChunkZ ); if ((Chunk != NULL) && Chunk->IsValid()) { - Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta ); + Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta, a_SendToClients); m_World->GetSimulatorManager()->WakeUp(a_BlockX, a_BlockY, a_BlockZ, Chunk); } BlockHandler(a_BlockType)->OnPlaced(ChunkInterface, a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); @@ -1666,6 +1666,30 @@ void cChunkMap::AddEntity(cEntity * a_Entity) +void cChunkMap::AddEntityIfNotPresent(cEntity * a_Entity) +{ + cCSLock Lock(m_CSLayers); + cChunkPtr Chunk = GetChunkNoGen(a_Entity->GetChunkX(), ZERO_CHUNK_Y, a_Entity->GetChunkZ()); + if ( + (Chunk == NULL) || // Chunk not present at all + (!Chunk->IsValid() && !a_Entity->IsPlayer()) // Chunk present, but no valid data; players need to spawn in such chunks (#953) + ) + { + LOGWARNING("Entity at %p (%s, ID %d) spawning in a non-existent chunk, the entity is lost.", + a_Entity, a_Entity->GetClass(), a_Entity->GetUniqueID() + ); + return; + } + if (!Chunk->HasEntity(a_Entity->GetUniqueID())) + { + Chunk->AddEntity(a_Entity); + } +} + + + + + bool cChunkMap::HasEntity(int a_UniqueID) { cCSLock Lock(m_CSLayers); |