diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-24 18:42:55 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-24 18:42:55 +1000 |
commit | af31bde03216ba337fb6b3b5ef306c4a0bb745b5 (patch) | |
tree | f001ad9f8e59c78a30ebb5e4011de5f2e026b02a /source/game/StarUniverseServer.cpp | |
parent | a2d901bd66178bbaacc2fec3acd07e7a27b9235f (diff) |
Handle world creation error when sending world messages, add active world callbacks
Diffstat (limited to 'source/game/StarUniverseServer.cpp')
-rw-r--r-- | source/game/StarUniverseServer.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/game/StarUniverseServer.cpp b/source/game/StarUniverseServer.cpp index 51f4cec..dd48085 100644 --- a/source/game/StarUniverseServer.cpp +++ b/source/game/StarUniverseServer.cpp @@ -151,6 +151,11 @@ List<WorldId> UniverseServer::activeWorlds() const { return m_worlds.keys(); } +bool UniverseServer::isWorldActive(WorldId const& worldId) const { + RecursiveMutexLocker locker(m_mainLock); + return m_worlds.contains(worldId); +} + List<ConnectionId> UniverseServer::clientIds() const { ReadLocker clientsLocker(m_clientsLock); return m_clients.keys(); @@ -1045,8 +1050,14 @@ void UniverseServer::handleWorldMessages() { auto it = m_pendingWorldMessages.begin(); while (it != m_pendingWorldMessages.end()) { auto& worldId = it->first; - if (auto worldPtr = triggerWorldCreation(worldId).value()) { - worldPtr->passMessages(move(it->second)); + if (auto worldResult = triggerWorldCreation(worldId)) { + auto& world = *worldResult; + + if (world) + world->passMessages(move(it->second)); + else for (auto& message : it->second) + message.promise.fail("Error creating world"); + it = m_pendingWorldMessages.erase(it); } else |