1
0

Protocol: Use logical outgoing packet types.

This commit is contained in:
Mattes D
2019-09-09 18:22:37 +02:00
parent ad24702b4e
commit 2c804dd34a
17 changed files with 705 additions and 517 deletions

View File

@@ -5,7 +5,8 @@
Implements the 1.11 protocol classes:
- cProtocol_1_11_0
- release 1.11 protocol (#315)
(others may be added later in the future for the 1.11 release series)
- cProtocol_1_11_1
- release 1.11.1 protocol (#316)
*/
#include "Globals.h"
@@ -332,7 +333,7 @@ namespace Metadata
cProtocol_1_11_0::cProtocol_1_11_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) :
super(a_Client, a_ServerAddress, a_ServerPort, a_State)
Super(a_Client, a_ServerAddress, a_ServerPort, a_State)
{
}
@@ -344,7 +345,7 @@ void cProtocol_1_11_0::SendCollectEntity(const cEntity & a_Entity, const cPlayer
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, GetPacketId(sendCollectEntity)); // Collect Item packet
cPacketizer Pkt(*this, pktCollectEntity);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteVarInt32(a_Player.GetUniqueID());
Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
@@ -358,7 +359,7 @@ void cProtocol_1_11_0::SendHideTitle(void)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
cPacketizer Pkt(*this, pktTitle);
Pkt.WriteVarInt32(4); // Hide title
}
@@ -370,7 +371,7 @@ void cProtocol_1_11_0::SendResetTitle(void)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, GetPacketId(sendTitle)); // Title packet
cPacketizer Pkt(*this, pktTitle);
Pkt.WriteVarInt32(5); // Reset title
}
@@ -382,7 +383,7 @@ void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob)
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, GetPacketId(sendSpawnMob)); // Spawn Mob packet
cPacketizer Pkt(*this, pktSpawnMob);
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
// TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now.
Pkt.WriteBEUInt64(0);
@@ -526,7 +527,7 @@ void cProtocol_1_11_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int
{
ASSERT(m_State == 3); // In game mode?
cPacketizer Pkt(*this, 0x45); // Title packet
cPacketizer Pkt(*this, pktTitle);
Pkt.WriteVarInt32(3); // Set title display times
Pkt.WriteBEInt32(a_FadeInTicks);
Pkt.WriteBEInt32(a_DisplayTicks);
@@ -594,7 +595,7 @@ void cProtocol_1_11_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
// Serialize the response into a packet:
Json::FastWriter Writer;
cPacketizer Pkt(*this, 0x00); // Response packet
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Writer.write(ResponseValue));
}
@@ -1175,7 +1176,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_
cProtocol_1_11_1::cProtocol_1_11_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) :
super(a_Client, a_ServerAddress, a_ServerPort, a_State)
Super(a_Client, a_ServerAddress, a_ServerPort, a_State)
{
}
@@ -1220,6 +1221,6 @@ void cProtocol_1_11_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
// Serialize the response into a packet:
Json::FastWriter Writer;
cPacketizer Pkt(*this, 0x00); // Response packet
cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Writer.write(ResponseValue));
}