| 147 | } |
| 148 | |
| 149 | void SystemWorldServer::removeObject(Uuid objectUuid) { |
| 150 | if (!m_objects.contains(objectUuid)) |
| 151 | throw StarException(strf("Cannot remove object with uuid '{}', object doesn't exist.", objectUuid.hex())); |
| 152 | |
| 153 | if (m_objects[objectUuid]->permanent()) |
| 154 | throw StarException(strf("Cannot remove object with uuid '{}', object is marked permanent", objectUuid.hex())); |
| 155 | |
| 156 | // already removing it |
| 157 | if (m_objectDestroyQueue.contains(objectUuid)) |
| 158 | return; |
| 159 | |
| 160 | // fly away any active ships that are located at the object |
| 161 | for (auto p : m_clientShips) { |
| 162 | auto ship = m_ships.get(p.second); |
| 163 | auto location = ship->systemLocation(); |
| 164 | if (location == objectUuid || ship->destination() == objectUuid) { |
| 165 | ship->setDestination(*systemLocationPosition(objectUuid)); |
| 166 | if (!ship->flying()) |
| 167 | m_shipFlights.append(p.first); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | m_objectDestroyQueue.append(objectUuid); |
| 172 | } |
| 173 | |
| 174 | bool SystemWorldServer::addObject(SystemObjectPtr object, bool doRangeCheck) { |
| 175 | if (doRangeCheck) { |
nothing calls this directly
no test coverage detected