From 7d847fcd6ad67f793726946631ad00a266bdda16 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 30 Jun 2023 06:35:46 +1000 Subject: [PATCH] Fix rare world lighting thread race --- source/game/StarWorldClient.cpp | 4 ++-- source/game/StarWorldClient.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index ed04d67..486105a 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -92,6 +92,7 @@ WorldClient::~WorldClient() { m_lightingCond.broadcast(); } + m_lightingThread.finish(); clearWorld(); } @@ -1446,11 +1447,10 @@ void WorldClient::lightingTileGather() { void WorldClient::lightingMain() { while (true) { + MutexLocker locker(m_lightingMutex); if (m_stopLightingThread) return; - MutexLocker locker(m_lightingMutex); - if (m_renderData) { int64_t start = Time::monotonicMilliseconds(); diff --git a/source/game/StarWorldClient.hpp b/source/game/StarWorldClient.hpp index 0686057..9c00130 100644 --- a/source/game/StarWorldClient.hpp +++ b/source/game/StarWorldClient.hpp @@ -252,7 +252,7 @@ private: mutable Mutex m_lightingMutex; mutable ConditionVariable m_lightingCond; mutable WorldRenderData* m_renderData; - bool m_stopLightingThread; + atomic m_stopLightingThread; SkyPtr m_sky;