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

Method readNetDelta

source/game/StarToolUser.cpp:689–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689void ToolUser::NetItem::readNetDelta(DataStream& ds, float interpolationTime, NetCompatibilityRules rules) {
690 if (!checkWithRules(rules)) return;
691 while (true) {
692 uint8_t code = ds.read<uint8_t>();
693 if (code == 0) {
694 break;
695 } else if (code == 1) {
696 m_itemDescriptor.readNetDelta(ds, 0.0f, rules);
697 if (!m_item || !m_item->matches(m_itemDescriptor.get(), true)) {
698 auto itemDatabase = Root::singleton().itemDatabase();
699 if (itemDatabase->loadItem(m_itemDescriptor.get(), m_item)) {
700 m_newItem = true;
701 if (auto netItem = as<NetElement>(m_item.get())) {
702 netItem->initNetVersion(m_netVersion);
703 if (m_netInterpolationEnabled)
704 netItem->enableNetInterpolation(m_netExtrapolationHint);
705 }
706 }
707 }
708 } else if (code == 2) {
709 if (auto netItem = as<NetElement>(m_item.get()))
710 netItem->netLoad(ds, rules);
711 else
712 throw IOException("Server/Client disagreement about whether an Item is a NetElement in NetItem::readNetDelta");
713 } else if (code == 3) {
714 if (auto netItem = as<NetElement>(m_item.get()))
715 netItem->readNetDelta(ds, interpolationTime, rules);
716 else
717 throw IOException("Server/Client disagreement about whether an Item is a NetElement in NetItem::readNetDelta");
718 } else {
719 throw IOException("Improper code received in NetItem::readDelta");
720 }
721 }
722}
723
724void ToolUser::NetItem::blankNetDelta(float interpolationTime) {
725 if (m_netInterpolationEnabled) {

Callers

nothing calls this directly

Calls 8

singletonClass · 0.85
itemDatabaseMethod · 0.80
loadItemMethod · 0.80
matchesMethod · 0.45
getMethod · 0.45
initNetVersionMethod · 0.45
netLoadMethod · 0.45

Tested by

no test coverage detected