MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / processUniverseFlags

Method processUniverseFlags

source/game/StarUniverseServer.cpp:601–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599}
600
601void UniverseServer::processUniverseFlags() {
602 RecursiveMutexLocker locker(m_mainLock);
603 ReadLocker clientsLocker(m_clientsLock);
604
605 if (auto actions = m_universeSettings->pullPendingFlagActions()) {
606 for (auto action : *actions) {
607 if (action.is<PlaceDungeonFlagAction>()) {
608 auto placeDungeonAction = action.get<PlaceDungeonFlagAction>();
609 if (instanceWorldStoredOrActive(placeDungeonAction.targetInstance)) {
610 auto worldId = InstanceWorldId(placeDungeonAction.targetInstance);
611 m_pendingFlagActions.append(pair<WorldId, UniverseFlagAction>{worldId, placeDungeonAction});
612 }
613 }
614 }
615 }
616
617 eraseWhere(m_pendingFlagActions, [&](pair<WorldId, UniverseFlagAction> const& p) {
618 if (p.first.is<InstanceWorldId>() && instanceWorldStoredOrActive(p.first.get<InstanceWorldId>())) {
619 // world is stored or active; perform flag actions once it loads
620 if (auto maybeTargetWorld = triggerWorldCreation(p.first)) {
621 if (auto targetWorld = maybeTargetWorld.value()) {
622 if (p.second.is<PlaceDungeonFlagAction>()) {
623 auto placeDungeonAction = p.second.get<PlaceDungeonFlagAction>();
624 locker.unlock();
625 targetWorld->executeAction([&](WorldServerThread*, WorldServer* worldServer) {
626 worldServer->placeDungeon(placeDungeonAction.dungeonId, placeDungeonAction.targetPosition, 0);
627 });
628 locker.lock();
629 }
630 return true;
631 }
632 }
633 return false;
634 } else {
635 // world hasn't yet been created; flag actions will be handled by normal creation
636 return true;
637 }
638 });
639}
640
641void UniverseServer::sendPendingChat() {
642 RecursiveMutexLocker locker(m_mainLock);

Callers

nothing calls this directly

Calls 9

InstanceWorldIdClass · 0.85
eraseWhereFunction · 0.85
executeActionMethod · 0.80
appendMethod · 0.45
valueMethod · 0.45
unlockMethod · 0.45
placeDungeonMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected