Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2025-05-26 05:36:50 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2025-05-26 05:36:50 +1000
commitf3079a79e7d336fabc6b8bbd0a670176e0b5bc6a (patch)
treee20a555c868eec0821fa21dd79a35c1b13a074ec /source/game
parentb9246dde76fc4011fe51193dc71683fb13c175a3 (diff)
client: attempt to disconnect safely instead of crashing when an incoming server packet causes an exception
Diffstat (limited to 'source/game')
-rw-r--r--source/game/StarUniverseClient.cpp10
1 files changed, 9 insertions, 1 deletions
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;