MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / update

Method update

source/game/StarWorldServer.cpp:604–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604void 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 }

Callers 3

addClientMethod · 0.45
setLiquidMethod · 0.45
updateDamageMethod · 0.45

Calls 15

eraseWhereFunction · 0.85
vmagFunction · 0.85
jsonToVec2IFunction · 0.85
strfFunction · 0.85
wrapTickMethod · 0.80
updateAllEntitiesMethod · 0.80
paddedMethod · 0.80
entityIdMethod · 0.80
updateDtMethod · 0.80
processMethod · 0.80
appendAllMethod · 0.80

Tested by

no test coverage detected