From f64dd786aadc4fafc4e7b771fe50b7c6ae95ccad Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 8 Dec 2013 13:37:10 +0000 Subject: Fixed tabcompletion packet, fixes #356 --- src/Protocol/Protocol17x.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 233155c90..75983e9a3 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -744,17 +744,13 @@ void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results) { - AString Results; - Results.reserve(500); // Make a moderate reservation to avoid excessive reallocations + cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet + Pkt.WriteVarInt(a_Results.size()); + for (AStringVector::const_iterator itr = a_Results.begin(), end = a_Results.end(); itr != end; ++itr) { - Results.append(*itr); - Results.push_back(0); + Pkt.WriteString(*itr); } - - cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet - Pkt.WriteVarInt(a_Results.size()); - Pkt.WriteString(Results); } -- cgit v1.2.3