From 5f86e0f027fe55004f835774db6b1d9b8d91ddd1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 20 Jul 2023 17:53:17 +1000 Subject: [PATCH] Hopefully fix server hang while finding a random starter world --- source/game/StarCelestialDatabase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/game/StarCelestialDatabase.cpp b/source/game/StarCelestialDatabase.cpp index f2a70d0..ac9f14f 100644 --- a/source/game/StarCelestialDatabase.cpp +++ b/source/game/StarCelestialDatabase.cpp @@ -206,14 +206,16 @@ bool CelestialMasterDatabase::coordinateValid(CelestialCoordinate const& coordin Maybe CelestialMasterDatabase::findRandomWorld(unsigned tries, unsigned trySpatialRange, function filter, Maybe seed) { - RecursiveMutexLocker locker(m_mutex); + //RecursiveMutexLocker locker(m_mutex); + // We don't need this mutex, the other calls are locking anyway. + // Having this here is just stopping other threads from having a go in here until we've found a world. RandomSource randSource; if (seed) randSource.init(*seed); for (unsigned i = 0; i < tries; ++i) { RectI range = xyRange(); Vec2I randomLocation = Vec2I(randSource.randInt(range.xMin(), range.xMax()), randSource.randInt(range.yMin(), range.yMax())); - for (auto system : scanSystems(RectI::withCenter(randomLocation, Vec2I::filled(trySpatialRange)))) { + for (auto& system : scanSystems(RectI::withCenter(randomLocation, Vec2I::filled(trySpatialRange)))) { if (!hasChildren(system).value(false)) continue;