From aebfbfb8c8d623ded8d409d29983a5e871a475bc Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Sat, 2 Sep 2017 11:46:57 -0500 Subject: GetPacketID for protocol packet IDs (#3977) * Added GetPacketId method to protocol, implemented for all protocols. * Moved GetPacketID methods into a single file, alpha-sorted. * Fixed 1.12.1 HandlePacket switch statement. * Added SendLogin to the GetPacketId framework. * Added SpawnObject to GetPacketId framework. * Added missing sendEntityEquipment packet ID update for 1.12.1 * Added LeashEntity packet ID change to 1.12.1 * Alphabetized packet enum, added SpawnGlobalEntity to GetPacketId framework * Fixed clang errors * Indented cases, expanded comment for GetPacketId * Changed dyslexic comment. --- src/Protocol/Protocol.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src/Protocol/Protocol.h') diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index 54c5b7223..9c4ee5e71 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -56,9 +56,84 @@ public: virtual ~cProtocol() {} + /** A list of all outgoing packets */ + enum eOutgoingPackets + { + sendAttachEntity = 0, + sendBlockAction, + sendBlockBreakAnim, + sendBlockChange, + sendBlockChanges, + sendCameraSetTo, + sendChatRaw, + sendCollectEntity, + sendDestroyEntity, + sendDifficulty, + sendDisconnectDuringLogin, + sendDisconnectDuringGame, + sendDisplayObjective, + sendEditSign, + sendEntityAnimation, + sendEntityEffect, + sendEntityEquipment, + sendEntityHeadLook, + sendEntityLook, + sendEntityMeta, + sendEntityProperties, + sendEntityRelMove, + sendEntityRelMoveLook, + sendEntityStatus, + sendEntityVelocity, + sendExperience, + sendExperienceOrb, + sendExplosion, + sendGameMode, + sendHealth, + sendInventorySlot, + sendJoinGame, + sendKeepAlive, + sendLeashEntity, + sendMapData, + sendPaintingSpawn, + sendParticleEffect, + sendPlayerAbilities, + sendPlayerList, + sendPlayerMaxSpeed, + sendPlayerMoveLook, + sendPlayerSpawn, + sendPluginMessage, + sendRemoveEntityEffect, + sendRespawn, + sendScoreboardObjective, + sendScoreUpdate, + sendSpawnObject, + sendSoundEffect, + sendSoundParticleEffect, + sendSpawnGlobalEntity, + sendSpawnMob, + sendSpawnPosition, + sendStatistics, + sendTabCompletion, + sendTeleportEntity, + sendTimeUpdate, + sendTitle, + sendUnloadChunk, + sendUpdateBlockEntity, + sendUpdateSign, + sendUseBed, + sendWeather, + sendWindowItems, + sendWindowClose, + sendWindowOpen, + sendWindowProperty + }; + /** 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; -- cgit v1.2.3 From 028a35ef0d4719e56a5bcc1a3f2a780128498f5d Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Mon, 4 Sep 2017 10:58:38 -0500 Subject: Added assert to cProtocolRecognizer::GetPacketId. (#4001) --- src/Protocol/Protocol.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Protocol/Protocol.h') 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; -- cgit v1.2.3