summaryrefslogtreecommitdiffstats
path: root/source/cChunk.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/cChunk.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 'source/cChunk.cpp')
-rw-r--r--source/cChunk.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 058e04b99..14f99c1d9 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -85,6 +85,7 @@ cChunk::cChunk(int a_X, int a_Y, int a_Z, cChunkMap * a_ChunkMap, cWorld * a_Wor
, m_IsValid(false)
, m_IsDirty(false)
, m_IsSaving(false)
+ , m_StayCount(0)
{
// LOGINFO("### new cChunk (%i, %i) at %p, thread 0x%x ###", a_X, a_Z, this, GetCurrentThreadId());
}
@@ -164,7 +165,7 @@ void cChunk::SetValid(bool a_SendToClients)
bool cChunk::CanUnload(void)
{
- return m_LoadedByClient.empty() && !m_IsDirty;
+ return m_LoadedByClient.empty() && !m_IsDirty && (m_StayCount == 0);
}
@@ -298,6 +299,17 @@ bool cChunk::HasBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ)
+/// Sets or resets the internal flag that prevents chunk from being unloaded
+void cChunk::Stay(bool a_Stay)
+{
+ m_StayCount += (a_Stay ? 1 : -1);
+ ASSERT(m_StayCount >= 0);
+}
+
+
+
+
+
void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
{
if (m_bCalculateLighting)