summaryrefslogtreecommitdiffstats
path: root/source/cChunkMap.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-17 18:56:25 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-17 18:56:25 +0100
commit510133bd35cad951a02f7d102f27badded7683a4 (patch)
tree3c995df9f2fd07806f053f6b57bd67686661a84c /source/cChunkMap.cpp
parentRemoved useless log messages (diff)
downloadcuberite-510133bd35cad951a02f7d102f27badded7683a4.tar
cuberite-510133bd35cad951a02f7d102f27badded7683a4.tar.gz
cuberite-510133bd35cad951a02f7d102f27badded7683a4.tar.bz2
cuberite-510133bd35cad951a02f7d102f27badded7683a4.tar.lz
cuberite-510133bd35cad951a02f7d102f27badded7683a4.tar.xz
cuberite-510133bd35cad951a02f7d102f27badded7683a4.tar.zst
cuberite-510133bd35cad951a02f7d102f27badded7683a4.zip
Diffstat (limited to 'source/cChunkMap.cpp')
-rw-r--r--source/cChunkMap.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp
index dbe6607fc..7adaebf90 100644
--- a/source/cChunkMap.cpp
+++ b/source/cChunkMap.cpp
@@ -103,10 +103,10 @@ cChunkPtr cChunkMap::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
return cChunkPtr();
}
- cChunkPtr Chunk = Layer->GetChunk(a_ChunkX, a_ChunkZ);
+ cChunkPtr Chunk = Layer->GetChunk(a_ChunkX, a_ChunkY, a_ChunkZ);
if (!(Chunk->IsValid()))
{
- m_World->GetStorage().QueueLoadChunk(a_ChunkX, a_ChunkZ);
+ m_World->GetStorage().QueueLoadChunk(a_ChunkX, a_ChunkY, a_ChunkZ);
}
return Chunk;
}
@@ -125,7 +125,7 @@ cChunkPtr cChunkMap::GetChunkNoGen( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
return cChunkPtr();
}
- cChunkPtr Chunk = Layer->GetChunk(a_ChunkX, a_ChunkZ);
+ cChunkPtr Chunk = Layer->GetChunk(a_ChunkX, a_ChunkY, a_ChunkZ);
// TODO: Load, but do not generate, if not valid
@@ -341,7 +341,7 @@ cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Pa
-cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkZ )
+cChunkPtr cChunkMap::cChunkLayer::GetChunk( int a_ChunkX, int a_ChunkY, int a_ChunkZ )
{
// Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check
@@ -371,7 +371,8 @@ void cChunkMap::cChunkLayer::Tick(float a_Dt, MTRand & a_TickRand)
{
for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++)
{
- if ((m_Chunks[i] != NULL) && (m_Chunks[i]->IsValid()))
+ // Only tick chunks that are valid and have clients:
+ if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->HasAnyClients())
{
m_Chunks[i]->Tick(a_Dt, a_TickRand);
}
@@ -382,6 +383,23 @@ void cChunkMap::cChunkLayer::Tick(float a_Dt, MTRand & a_TickRand)
+int cChunkMap::cChunkLayer::GetNumChunksLoaded(void) const
+{
+ int NumChunks = 0;
+ for ( int i = 0; i < ARRAYCOUNT(m_Chunks); ++i )
+ {
+ if (m_Chunks[i] != NULL)
+ {
+ NumChunks++;
+ }
+ } // for i - m_Chunks[]
+ return NumChunks;
+}
+
+
+
+
+
void cChunkMap::cChunkLayer::Save(void)
{
cWorld * World = m_Parent->GetWorld();
@@ -389,7 +407,7 @@ void cChunkMap::cChunkLayer::Save(void)
{
if ((m_Chunks[i] != NULL) && m_Chunks[i]->IsValid() && m_Chunks[i]->IsDirty())
{
- World->GetStorage().QueueSaveChunk(m_Chunks[i]->GetPosX(), m_Chunks[i]->GetPosZ());
+ World->GetStorage().QueueSaveChunk(m_Chunks[i]->GetPosX(), m_Chunks[i]->GetPosY(), m_Chunks[i]->GetPosZ());
}
} // for i - m_Chunks[]
}