summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-06-10 18:25:53 +0200
committermadmaxoft <github@xoft.cz>2014-06-10 18:25:53 +0200
commit366ecf9dfd38d612c0685f3fbf8b3a95b9900697 (patch)
tree707394377759c40768cb2ac609c082d9d5cadce1 /src/ChunkMap.cpp
parentFixed gcc compilation. (diff)
downloadcuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar.gz
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar.bz2
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar.lz
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar.xz
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.tar.zst
cuberite-366ecf9dfd38d612c0685f3fbf8b3a95b9900697.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 0a8164b47..dba6f3f41 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1665,6 +1665,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);