summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-26 17:15:09 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-26 17:15:09 +0100
commitb902546863c4b17c6d8ff3f198713aba7a8bbadd (patch)
tree35e67849dc70672b8ccfaf0aeb7e8d8293d639f4 /source/cChunkMap.cpp
parentAttempt at fixing crashes with disconnecting players (diff)
downloadcuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.gz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.bz2
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.lz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.xz
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.tar.zst
cuberite-b902546863c4b17c6d8ff3f198713aba7a8bbadd.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkMap.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index d9964c9d2..548040724 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -755,6 +755,21 @@ void cChunkMap::UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, c
+void cChunkMap::ChunkStay(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Stay)
+{
+ cCSLock Lock(m_CSLayers);
+ cChunkPtr Chunk = GetChunkNoGen(a_ChunkX, a_ChunkY, a_ChunkZ);
+ if (Chunk == NULL)
+ {
+ return;
+ }
+ Chunk->Stay(a_Stay);
+}
+
+
+
+
+
void cChunkMap::Tick( float a_Dt, MTRand & a_TickRandom )
{
cCSLock Lock(m_CSLayers);
@@ -939,3 +954,79 @@ void cChunkMap::ChunkValidated(void)
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cChunkStay:
+
+cChunkStay::cChunkStay(cWorld * a_World) :
+ m_World(a_World)
+{
+}
+
+
+
+
+
+cChunkStay::~cChunkStay()
+{
+ Clear();
+}
+
+
+
+
+
+void cChunkStay::Clear(void)
+{
+ cChunkCoordsList Chunks;
+ {
+ cCSLock Lock(m_CS);
+ std::swap(Chunks, m_Chunks);
+ }
+
+ // Un-"stay" all chunks:
+ for (cChunkCoordsList::const_iterator itr = Chunks.begin(); itr != Chunks.end(); ++itr)
+ {
+ m_World->ChunkStay(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ, false);
+ } // for itr - Chunks[]
+}
+
+
+
+
+
+void cChunkStay::Add(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ cCSLock Lock(m_CS);
+ for (cChunkCoordsList::const_iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr)
+ {
+ if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkY == a_ChunkY) && (itr->m_ChunkZ == a_ChunkZ))
+ {
+ // Already "stayed"
+ return;
+ }
+ } // for itr - Chunks[]
+ m_World->ChunkStay(a_ChunkX, a_ChunkY, a_ChunkZ);
+}
+
+
+
+
+
+void cChunkStay::Remove(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
+{
+ cCSLock Lock(m_CS);
+ for (cChunkCoordsList::const_iterator itr = m_Chunks.begin(); itr != m_Chunks.end(); ++itr)
+ {
+ if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkY == a_ChunkY) && (itr->m_ChunkZ == a_ChunkZ))
+ {
+ // Found, un-"stay"
+ m_World->ChunkStay(a_ChunkX, a_ChunkY, a_ChunkZ, false);
+ return;
+ }
+ } // for itr - Chunks[]
+}
+
+
+
+