Fix asynchronous lighting crash
This somehow only occurred on Linux
This commit is contained in:
parent
fe99ec6966
commit
87f0e49341
@ -1455,20 +1455,21 @@ void WorldClient::lightingTileGather() {
|
||||
void WorldClient::lightingMain() {
|
||||
while (true) {
|
||||
MutexLocker locker(m_lightingMutex);
|
||||
|
||||
m_lightingCond.wait(m_lightingMutex);
|
||||
if (m_stopLightingThread)
|
||||
return;
|
||||
|
||||
if (m_renderData) {
|
||||
if (WorldRenderData* renderData = m_renderData) {
|
||||
int64_t start = Time::monotonicMicroseconds();
|
||||
|
||||
lightingTileGather();
|
||||
|
||||
m_lightingCalculator.calculate(m_renderData->lightMap);
|
||||
m_lightingCalculator.calculate(renderData->lightMap);
|
||||
m_renderData = nullptr;
|
||||
LogMap::set("client_render_world_async_light_calc", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
|
||||
}
|
||||
|
||||
m_lightingCond.wait(m_lightingMutex);
|
||||
continue;
|
||||
|
||||
locker.unlock();
|
||||
@ -1546,6 +1547,8 @@ void WorldClient::clearWorld() {
|
||||
}
|
||||
}
|
||||
|
||||
waitForLighting();
|
||||
|
||||
m_currentStep = 0;
|
||||
m_currentServerStep = 0.0;
|
||||
m_inWorld = false;
|
||||
|
@ -252,9 +252,9 @@ private:
|
||||
mutable CellularLightIntensityCalculator m_lightIntensityCalculator;
|
||||
ThreadFunction<void> m_lightingThread;
|
||||
|
||||
mutable Mutex m_lightingMutex;
|
||||
mutable ConditionVariable m_lightingCond;
|
||||
mutable WorldRenderData* m_renderData;
|
||||
Mutex m_lightingMutex;
|
||||
ConditionVariable m_lightingCond;
|
||||
atomic<WorldRenderData*> m_renderData;
|
||||
atomic<bool> m_stopLightingThread;
|
||||
|
||||
SkyPtr m_sky;
|
||||
|
Loading…
Reference in New Issue
Block a user