From c8d8b7ed61e892a30eb4886686fa7613e56da81b Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 25 May 2025 05:48:37 +1000 Subject: fix crash when receiving an interact packet for a non-existent entity --- source/game/StarWorldClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/game') 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 const& packets) { } else if (auto entityInteract = as(packet)) { auto interactResult = interact(entityInteract->interactRequest).result(); - m_outgoingPackets.append(make_shared(interactResult.take(), entityInteract->requestId, entityInteract->interactRequest.sourceId)); + m_outgoingPackets.append(make_shared(interactResult.value(), entityInteract->requestId, entityInteract->interactRequest.sourceId)); } else if (auto interactResult = as(packet)) { if (auto response = m_entityInteractionResponses.maybeTake(interactResult->requestId)) { -- cgit v1.2.3 From f3079a79e7d336fabc6b8bbd0a670176e0b5bc6a Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 26 May 2025 05:36:50 +1000 Subject: client: attempt to disconnect safely instead of crashing when an incoming server packet causes an exception --- source/game/StarUniverseClient.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/game') 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; -- cgit v1.2.3