cWorldGenerator speedup - doesn't call GetChunk() anymore, not queueing the chunk it's generating to be loaded recursively.
cChunk fix - setting a block to the same value doesn't mark chunk dirty (resulted in un-unloadable chunks) git-svn-id: http://mc-server.googlecode.com/svn/trunk@279 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -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);
|
||||
|
||||
Chunk->SetValid();
|
||||
LOG("Generating chunk [%d, %d]", coords.m_ChunkX, coords.m_ChunkZ);
|
||||
m_pWorldGenerator->GenerateChunk(coords.m_ChunkX, 0, coords.m_ChunkZ);
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user