| 172 | } |
| 173 | |
| 174 | bool SystemWorldServer::addObject(SystemObjectPtr object, bool doRangeCheck) { |
| 175 | if (doRangeCheck) { |
| 176 | CelestialCoordinate system = CelestialCoordinate(m_location); |
| 177 | CelestialCoordinate outer = system.child(m_celestialDatabase->childOrbits(system).sorted().last()); |
| 178 | List<pair<float, float>> orbitDistances; |
| 179 | for (auto planet : planets()) { |
| 180 | orbitDistances.append({planetOrbitDistance(planet), clusterSize(planet) / 2.0}); |
| 181 | } |
| 182 | for (auto o : m_objects.values()) { |
| 183 | if (o->permanent()) |
| 184 | orbitDistances.append({o->position().magnitude(), 0.0}); |
| 185 | } |
| 186 | |
| 187 | float maxRange = planetOrbitDistance(outer) + (clusterSize(outer) / 2.0) + systemConfig().clientObjectSpawnPadding; |
| 188 | // Allow objectSpawnPadding of room outside the farthest orbit to have an object placed in it |
| 189 | maxRange += systemConfig().clientObjectSpawnPadding; |
| 190 | float minRange = (planetSize(system) / 2.0) + systemConfig().clientObjectSpawnPadding; |
| 191 | float radius = object->position().magnitude(); |
| 192 | if (radius > maxRange || radius < minRange) |
| 193 | return false; |
| 194 | for (pair<float, float> p : orbitDistances) { |
| 195 | if (abs(radius - p.first) < p.second + systemConfig().clientObjectSpawnPadding) |
| 196 | return false; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | m_objects.set(object->uuid(), object); |
| 201 | |
| 202 | auto objectStore = object->netStore(); |
| 203 | for (auto clientId : m_clientShips.keys()) { |
| 204 | m_outgoingPackets[clientId].append(make_shared<SystemObjectCreatePacket>(objectStore)); |
| 205 | } |
| 206 | |
| 207 | m_triggerStorage = true; |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | void SystemWorldServer::update(float dt) { |
| 212 | for (auto p : m_ships) |
nothing calls this directly
no test coverage detected