| 303 | } |
| 304 | |
| 305 | void UniverseServer::clientFlyShip(ConnectionId clientId, Vec3I const& system, SystemLocation const& location, Json const& settings) { |
| 306 | RecursiveMutexLocker locker(m_mainLock); |
| 307 | ReadLocker clientsLocker(m_clientsLock); |
| 308 | |
| 309 | if (m_pendingFlights.contains(clientId) || m_queuedFlights.contains(clientId)) |
| 310 | return; |
| 311 | |
| 312 | auto clientContext = m_clients.get(clientId); |
| 313 | if (!clientContext) |
| 314 | return; |
| 315 | |
| 316 | if (system == Vec3I()) { |
| 317 | m_pendingFlights.set(clientId, make_tuple(Vec3I(), SystemLocation(), settings)); // find starter world |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | auto clientSystem = clientContext->systemWorld(); |
| 322 | bool sameSystem = clientSystem && clientSystem->location() == system; |
| 323 | bool sameLocation = clientSystem && clientSystem->clientShipLocation(clientId) == location; |
| 324 | if (m_pendingArrivals.contains(clientId) && sameSystem && location && !sameLocation) { |
| 325 | // for continuing flight within a system, set the new destination immediately |
| 326 | clientSystem->setClientDestination(clientId, location); |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | // don't switch systems while already flying |
| 331 | if (!m_pendingArrivals.contains(clientId) || sameSystem) |
| 332 | m_pendingFlights.set(clientId, make_tuple(system, location, settings)); |
| 333 | } |
| 334 | |
| 335 | WorldId UniverseServer::clientWorld(ConnectionId clientId) const { |
| 336 | RecursiveMutexLocker locker(m_mainLock); |
nothing calls this directly
no test coverage detected