From 939ebbee58152b95048dd7410879e2e73c997776 Mon Sep 17 00:00:00 2001 From: tycho Date: Sat, 3 Oct 2015 22:38:52 +0100 Subject: Broken --- src/ClientHandle.cpp | 6 +++--- src/Protocol/Protocol.h | 4 ++-- src/Protocol/Protocol17x.cpp | 2 +- src/Protocol/Protocol17x.h | 4 ++-- src/Protocol/Protocol18x.h | 4 ++-- src/Protocol/ProtocolRecognizer.cpp | 14 +++++++------- src/Protocol/ProtocolRecognizer.h | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 253593d14..c25cbdf11 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -59,7 +59,7 @@ int cClientHandle::s_ClientCount = 0; //////////////////////////////////////////////////////////////////////////////// // cClientHandle: - +#if 0 cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) : m_CurrentViewDistance(a_ViewDistance), m_RequestedViewDistance(a_ViewDistance), @@ -98,7 +98,7 @@ cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) : LOGD("New ClientHandle created at %p", static_cast(this)); } - +#endif @@ -2257,7 +2257,7 @@ void cClientHandle::SendDisconnect(const AString & a_Reason) if (!m_HasSentDC) { LOGD("Sending a DC: \"%s\"", StripColorCodes(a_Reason).c_str()); - m_Protocol->SendDisconnect(a_Reason); + m_Protocol->SendDisconnect(m_OutgoingData, a_Reason); m_HasSentDC = true; } } 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(&Packet), 1); // WriteByte() + cPacketizer Pkt(*this, 0xff); auto UTF16 = UTF8ToRawBEUTF16(a_Reason); - static const u_short Size = htons(static_cast(UTF16.size())); - SendData(reinterpret_cast(&Size), 2); // WriteShort() - SendData(reinterpret_cast(UTF16.data()), UTF16.size() * sizeof(char16_t)); // WriteString() + Pkt.WriteBEUInt16(static_cast(UTF16.size())); + Pkt.WriteBuf(reinterpret_cast(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; -- cgit v1.2.3