Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/game/StarWorldClient.cpp9
-rw-r--r--source/game/StarWorldClient.hpp6
2 files changed, 9 insertions, 6 deletions
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index d684c16..25b676c 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -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;
diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp
index b8e9504..85be6d9 100644
--- a/source/game/StarWorldClient.hpp
+++ b/source/game/StarWorldClient.hpp
@@ -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;