| 458 | } |
| 459 | |
| 460 | bool UniverseServer::updatePlanetType(CelestialCoordinate const& coordinate, String const& newType, String const& weatherBiome) { |
| 461 | RecursiveMutexLocker locker(m_mainLock); |
| 462 | |
| 463 | if (!coordinate.isNull() && m_celestialDatabase->coordinateValid(coordinate)) { |
| 464 | if (auto celestialParameters = m_celestialDatabase->parameters(coordinate)) { |
| 465 | if (auto terrestrialParameters = as<TerrestrialWorldParameters>(celestialParameters->visitableParameters())) { |
| 466 | auto newTerrestrialParameters = make_shared<TerrestrialWorldParameters>(*terrestrialParameters); |
| 467 | newTerrestrialParameters->typeName = newType; |
| 468 | |
| 469 | auto biomeDatabase = Root::singleton().biomeDatabase(); |
| 470 | auto newWeatherPool = biomeDatabase->biomeWeathers(weatherBiome, celestialParameters->seed(), terrestrialParameters->threatLevel); |
| 471 | newTerrestrialParameters->weatherPool = newWeatherPool; |
| 472 | |
| 473 | newTerrestrialParameters->terraformed = true; |
| 474 | |
| 475 | celestialParameters->setVisitableParameters(newTerrestrialParameters); |
| 476 | |
| 477 | m_celestialDatabase->updateParameters(coordinate, *celestialParameters); |
| 478 | |
| 479 | ReadLocker clientsLocker(m_clientsLock); |
| 480 | |
| 481 | for (auto clientId : m_clients.keys()) |
| 482 | m_connectionServer->sendPackets(clientId, {make_shared<PlanetTypeUpdatePacket>(coordinate)}); |
| 483 | |
| 484 | return true; |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | bool UniverseServer::sendPacket(ConnectionId clientId, PacketPtr packet) { |
| 493 | RecursiveMutexLocker locker(m_mainLock); |
nothing calls this directly
no test coverage detected