| 81 | } |
| 82 | |
| 83 | void SystemWorldServerThread::update() { |
| 84 | WriteLocker queueLocker(m_queueMutex); |
| 85 | WriteLocker locker(m_mutex); |
| 86 | |
| 87 | for (auto p : take(m_incomingPacketQueue)) |
| 88 | m_systemWorld->handleIncomingPacket(p.first, p.second); |
| 89 | |
| 90 | for (auto p : take(m_clientShipActions)) |
| 91 | p.second(m_systemWorld->clientShip(p.first).get()); |
| 92 | |
| 93 | if (!m_pause || *m_pause == false) |
| 94 | m_systemWorld->update(SystemWorldTimestep * GlobalTimescale); |
| 95 | m_triggerStorage = m_systemWorld->triggeredStorage(); |
| 96 | |
| 97 | // important to set destinations before getting locations |
| 98 | // setting a destination nullifies the current location |
| 99 | for (auto p : take(m_clientShipDestinations)) |
| 100 | m_systemWorld->setClientDestination(p.first, p.second); |
| 101 | |
| 102 | m_activeInstanceWorlds = m_systemWorld->activeInstanceWorlds(); |
| 103 | |
| 104 | for (auto clientId : m_clients) { |
| 105 | m_outgoingPacketQueue[clientId].appendAll(m_systemWorld->pullOutgoingPackets(clientId)); |
| 106 | auto shipSystemLocation = m_systemWorld->clientShipLocation(clientId); |
| 107 | auto& shipLocation = m_clientShipLocations[clientId]; |
| 108 | if (shipLocation.first != shipSystemLocation) { |
| 109 | shipLocation.first = shipSystemLocation; |
| 110 | shipLocation.second = m_systemWorld->clientSkyParameters(clientId); |
| 111 | } |
| 112 | if (auto warpAction = m_systemWorld->clientWarpAction(clientId)) |
| 113 | m_clientWarpActions.set(clientId, *warpAction); |
| 114 | else if (m_clientWarpActions.contains(clientId)) |
| 115 | m_clientWarpActions.remove(clientId); |
| 116 | } |
| 117 | queueLocker.unlock(); |
| 118 | |
| 119 | if (m_updateAction) |
| 120 | m_updateAction(this); |
| 121 | } |
| 122 | |
| 123 | void SystemWorldServerThread::setClientDestination(ConnectionId clientId, SystemLocation const& destination) { |
| 124 | WriteLocker locker(m_queueMutex); |
nothing calls this directly
no test coverage detected