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

Method queueUpdatePackets

source/game/StarWorldClient.cpp:1493–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1491}
1492
1493void WorldClient::queueUpdatePackets(bool sendEntityUpdates) {
1494 auto& root = Root::singleton();
1495 auto assets = root.assets();
1496 auto entityFactory = root.entityFactory();
1497
1498 m_outgoingPackets.append(make_shared<StepUpdatePacket>(m_currentTime));
1499
1500 if (m_currentStep % m_clientConfig.getInt("worldClientStateUpdateDelta") == 0)
1501 m_outgoingPackets.append(make_shared<WorldClientStateUpdatePacket>(m_clientState.writeDelta()));
1502
1503 m_entityMap->forAllEntities([&](EntityPtr const& entity) { notifyEntityCreate(entity); });
1504
1505 if (sendEntityUpdates) {
1506 auto entityUpdateSet = make_shared<EntityUpdateSetPacket>();
1507 entityUpdateSet->forConnection = *m_clientId;
1508 auto netRules = m_clientState.netCompatibilityRules();
1509 m_entityMap->forAllEntities([&](EntityPtr const& entity) {
1510 if (auto version = m_masterEntitiesNetVersion.ptr(entity->entityId())) {
1511 auto updateAndVersion = entity->writeNetState(*version, netRules);
1512 if (!updateAndVersion.first.empty())
1513 entityUpdateSet->deltas[entity->entityId()] = std::move(updateAndVersion.first);
1514 *version = updateAndVersion.second;
1515 }
1516 });
1517 m_outgoingPackets.append(std::move(entityUpdateSet));
1518 }
1519
1520 for (auto& remoteHitRequest : m_damageManager->pullRemoteHitRequests())
1521 m_outgoingPackets.append(make_shared<HitRequestPacket>(std::move(remoteHitRequest)));
1522 for (auto& remoteDamageRequest : m_damageManager->pullRemoteDamageRequests())
1523 m_outgoingPackets.append(make_shared<DamageRequestPacket>(std::move(remoteDamageRequest)));
1524 for (auto& remoteDamageNotification : m_damageManager->pullRemoteDamageNotifications())
1525 m_outgoingPackets.append(make_shared<DamageNotificationPacket>(std::move(remoteDamageNotification)));
1526}
1527
1528void WorldClient::handleDamageNotifications() {
1529 if (!inWorld())

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
assetsMethod · 0.80
entityFactoryMethod · 0.80
getIntMethod · 0.80
writeDeltaMethod · 0.80
entityIdMethod · 0.80
pullRemoteHitRequestsMethod · 0.80
appendMethod · 0.45
forAllEntitiesMethod · 0.45
netCompatibilityRulesMethod · 0.45

Tested by

no test coverage detected