- // sync entities
- auto global_iter = server.GetWorld().Entities().begin();
- auto global_end = server.GetWorld().Entities().end();
- auto local_iter = spawns.begin();
- auto local_end = spawns.end();
-
- while (global_iter != global_end && local_iter != local_end) {
- if (global_iter->ID() == local_iter->entity->ID()) {
- // they're the same
- if (CanDespawn(*global_iter)) {
- SendDespawn(*local_iter);
- } else {
- // update
- QueueUpdate(*local_iter);
- }
- ++global_iter;
- ++local_iter;
- } else if (global_iter->ID() < local_iter->entity->ID()) {
- // global entity was inserted
- if (CanSpawn(*global_iter)) {
- auto spawned = spawns.emplace(local_iter, *global_iter);
- SendSpawn(*spawned);
- }
- ++global_iter;
- } else {
- // global entity was removed
+ CheckPlayerFix();
+ CheckChunkQueue();
+ CheckEntities();
+ SendUpdates();
+ }
+ if (conn.ShouldPing()) {
+ conn.SendPing(server.GetPacket(), server.GetSocket());
+ }
+}
+
+void ClientConnection::CheckEntities() {
+ auto global_iter = server.GetWorld().Entities().begin();
+ auto global_end = server.GetWorld().Entities().end();
+ auto local_iter = spawns.begin();
+ auto local_end = spawns.end();
+
+ while (global_iter != global_end && local_iter != local_end) {
+ if (global_iter->ID() == local_iter->entity->ID()) {
+ // they're the same
+ if (CanDespawn(*global_iter)) {