summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorLane Kolbly <lane@rscheme.org>2017-09-04 17:58:38 +0200
committerAlexander Harkness <me@bearbin.net>2017-09-04 17:58:38 +0200
commit028a35ef0d4719e56a5bcc1a3f2a780128498f5d (patch)
tree67d5e9a4fdf9a89f59578b47149799b5b9550719 /src/Protocol
parentGetPacketID for protocol packet IDs (#3977) (diff)
downloadcuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar.gz
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar.bz2
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar.lz
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar.xz
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.tar.zst
cuberite-028a35ef0d4719e56a5bcc1a3f2a780128498f5d.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Protocol.h6
-rw-r--r--src/Protocol/ProtocolRecognizer.h10
-rw-r--r--src/Protocol/Protocol_1_12.h8
-rw-r--r--src/Protocol/Protocol_1_8.h10
-rw-r--r--src/Protocol/Protocol_1_9.h12
5 files changed, 29 insertions, 17 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 9c4ee5e71..235b60020 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -131,9 +131,6 @@ public:
/** Called when client sends some data */
virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
- /** Returns the protocol-specific packet ID given the protocol-agnostic packet enum (see PacketID.cpp for implementations) */
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) = 0;
-
// Sending stuff to clients (alphabetically sorted):
virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity & a_Vehicle) = 0;
virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) = 0;
@@ -240,6 +237,9 @@ protected:
/** Buffer for composing packet length (so that each cPacketizer instance doesn't allocate a new cPacketBuffer) */
cByteBuffer m_OutPacketLenBuffer;
+ /** Returns the protocol-specific packet ID given the protocol-agnostic packet enum (see PacketID.cpp for implementations) */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) = 0;
+
/** A generic data-sending routine, all outgoing packet data needs to be routed through this so that descendants may override it. */
virtual void SendData(const char * a_Data, size_t a_Size) = 0;
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index f96d5aa77..6d75b0f2e 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -52,9 +52,6 @@ public:
/** Translates protocol version number into protocol version text: 49 -> "1.4.4" */
static AString GetVersionTextFromInt(int a_ProtocolVersion);
- /** GetPacketId is implemented in each protocol version class */
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override { return 0; }
-
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
@@ -159,6 +156,13 @@ protected:
/** Is a server list ping for an unrecognized version currently occuring? */
bool m_InPingForUnrecognizedVersion;
+ /** GetPacketId is implemented in each protocol version class */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override
+ {
+ ASSERT(!"cProtocolRecognizer::GetPacketId should never be called! Something is horribly wrong! (this method being called implies that someone other than a Protocol-derived class is calling GetPacketId)");
+ return 0;
+ }
+
// Packet handlers while in status state (m_InPingForUnrecognizedVersion == true)
void HandlePacketStatusRequest();
void HandlePacketStatusPing();
diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h
index ed47f7ef2..9b87494a6 100644
--- a/src/Protocol/Protocol_1_12.h
+++ b/src/Protocol/Protocol_1_12.h
@@ -30,8 +30,6 @@ class cProtocol_1_12 :
public:
cProtocol_1_12(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
-
virtual void SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
virtual void SendHideTitle(void) override;
virtual void SendResetTitle(void) override;
@@ -45,6 +43,10 @@ protected:
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
+
+protected:
+
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
};
@@ -59,9 +61,9 @@ class cProtocol_1_12_1 :
public:
cProtocol_1_12_1(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
+protected:
virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
-protected:
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
};
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index 472538d60..108cc9798 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -45,9 +45,6 @@ public:
cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- /** Nobody inherits 1.8, so it doesn't use this method */
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override { return 0; }
-
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
@@ -176,6 +173,13 @@ protected:
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
+ /** Nobody inherits 1.8, so it doesn't use this method */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override
+ {
+ ASSERT(!"GetPacketId for cProtocol_1_8_0 is not implemented.");
+ return 0;
+ }
+
/** Reads and handles the packet. The packet length and type have already been read.
Returns true if the packet was understood, false if it was an unknown packet
*/
diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h
index 200f10004..d08b76755 100644
--- a/src/Protocol/Protocol_1_9.h
+++ b/src/Protocol/Protocol_1_9.h
@@ -51,9 +51,6 @@ public:
cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- /** Get the packet ID for a given packet */
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
-
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
@@ -186,6 +183,9 @@ protected:
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
+ /** Get the packet ID for a given packet */
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
+
/** Reads and handles the packet. The packet length and type have already been read.
Returns true if the packet was understood, false if it was an unknown packet. */
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType);
@@ -339,14 +339,16 @@ class cProtocol_1_9_4 :
public:
cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
- virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
-
// cProtocol_1_9_2 overrides:
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
virtual void SendUpdateSign (int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) override;
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
+protected:
+
+ virtual UInt32 GetPacketId(eOutgoingPackets a_Packet) override;
+
} ;