| 260 | } |
| 261 | |
| 262 | void SystemWorldServer::queueUpdatePackets() { |
| 263 | for (auto clientId : m_clientNetVersions.keys()) { |
| 264 | auto versions = m_clientNetVersions.ptr(clientId); |
| 265 | |
| 266 | HashMap<Uuid, ByteArray> shipUpdates; |
| 267 | for (auto ship : m_ships.values()) { |
| 268 | uint64_t version = versions->ships.maybe(ship->uuid()).value(0); |
| 269 | auto shipUpdate = ship->writeNetState(version, {}); |
| 270 | versions->ships.set(ship->uuid(), shipUpdate.second); |
| 271 | if (!shipUpdate.first.empty()) |
| 272 | shipUpdates.set(ship->uuid(), shipUpdate.first); |
| 273 | } |
| 274 | |
| 275 | HashMap<Uuid, ByteArray> objectUpdates; |
| 276 | for (auto object : m_objects.values()) { |
| 277 | uint64_t version = versions->objects.maybe(object->uuid()).value(0); |
| 278 | auto objectUpdate = object->writeNetState(version, {}); |
| 279 | versions->objects.set(object->uuid(), objectUpdate.second); |
| 280 | if (!objectUpdate.first.empty()) |
| 281 | objectUpdates.set(object->uuid(), objectUpdate.first); |
| 282 | } |
| 283 | m_outgoingPackets[clientId].append(make_shared<SystemWorldUpdatePacket>(objectUpdates, shipUpdates)); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | void SystemWorldServer::handleIncomingPacket(ConnectionId, PacketPtr packet) { |
| 288 | if (auto objectSpawn = as<SystemObjectSpawnPacket>(packet)) { |