summaryrefslogtreecommitdiffstats
path: root/source/cChunk.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-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)