summaryrefslogtreecommitdiffstats
path: root/src/Protocol/Protocol18x.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-19 15:07:01 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-19 15:07:01 +0200
commit6aa331a4fa314daebfb76161b7e26685d7786e2e (patch)
tree7b4951bda1e752ffcaadf9765fc2125de2e90bf0 /src/Protocol/Protocol18x.cpp
parentUpdated SPAWNING_ENTITY hook description. (diff)
downloadcuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar.gz
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar.bz2
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar.lz
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar.xz
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.tar.zst
cuberite-6aa331a4fa314daebfb76161b7e26685d7786e2e.zip
Diffstat (limited to 'src/Protocol/Protocol18x.cpp')
-rw-r--r--src/Protocol/Protocol18x.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index 293080166..4b78bc4cd 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -75,6 +75,7 @@ Implements the 1.8.x protocol classes:
const int MAX_ENC_LEN = 512; // Maximum size of the encrypted message; should be 128, but who knows...
+const uLongf MAX_COMPRESSED_PACKET_LEN = 200 KiB; // Maximum size of compressed packets.
@@ -1513,11 +1514,10 @@ void cProtocol180::SendWindowProperty(const cWindow & a_Window, int a_Property,
bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_CompressedData)
{
// Compress the data:
- const uLongf CompressedMaxSize = 200000;
- char CompressedData[CompressedMaxSize];
+ char CompressedData[MAX_COMPRESSED_PACKET_LEN];
uLongf CompressedSize = compressBound(a_Packet.size());
- if (CompressedSize >= CompressedMaxSize)
+ if (CompressedSize >= MAX_COMPRESSED_PACKET_LEN)
{
ASSERT(!"Too high packet size.");
return false;
@@ -1541,7 +1541,7 @@ bool cProtocol180::CompressPacket(const AString & a_Packet, AString & a_Compress
Buffer.CommitRead();
a_CompressedData.clear();
- a_CompressedData.resize(LengthData.size() + CompressedSize);
+ a_CompressedData.reserve(LengthData.size() + CompressedSize);
a_CompressedData.append(LengthData.data(), LengthData.size());
a_CompressedData.append(CompressedData, CompressedSize);
return true;