From 7f372b12cb01f7df9d5466de11b36494353613a8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 12 Sep 2020 21:08:23 +0100 Subject: Add State enum to protocol --- src/Protocol/Protocol_1_9.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/Protocol/Protocol_1_9.cpp') diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index b4fc47d0f..db0d4c17d 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -79,7 +79,7 @@ static const UInt32 OFF_HAND = 1; //////////////////////////////////////////////////////////////////////////////// // cProtocol_1_9_0: -cProtocol_1_9_0::cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) : +cProtocol_1_9_0::cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, State a_State) : Super(a_Client, a_ServerAddress, a_ServerPort, a_State), m_IsTeleportIdConfirmed(true), m_OutstandingTeleportId(0) @@ -575,9 +575,8 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy { switch (m_State) { - case 1: + case State::Status: { - // Status switch (a_PacketType) { case 0x00: HandlePacketStatusRequest(a_ByteBuffer); return true; @@ -586,9 +585,8 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy break; } - case 2: + case State::Login: { - // Login switch (a_PacketType) { case 0x00: HandlePacketLoginStart (a_ByteBuffer); return true; @@ -597,9 +595,8 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy break; } - case 3: + case State::Game: { - // Game switch (a_PacketType) { case 0x00: HandleConfirmTeleport (a_ByteBuffer); return true; @@ -643,10 +640,10 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy // Cannot kick the client - we don't know this state and thus the packet number for the kick packet // Switch to a state when all further packets are silently ignored: - m_State = 255; + m_State = State::Invalid; return false; } - case 255: + case State::Invalid: { // This is the state used for "not processing packets anymore" when we receive a bad packet from a client. // Do not output anything (the caller will do that for us), just return failure -- cgit v1.2.3