1
0

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
This commit is contained in:
madmaxoft@gmail.com
2012-02-26 16:15:09 +00:00
parent 7268a70902
commit b902546863
6 changed files with 152 additions and 1 deletions

View File

@@ -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)