| 180 | } |
| 181 | |
| 182 | bool CelestialMasterDatabase::coordinateValid(CelestialCoordinate const& coordinate) { |
| 183 | RecursiveMutexLocker locker(m_mutex); |
| 184 | |
| 185 | if (!coordinate) |
| 186 | return false; |
| 187 | |
| 188 | auto const& chunk = getChunk(chunkIndexFor(coordinate)); |
| 189 | |
| 190 | auto systemObjects = chunk.systemObjects.ptr(coordinate.location()); |
| 191 | if (!systemObjects) |
| 192 | return false; |
| 193 | |
| 194 | if (coordinate.isSystem()) |
| 195 | return true; |
| 196 | |
| 197 | auto planet = systemObjects->ptr(coordinate.planet().orbitNumber()); |
| 198 | if (!planet) |
| 199 | return false; |
| 200 | |
| 201 | if (coordinate.isPlanetaryBody()) |
| 202 | return true; |
| 203 | |
| 204 | return planet->satelliteParameters.contains(coordinate.orbitNumber()); |
| 205 | } |
| 206 | |
| 207 | Maybe<CelestialCoordinate> CelestialMasterDatabase::findRandomWorld(unsigned tries, unsigned trySpatialRange, |
| 208 | function<bool(CelestialCoordinate)> filter, Maybe<uint64_t> seed) { |
no test coverage detected