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

Method updatePlanetType

source/game/StarUniverseServer.cpp:460–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460bool 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
492bool UniverseServer::sendPacket(ConnectionId clientId, PacketPtr packet) {
493 RecursiveMutexLocker locker(m_mainLock);

Callers

nothing calls this directly

Calls 12

singletonClass · 0.85
coordinateValidMethod · 0.80
visitableParametersMethod · 0.80
biomeDatabaseMethod · 0.80
biomeWeathersMethod · 0.80
isNullMethod · 0.45
parametersMethod · 0.45
seedMethod · 0.45
updateParametersMethod · 0.45
keysMethod · 0.45
sendPacketsMethod · 0.45

Tested by

no test coverage detected