summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol.h4
-rw-r--r--src/Protocol/Protocol17x.cpp2
-rw-r--r--src/Protocol/Protocol17x.h4
-rw-r--r--src/Protocol/Protocol18x.h4
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp14
-rw-r--r--src/Protocol/ProtocolRecognizer.h2
6 files changed, 15 insertions, 15 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 8e6bfae7d..e3b64211f 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -107,7 +107,7 @@ public:
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) = 0;
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
- virtual void SendDisconnect (const AString & a_Reason) = 0;
+ virtual void SendDisconnect (AString & a_ByteBuffer, const AString & a_Reason) = 0;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) = 0; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) = 0;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) = 0;
@@ -204,7 +204,7 @@ protected:
/** A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it. */
- virtual void SendData(cByteBuffer & a_ByteBuffer, const char * a_Data, size_t a_Size) = 0;
+ //virtual void SendData(cByteBuffer & a_ByteBuffer, const char * a_Data, size_t a_Size) = 0;
/** Sends a single packet contained within the cPacketizer class.
The cPacketizer's destructor calls this to send the contained packet; protocol may transform the data (compression in 1.8 etc). */
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 4e3b985e1..dd61e3e0c 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -278,7 +278,7 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
-void cProtocol172::SendDisconnect(const AString & a_Reason)
+void cProtocol172::SendDisconnect(AString & a_ByteBuffer, const AString & a_Reason)
{
switch (m_State)
{
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index bc4479529..e7ecc1650 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -66,7 +66,7 @@ public:
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
- virtual void SendDisconnect (const AString & a_Reason) override;
+ virtual void SendDisconnect (AString & a_ByteBuffer, const AString & a_Reason) override;
virtual void SendDisplayObjective (const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override;
@@ -200,7 +200,7 @@ protected:
void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel, UInt16 a_PayloadLength);
/** Sends the data to the client, encrypting them if needed. */
- //virtual void SendData(const char * a_Data, size_t a_Size) override;
+ //virtual void SendData(cByteBuffer & a_Buffer, const char * a_Data, size_t a_Size) override;
/** Sends the packet to the client. Called by the cPacketizer's destructor. */
virtual void SendPacket(cPacketizer & a_Packet) override;
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index dcb6f7f22..005791da9 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -68,7 +68,7 @@ public:
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
- virtual void SendDisconnect (const AString & a_Reason) override;
+ virtual void SendDisconnect (AString & a_ByteBuffer, const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;
@@ -222,7 +222,7 @@ protected:
/** Sends the data to the client, encrypting them if needed. */
- //virtual void SendData(const char * a_Data, size_t a_Size) override;
+ //virtual void SendData(cByteBuffer & a_ByteBuffer, const char * a_Data, size_t a_Size) override;
/** Sends the packet to the client. Called by the cPacketizer's destructor. */
virtual void SendPacket(cPacketizer & a_Packet) override;
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index 1c4333305..4b23daf22 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -15,6 +15,7 @@
#include "../World.h"
#include "../ChatColor.h"
#include "Bindings/PluginManager.h"
+#include "Packetizer.h"
@@ -177,7 +178,7 @@ void cProtocolRecognizer::SendDestroyEntity(const cEntity & a_Entity)
-void cProtocolRecognizer::SendDisconnect(cByteBuffer & a_ByteBuffer, const AString & a_Reason)
+void cProtocolRecognizer::SendDisconnect(AString & a_ByteBuffer, const AString & a_Reason)
{
if (m_Protocol != nullptr)
{
@@ -185,19 +186,18 @@ void cProtocolRecognizer::SendDisconnect(cByteBuffer & a_ByteBuffer, const AStri
}
else
{
+
// This is used when the client sends a server-ping, respond with the default packet:
- static const int Packet = 0xff; // PACKET_DISCONNECT
- a_ByteBuffer.Write(reinterpret_cast<const char *>(&Packet), 1); // WriteByte()
+ cPacketizer Pkt(*this, 0xff);
auto UTF16 = UTF8ToRawBEUTF16(a_Reason);
- static const u_short Size = htons(static_cast<u_short>(UTF16.size()));
- SendData(reinterpret_cast<const char *>(&Size), 2); // WriteShort()
- SendData(reinterpret_cast<const char *>(UTF16.data()), UTF16.size() * sizeof(char16_t)); // WriteString()
+ Pkt.WriteBEUInt16(static_cast<UInt16>(UTF16.size()));
+ Pkt.WriteBuf(reinterpret_cast<const char *>(UTF16.data()), UTF16.size() * sizeof(char16_t));
}
}
-e
+
void cProtocolRecognizer::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
{
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index 49a56047f..7f1758463 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -57,7 +57,7 @@ public:
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
- virtual void SendDisconnect (const AString & a_Reason) override;
+ virtual void SendDisconnect (AString & a_ByteBuffer, const AString & a_Reason) override;
virtual void SendEditSign (int a_BlockX, int a_BlockY, int a_BlockZ) override; ///< Request the client to open up the sign editor for the sign (1.6+)
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
virtual void SendEntityEquipment (const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item) override;