summaryrefslogtreecommitdiffstats
path: root/source/cChunkGenerator.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-16 18:45:26 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-16 18:45:26 +0100
commit2928cb6853f1e007e98f174c37d75c793a0c09cc (patch)
tree25865a247f5460f185f7f058e0db54637b487a5d /source/cChunkGenerator.cpp
parentGot rid of dangerous GetEntity(), not using DoWithEntity() (diff)
downloadcuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar.gz
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar.bz2
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar.lz
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar.xz
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.tar.zst
cuberite-2928cb6853f1e007e98f174c37d75c793a0c09cc.zip
Diffstat (limited to '')
-rw-r--r--source/cChunkGenerator.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp
index 8755ea325..4d9aef421 100644
--- a/source/cChunkGenerator.cpp
+++ b/source/cChunkGenerator.cpp
@@ -53,11 +53,11 @@ bool cChunkGenerator::Start(cWorld * a_World, const AString & a_WorldGeneratorNa
if (a_WorldGeneratorName.compare("Test") == 0 )
{
- m_pWorldGenerator = new cWorldGenerator_Test();
+ m_pWorldGenerator = new cWorldGenerator_Test(a_World);
}
else // Default
{
- m_pWorldGenerator = new cWorldGenerator();
+ m_pWorldGenerator = new cWorldGenerator(a_World);
}
return super::Start();
@@ -129,17 +129,22 @@ void cChunkGenerator::Execute(void)
bool SkipEnabled = (m_Queue.size() > QUEUE_SKIP_LIMIT);
Lock.Unlock(); // Unlock ASAP
- cChunkPtr Chunk = m_World->GetChunk(coords.m_ChunkX, 0, coords.m_ChunkZ);
- if ((Chunk != NULL) && (Chunk->IsValid() || (SkipEnabled && !Chunk->HasAnyClient())))
+ if (
+ m_World->IsChunkValid(coords.m_ChunkX, 0, coords.m_ChunkZ) ||
+ (SkipEnabled && m_World->HasChunkAnyClients(coords.m_ChunkX, 0, coords.m_ChunkZ))
+ )
{
// Already generated / overload-skip, ignore request
continue;
}
-
+
LOG("Generating chunk [%d, %d]", coords.m_ChunkX, coords.m_ChunkZ);
- m_pWorldGenerator->GenerateChunk(Chunk);
+ m_pWorldGenerator->GenerateChunk(coords.m_ChunkX, 0, coords.m_ChunkZ);
- Chunk->SetValid();
+ // Chunk->SetValid();
+
+ // Save the chunk right after generating, so that we don't have to generate it again on next run
+ m_World->GetStorage().QueueSaveChunk(coords.m_ChunkX, coords.m_ChunkZ);
} // while (!bStop)
}