summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ProtocolRecognizer.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-01-03 17:31:13 +0100
committerMattes D <github@xoft.cz>2020-01-07 06:53:17 +0100
commit4aef80b47eb6941d7fc41e57efe147af0ece1f9b (patch)
tree4aeb7c9e8e4aa3ae2ceed1cc60155d868852c5cd /src/Protocol/ProtocolRecognizer.cpp
parentStringUtils: Added note to StringsConcat about StringJoin. (diff)
downloadcuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.gz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.bz2
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.lz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.xz
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.tar.zst
cuberite-4aef80b47eb6941d7fc41e57efe147af0ece1f9b.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 6ad0a095d..17b42dae9 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -1038,7 +1038,24 @@ bool cProtocolRecognizer::TryRecognizeProtocol(void)
// Not enough bytes for the packet, keep waiting
return false;
}
- return TryRecognizeLengthedProtocol(PacketLen - ReadSoFar);
+ if (!TryRecognizeLengthedProtocol(PacketLen - ReadSoFar))
+ {
+ return false;
+ }
+
+ // The protocol has been recognized, initialize it:
+ ASSERT(m_Protocol != nullptr);
+ try
+ {
+ m_Protocol->Initialize(*m_Client);
+ }
+ catch (const std::exception & exc)
+ {
+ m_Client->Kick(exc.what());
+ m_Protocol.reset();
+ return false;
+ }
+ return true;
}