| 602 | } |
| 603 | |
| 604 | void WorldServer::update(float dt) { |
| 605 | m_currentTime += dt; |
| 606 | ++m_currentStep; |
| 607 | for (auto const& pair : m_clientInfo) |
| 608 | pair.second->interpolationTracker.update(m_currentTime); |
| 609 | |
| 610 | List<WorldAction> triggeredActions; |
| 611 | eraseWhere(m_timers, [&triggeredActions, dt](pair<float, WorldAction>& timer) { |
| 612 | if ((timer.first -= dt) <= 0) { |
| 613 | triggeredActions.append(timer.second); |
| 614 | return true; |
| 615 | } |
| 616 | return false; |
| 617 | }); |
| 618 | for (auto const& action : triggeredActions) |
| 619 | action(this); |
| 620 | |
| 621 | m_spawner.update(dt); |
| 622 | |
| 623 | bool doBreakChecks = m_tileEntityBreakCheckTimer.wrapTick(m_currentTime) && m_needsGlobalBreakCheck; |
| 624 | if (doBreakChecks) |
| 625 | m_needsGlobalBreakCheck = false; |
| 626 | |
| 627 | List<EntityId> toRemove; |
| 628 | m_entityMap->updateAllEntities([&](EntityPtr const& entity) { |
| 629 | entity->update(dt, m_currentStep); |
| 630 | |
| 631 | if (auto tileEntity = as<TileEntity>(entity)) { |
| 632 | // Only do break checks on objects if all sectors the object touches |
| 633 | // *and surrounding sectors* are active. Objects that this object |
| 634 | // rests on can be up to an entire sector large in any direction. |
| 635 | if (doBreakChecks && regionActive(RectI::integral(tileEntity->metaBoundBox().translated(tileEntity->position())).padded(WorldSectorSize))) |
| 636 | tileEntity->checkBroken(); |
| 637 | updateTileEntityTiles(tileEntity); |
| 638 | } |
| 639 | |
| 640 | if (entity->shouldDestroy() && entity->entityMode() == EntityMode::Master) |
| 641 | toRemove.append(entity->entityId()); |
| 642 | }, [](EntityPtr const& a, EntityPtr const& b) { |
| 643 | return a->entityType() < b->entityType(); |
| 644 | }); |
| 645 | |
| 646 | for (auto& pair : m_scriptContexts) |
| 647 | pair.second->update(pair.second->updateDt(dt)); |
| 648 | |
| 649 | updateDamage(dt); |
| 650 | if (shouldRunThisStep("wiringUpdate")) |
| 651 | m_wireProcessor->process(); |
| 652 | |
| 653 | m_sky->update(dt); |
| 654 | |
| 655 | List<RectI> clientWindows; |
| 656 | List<RectI> clientMonitoringRegions; |
| 657 | for (auto const& pair : m_clientInfo) { |
| 658 | clientWindows.append(pair.second->clientState.window()); |
| 659 | for (auto const& region : pair.second->monitoringRegions(m_entityMap)) |
| 660 | clientMonitoringRegions.appendAll(m_geometry.splitRect(region)); |
| 661 | } |
no test coverage detected