Fixed a race condition between chunk loader and generator.
When using ChunkWorx to generate multiple chunks, the server would sometimes fail an assert because it would generate a chunk even when it was successfully loaded. This was caused by chunks queued in cWorld's m_SetChunkDataQueue and thus being marked as "InQueue" although they were already loaded. Solved by adding a new parameter to chunk coord callbacks specifying whether the operation succeeded or failed, and using that instead of the chunk presence flag to decide whether to generate or not.
This commit is contained in:
@@ -238,12 +238,12 @@ void cLightingThread::Execute(void)
|
||||
|
||||
void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
|
||||
{
|
||||
// If the chunk is already lit, skip it:
|
||||
// If the chunk is already lit, skip it (report as success):
|
||||
if (m_World->IsChunkLighted(a_Item.m_ChunkX, a_Item.m_ChunkZ))
|
||||
{
|
||||
if (a_Item.m_CallbackAfter != nullptr)
|
||||
{
|
||||
a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ);
|
||||
a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ void cLightingThread::LightChunk(cLightingChunkStay & a_Item)
|
||||
|
||||
if (a_Item.m_CallbackAfter != nullptr)
|
||||
{
|
||||
a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ);
|
||||
a_Item.m_CallbackAfter->Call(a_Item.m_ChunkX, a_Item.m_ChunkZ, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user