diff options
-rwxr-xr-x | scripts/ci/linux/run-client.sh | 13 | ||||
-rw-r--r-- | source/core/StarNetElementGroup.cpp | 35 | ||||
-rw-r--r-- | source/core/StarNetElementGroup.hpp | 4 | ||||
-rw-r--r-- | source/game/StarUniverseClient.cpp | 10 | ||||
-rw-r--r-- | source/game/StarWorldClient.cpp | 2 |
5 files changed, 38 insertions, 26 deletions
diff --git a/scripts/ci/linux/run-client.sh b/scripts/ci/linux/run-client.sh index f6f72b5..570e619 100755 --- a/scripts/ci/linux/run-client.sh +++ b/scripts/ci/linux/run-client.sh @@ -1,18 +1,5 @@ #!/bin/sh -# Check if environment variables are already set -if [ -n "${__GLX_VENDOR_LIBRARY_NAME}" ] || [ -n "${MESA_LOADER_DRIVER_OVERRIDE}" ] || [ -n "${GALLIUM_DRIVER}" ]; then : -else - # Check for Vulkan support - if command -v vulkaninfo &> /dev/null; then - # Check for Zink support - if __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=1 glxinfo | grep -q 'renderer string: zink'; then - # Set environment variables for Zink - export __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=1 - fi - fi -fi - cd "`dirname \"$0\"`" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:./" ./starbound "$@" & exit diff --git a/source/core/StarNetElementGroup.cpp b/source/core/StarNetElementGroup.cpp index 6626e2b..901eeb1 100644 --- a/source/core/StarNetElementGroup.cpp +++ b/source/core/StarNetElementGroup.cpp @@ -13,6 +13,8 @@ void NetElementGroup::addNetElement(NetElement* element, bool propagateInterpola void NetElementGroup::clearNetElements() { m_elements.clear(); + m_filteredForRules.reset(); + m_filteredElementsCache.clear(); } void NetElementGroup::initNetVersion(NetElementVersion const* version) { @@ -89,26 +91,24 @@ bool NetElementGroup::writeNetDelta(DataStream& ds, uint64_t fromVersion, NetCom void NetElementGroup::readNetDelta(DataStream& ds, float interpolationTime, NetCompatibilityRules rules) { if (!checkWithRules(rules)) return; - if (m_elements.size() == 0) { - throw IOException("readNetDelta called on empty NetElementGroup"); - } else if (m_elements.size() == 1) { - m_elements[0].first->readNetDelta(ds, interpolationTime, rules); + auto& elements = filterElementsForRules(rules); + if (elements.size() == 0) { + if (m_elements.size() == 0) + throw IOException("readNetDelta called on empty NetElementGroup"); + } else if (elements.size() == 1) { + elements[0]->readNetDelta(ds, interpolationTime, rules); } else { uint64_t readIndex = ds.readVlqU(); - uint64_t i = 0; - for (auto& element : m_elements) { - if (!element.first->checkWithRules(rules)) - continue; + for (uint64_t i = 0; i != elements.size(); ++i) { if (readIndex == 0 || readIndex - 1 > i) { if (m_interpolationEnabled) - m_elements[i].first->blankNetDelta(interpolationTime); + elements[i]->blankNetDelta(interpolationTime); } else if (readIndex - 1 == i) { - m_elements[i].first->readNetDelta(ds, interpolationTime, rules); + elements[i]->readNetDelta(ds, interpolationTime); readIndex = ds.readVlqU(); } else { throw IOException("group indexes out of order in NetElementGroup::readNetDelta"); } - ++i; } } } @@ -120,4 +120,17 @@ void NetElementGroup::blankNetDelta(float interpolationTime) { } } +List<NetElement*>& NetElementGroup::filterElementsForRules(NetCompatibilityRules rules) { + if (!m_filteredForRules || m_filteredForRules != rules) { + m_filteredForRules = rules; + m_filteredElementsCache.clear(); + m_filteredElementsCache.reserve(m_elements.size()); + for (auto& element : m_elements) { + if (element.first->checkWithRules(rules)) + m_filteredElementsCache.push_back(element.first); + } + } + return m_filteredElementsCache; +} + } diff --git a/source/core/StarNetElementGroup.hpp b/source/core/StarNetElementGroup.hpp index 1904a33..6f009d8 100644 --- a/source/core/StarNetElementGroup.hpp +++ b/source/core/StarNetElementGroup.hpp @@ -40,7 +40,11 @@ public: float netExtrapolationHint() const; private: + List<NetElement*>& filterElementsForRules(NetCompatibilityRules rules); + List<pair<NetElement*, bool>> m_elements; + Maybe<NetCompatibilityRules> m_filteredForRules; + List<NetElement*> m_filteredElementsCache; NetElementVersion const* m_version = nullptr; bool m_interpolationEnabled = false; float m_extrapolationHint = 0.0f; diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp index 9a1f31b..394cacc 100644 --- a/source/game/StarUniverseClient.cpp +++ b/source/game/StarUniverseClient.cpp @@ -258,7 +258,15 @@ void UniverseClient::update(float dt) { } m_connection->receive(); - handlePackets(m_connection->pull()); + try { + handlePackets(m_connection->pull()); + } + catch (StarException const& e) { + Logger::error("Exception caught handling incoming server packets {}", outputException(e, true)); + reset(); + if (!m_disconnectReason) + m_disconnectReason = String("Exception caught handling incoming server packets, check log"); + } if (!isConnected()) return; diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 8db6a62..42b031a 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -1068,7 +1068,7 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) { } else if (auto entityInteract = as<EntityInteractPacket>(packet)) { auto interactResult = interact(entityInteract->interactRequest).result(); - m_outgoingPackets.append(make_shared<EntityInteractResultPacket>(interactResult.take(), entityInteract->requestId, entityInteract->interactRequest.sourceId)); + m_outgoingPackets.append(make_shared<EntityInteractResultPacket>(interactResult.value(), entityInteract->requestId, entityInteract->interactRequest.sourceId)); } else if (auto interactResult = as<EntityInteractResultPacket>(packet)) { if (auto response = m_entityInteractionResponses.maybeTake(interactResult->requestId)) { |