| 209 | } |
| 210 | |
| 211 | void SystemWorldServer::update(float dt) { |
| 212 | for (auto p : m_ships) |
| 213 | p.second->serverUpdate(this, dt); |
| 214 | |
| 215 | for (auto p : m_objects) { |
| 216 | p.second->serverUpdate(this, dt); |
| 217 | |
| 218 | // don't destroy objects that still have players at them |
| 219 | if (p.second->shouldDestroy() && shipsAtLocation(p.first).size() == 0) |
| 220 | removeObject(p.first); |
| 221 | } |
| 222 | |
| 223 | spawnObjects(); |
| 224 | |
| 225 | queueUpdatePackets(); |
| 226 | |
| 227 | // remove objects and ships after queueing update packets to ensure they're not updated after being removed |
| 228 | for (auto objectUuid : take(m_objectDestroyQueue)) { |
| 229 | for (auto p : m_clientNetVersions) { |
| 230 | p.second.objects.remove(objectUuid); |
| 231 | m_outgoingPackets[p.first].append(make_shared<SystemObjectDestroyPacket>(objectUuid)); |
| 232 | } |
| 233 | m_objects.remove(objectUuid); |
| 234 | m_triggerStorage = true; |
| 235 | } |
| 236 | for (auto shipUuid : take(m_shipDestroyQueue)) { |
| 237 | for (auto p : m_clientNetVersions) { |
| 238 | p.second.ships.remove(shipUuid); |
| 239 | m_outgoingPackets[p.first].append(make_shared<SystemShipDestroyPacket>(shipUuid)); |
| 240 | } |
| 241 | m_ships.remove(shipUuid); |
| 242 | m_triggerStorage = true; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | List<SystemObjectPtr> SystemWorldServer::objects() const { |
| 247 | return m_objects.values(); |
nothing calls this directly
no test coverage detected