From b902546863c4b17c6d8ff3f198713aba7a8bbadd Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 26 Feb 2012 16:15:09 +0000 Subject: New cChunkStay class for temporarily keeping chunks loaded even when then have no clients. For now unused, will be used by generator and lighting in the future. git-svn-id: http://mc-server.googlecode.com/svn/trunk@330 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cChunk.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/cChunk.cpp') 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) -- cgit v1.2.3