Merge pull request #3480 from cuberite/proto_1_11
Initial support for the 1.11 protocol
This commit is contained in:
commit
71e14ee358
@ -2909,7 +2909,7 @@ void cChunk::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cons
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
|
void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
|
for (auto itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr)
|
||||||
{
|
{
|
||||||
@ -2917,7 +2917,7 @@ void cChunk::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
(*itr)->SendCollectEntity(a_Entity, a_Player);
|
(*itr)->SendCollectEntity(a_Entity, a_Player, a_Count);
|
||||||
} // for itr - LoadedByClient[]
|
} // for itr - LoadedByClient[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ public:
|
|||||||
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
||||||
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
||||||
|
@ -332,7 +332,7 @@ void cChunkMap::BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
|
void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSChunks);
|
cCSLock Lock(m_CSChunks);
|
||||||
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkZ());
|
cChunkPtr Chunk = GetChunkNoGen(a_Entity.GetChunkX(), a_Entity.GetChunkZ());
|
||||||
@ -341,7 +341,7 @@ void cChunkMap::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer &
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// It's perfectly legal to broadcast packets even to invalid chunks!
|
// It's perfectly legal to broadcast packets even to invalid chunks!
|
||||||
Chunk->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
|
Chunk->BroadcastCollectEntity(a_Entity, a_Player, a_Count, a_Exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastBlockBreakAnimation(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
|
void BroadcastBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude);
|
||||||
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
void BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
||||||
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
||||||
|
@ -2426,9 +2426,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
|
void cClientHandle::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
|
||||||
{
|
{
|
||||||
m_Protocol->SendCollectEntity(a_Entity, a_Player);
|
m_Protocol->SendCollectEntity(a_Entity, a_Player, a_Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public: // tolua_export
|
|||||||
void SendChatSystem (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
|
void SendChatSystem (const AString & a_Message, eMessageType a_ChatPrefix, const AString & a_AdditionalData = "");
|
||||||
void SendChatSystem (const cCompositeChat & a_Message);
|
void SendChatSystem (const cCompositeChat & a_Message);
|
||||||
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
|
void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer);
|
||||||
void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player);
|
void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count);
|
||||||
void SendDestroyEntity (const cEntity & a_Entity);
|
void SendDestroyEntity (const cEntity & a_Entity);
|
||||||
void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
||||||
void SendDisconnect (const AString & a_Reason);
|
void SendDisconnect (const AString & a_Reason);
|
||||||
|
@ -406,7 +406,14 @@ AString cCompositeChat::CreateJsonString(bool a_ShouldUseChatPrefixes) const
|
|||||||
msg["extra"].append(Part);
|
msg["extra"].append(Part);
|
||||||
} // for itr - Parts[]
|
} // for itr - Parts[]
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// Serialize as machine-readable string (no whitespace):
|
||||||
|
Json::FastWriter writer;
|
||||||
|
return writer.write(msg);
|
||||||
|
#else
|
||||||
|
// Serialize as human-readable string (pretty-printed):
|
||||||
return msg.toStyledString();
|
return msg.toStyledString();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void cArrowEntity::CollectedBy(cPlayer & a_Dest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWorld()->BroadcastCollectEntity(*this, a_Dest);
|
GetWorld()->BroadcastCollectEntity(*this, a_Dest, 1);
|
||||||
GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
|
GetWorld()->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
|
||||||
m_bIsCollected = true;
|
m_bIsCollected = true;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ bool cPickup::CollectedBy(cPlayer & a_Dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Item.m_ItemCount -= NumAdded;
|
m_Item.m_ItemCount -= NumAdded;
|
||||||
m_World->BroadcastCollectEntity(*this, a_Dest);
|
m_World->BroadcastCollectEntity(*this, a_Dest, NumAdded);
|
||||||
|
|
||||||
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
|
// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
|
||||||
m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
|
m_World->BroadcastSoundEffect("random.pop", GetPosX(), GetPosY(), GetPosZ(), 0.5, (0.75f + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));
|
||||||
|
@ -7,9 +7,10 @@ SET (SRCS
|
|||||||
ChunkDataSerializer.cpp
|
ChunkDataSerializer.cpp
|
||||||
MojangAPI.cpp
|
MojangAPI.cpp
|
||||||
Packetizer.cpp
|
Packetizer.cpp
|
||||||
Protocol18x.cpp
|
Protocol_1_8.cpp
|
||||||
Protocol19x.cpp
|
Protocol_1_9.cpp
|
||||||
Protocol110x.cpp
|
Protocol_1_10.cpp
|
||||||
|
Protocol_1_11.cpp
|
||||||
ProtocolRecognizer.cpp
|
ProtocolRecognizer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,16 +20,17 @@ SET (HDRS
|
|||||||
MojangAPI.h
|
MojangAPI.h
|
||||||
Packetizer.h
|
Packetizer.h
|
||||||
Protocol.h
|
Protocol.h
|
||||||
Protocol18x.h
|
Protocol_1_8.h
|
||||||
Protocol19x.h
|
Protocol_1_9.h
|
||||||
Protocol110x.h
|
Protocol_1_10.h
|
||||||
|
Protocol_1_11.h
|
||||||
ProtocolRecognizer.h
|
ProtocolRecognizer.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set_source_files_properties(Protocol19x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
|
set_source_files_properties(Protocol_1_9.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
|
||||||
set_source_files_properties(Protocol18x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
|
set_source_files_properties(Protocol_1_8.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum -Wno-error=switch")
|
||||||
set_source_files_properties(Protocol110x.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch")
|
set_source_files_properties(Protocol_1_10.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include "ChunkDataSerializer.h"
|
#include "ChunkDataSerializer.h"
|
||||||
#include "zlib/zlib.h"
|
#include "zlib/zlib.h"
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
#include "Protocol18x.h"
|
#include "Protocol_1_8.h"
|
||||||
#include "Protocol19x.h"
|
#include "Protocol_1_9.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu
|
|||||||
cByteBuffer Buffer(20);
|
cByteBuffer Buffer(20);
|
||||||
if (PacketData.size() >= 256)
|
if (PacketData.size() >= 256)
|
||||||
{
|
{
|
||||||
if (!cProtocol180::CompressPacket(PacketData, a_Data))
|
if (!cProtocol_1_8_0::CompressPacket(PacketData, a_Data))
|
||||||
{
|
{
|
||||||
ASSERT(!"Packet compression failed.");
|
ASSERT(!"Packet compression failed.");
|
||||||
a_Data.clear();
|
a_Data.clear();
|
||||||
@ -254,7 +254,7 @@ void cChunkDataSerializer::Serialize107(AString & a_Data, int a_ChunkX, int a_Ch
|
|||||||
cByteBuffer Buffer(20);
|
cByteBuffer Buffer(20);
|
||||||
if (PacketData.size() >= 256)
|
if (PacketData.size() >= 256)
|
||||||
{
|
{
|
||||||
if (!cProtocol190::CompressPacket(PacketData, a_Data))
|
if (!cProtocol_1_9_0::CompressPacket(PacketData, a_Data))
|
||||||
{
|
{
|
||||||
ASSERT(!"Packet compression failed.");
|
ASSERT(!"Packet compression failed.");
|
||||||
a_Data.clear();
|
a_Data.clear();
|
||||||
@ -400,7 +400,7 @@ void cChunkDataSerializer::Serialize110(AString & a_Data, int a_ChunkX, int a_Ch
|
|||||||
cByteBuffer Buffer(20);
|
cByteBuffer Buffer(20);
|
||||||
if (PacketData.size() >= 256)
|
if (PacketData.size() >= 256)
|
||||||
{
|
{
|
||||||
if (!cProtocol190::CompressPacket(PacketData, a_Data))
|
if (!cProtocol_1_9_0::CompressPacket(PacketData, a_Data))
|
||||||
{
|
{
|
||||||
ASSERT(!"Packet compression failed.");
|
ASSERT(!"Packet compression failed.");
|
||||||
a_Data.clear();
|
a_Data.clear();
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) = 0;
|
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) = 0;
|
||||||
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) = 0;
|
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) = 0;
|
||||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) = 0;
|
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 SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) = 0;
|
||||||
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
|
virtual void SendDestroyEntity (const cEntity & a_Entity) = 0;
|
||||||
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) = 0;
|
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) = 0;
|
||||||
virtual void SendDisconnect (const AString & a_Reason) = 0;
|
virtual void SendDisconnect (const AString & a_Reason) = 0;
|
||||||
|
@ -7,9 +7,10 @@
|
|||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
#include "ProtocolRecognizer.h"
|
#include "ProtocolRecognizer.h"
|
||||||
#include "Protocol18x.h"
|
#include "Protocol_1_8.h"
|
||||||
#include "Protocol19x.h"
|
#include "Protocol_1_9.h"
|
||||||
#include "Protocol110x.h"
|
#include "Protocol_1_10.h"
|
||||||
|
#include "Protocol_1_11.h"
|
||||||
#include "Packetizer.h"
|
#include "Packetizer.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
@ -54,6 +55,7 @@ AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
|
|||||||
case PROTO_VERSION_1_9_2: return "1.9.2";
|
case PROTO_VERSION_1_9_2: return "1.9.2";
|
||||||
case PROTO_VERSION_1_9_4: return "1.9.4";
|
case PROTO_VERSION_1_9_4: return "1.9.4";
|
||||||
case PROTO_VERSION_1_10_0: return "1.10";
|
case PROTO_VERSION_1_10_0: return "1.10";
|
||||||
|
case PROTO_VERSION_1_11_0: return "1.11";
|
||||||
}
|
}
|
||||||
ASSERT(!"Unknown protocol version");
|
ASSERT(!"Unknown protocol version");
|
||||||
return Printf("Unknown protocol (%d)", a_ProtocolVersion);
|
return Printf("Unknown protocol (%d)", a_ProtocolVersion);
|
||||||
@ -220,10 +222,10 @@ void cProtocolRecognizer::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSe
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocolRecognizer::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
|
void cProtocolRecognizer::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
|
||||||
{
|
{
|
||||||
ASSERT(m_Protocol != nullptr);
|
ASSERT(m_Protocol != nullptr);
|
||||||
m_Protocol->SendCollectEntity(a_Entity, a_Player);
|
m_Protocol->SendCollectEntity(a_Entity, a_Player, a_Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -978,8 +980,7 @@ void cProtocolRecognizer::SendData(const char * a_Data, size_t a_Size)
|
|||||||
|
|
||||||
bool cProtocolRecognizer::TryRecognizeProtocol(void)
|
bool cProtocolRecognizer::TryRecognizeProtocol(void)
|
||||||
{
|
{
|
||||||
// NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and
|
// NOTE: If a new protocol is added or an old one is removed, adjust MCS_CLIENT_VERSIONS and MCS_PROTOCOL_VERSIONS macros in the header file
|
||||||
// MCS_PROTOCOL_VERSIONS macros in the header file, as well as PROTO_VERSION_LATEST macro
|
|
||||||
|
|
||||||
// Lengthed protocol, try if it has the entire initial handshake packet:
|
// Lengthed protocol, try if it has the entire initial handshake packet:
|
||||||
UInt32 PacketLen;
|
UInt32 PacketLen;
|
||||||
@ -1045,37 +1046,42 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
|
|||||||
case PROTO_VERSION_1_8_0:
|
case PROTO_VERSION_1_8_0:
|
||||||
{
|
{
|
||||||
m_Buffer.CommitRead();
|
m_Buffer.CommitRead();
|
||||||
m_Protocol = new cProtocol180(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_8_0(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PROTO_VERSION_1_9_0:
|
case PROTO_VERSION_1_9_0:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol190(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_9_0(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PROTO_VERSION_1_9_1:
|
case PROTO_VERSION_1_9_1:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol191(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_9_1(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PROTO_VERSION_1_9_2:
|
case PROTO_VERSION_1_9_2:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol192(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_9_2(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PROTO_VERSION_1_9_4:
|
case PROTO_VERSION_1_9_4:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol194(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_9_4(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case PROTO_VERSION_1_10_0:
|
case PROTO_VERSION_1_10_0:
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocol1100(m_Client, ServerAddress, ServerPort, NextState);
|
m_Protocol = new cProtocol_1_10_0(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PROTO_VERSION_1_11_0:
|
||||||
|
{
|
||||||
|
m_Protocol = new cProtocol_1_11_0(m_Client, ServerAddress, ServerPort, NextState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
LOGINFO("Client \"%s\" uses an unsupported protocol (lengthed, version %u (0x%x))",
|
LOGD("Client \"%s\" uses an unsupported protocol (lengthed, version %u (0x%x))",
|
||||||
m_Client->GetIPString().c_str(), ProtocolVersion, ProtocolVersion
|
m_Client->GetIPString().c_str(), ProtocolVersion, ProtocolVersion
|
||||||
);
|
);
|
||||||
if (NextState != 1)
|
if (NextState != 1)
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
|
|
||||||
// Adjust these if a new protocol is added or an old one is removed:
|
// Adjust these if a new protocol is added or an old one is removed:
|
||||||
#define MCS_CLIENT_VERSIONS "1.8.x, 1.9.x, 1.10.x"
|
#define MCS_CLIENT_VERSIONS "1.8.x, 1.9.x, 1.10.x, 1.11"
|
||||||
#define MCS_PROTOCOL_VERSIONS "47, 107, 108, 109, 110, 210"
|
#define MCS_PROTOCOL_VERSIONS "47, 107, 108, 109, 110, 210, 315"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ public:
|
|||||||
PROTO_VERSION_1_9_2 = 109,
|
PROTO_VERSION_1_9_2 = 109,
|
||||||
PROTO_VERSION_1_9_4 = 110,
|
PROTO_VERSION_1_9_4 = 110,
|
||||||
PROTO_VERSION_1_10_0 = 210,
|
PROTO_VERSION_1_10_0 = 210,
|
||||||
|
PROTO_VERSION_1_11_0 = 315,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
cProtocolRecognizer(cClientHandle * a_Client);
|
cProtocolRecognizer(cClientHandle * a_Client);
|
||||||
@ -61,7 +62,7 @@ public:
|
|||||||
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
||||||
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
||||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
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 SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
|
||||||
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
||||||
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
||||||
virtual void SendDisconnect (const AString & a_Reason) override;
|
virtual void SendDisconnect (const AString & a_Reason) override;
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
|
|
||||||
// Protocol110x.cpp
|
// Protocol_1_10.cpp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Implements the 1.10.x protocol classes:
|
Implements the 1.10 protocol classes:
|
||||||
- cProtocol1100
|
- cProtocol_1_10_0
|
||||||
- release 1.10.0 protocol (#210)
|
- release 1.10 protocol (#210), also used by 1.10.1 and 1.10.2
|
||||||
(others may be added later in the future for the 1.10 release series)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Protocol110x.h"
|
#include "Protocol_1_10.h"
|
||||||
#include "Packetizer.h"
|
#include "Packetizer.h"
|
||||||
|
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
@ -283,7 +282,7 @@ namespace Metadata
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cProtocol1100::cProtocol1100(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State) :
|
cProtocol_1_10_0::cProtocol_1_10_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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -292,7 +291,7 @@ cProtocol1100::cProtocol1100(cClientHandle * a_Client, const AString &a_ServerAd
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol1100::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
|
void cProtocol_1_10_0::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
|
||||||
{
|
{
|
||||||
ASSERT(m_State == 3); // In game mode?
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
@ -310,7 +309,7 @@ void cProtocol1100::SendSoundEffect(const AString & a_SoundName, double a_X, dou
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol1100::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
void cProtocol_1_10_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||||
{
|
{
|
||||||
cServer * Server = cRoot::Get()->GetServer();
|
cServer * Server = cRoot::Get()->GetServer();
|
||||||
AString ServerDescription = Server->GetDescription();
|
AString ServerDescription = Server->GetDescription();
|
||||||
@ -355,7 +354,7 @@ void cProtocol1100::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol1100::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity)
|
void cProtocol_1_10_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity)
|
||||||
{
|
{
|
||||||
using namespace Metadata;
|
using namespace Metadata;
|
||||||
|
|
||||||
@ -552,7 +551,7 @@ void cProtocol1100::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_E
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol1100::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
|
void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
|
||||||
{
|
{
|
||||||
using namespace Metadata;
|
using namespace Metadata;
|
||||||
|
|
@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
// Protocol110x.h
|
// Protocol_1_10.h
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Declares the 1.10.x protocol classes:
|
Declares the 1.10 protocol classes:
|
||||||
- cProtocol1100
|
- cProtocol_1_10
|
||||||
- release 1.10.0 protocol (#210)
|
- release 1.10 protocol (#210), also used by 1.10.1 and 1.10.2
|
||||||
(others may be added later in the future for the 1.10 release series)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -14,15 +13,19 @@ Declares the 1.10.x protocol classes:
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Protocol19x.h"
|
#include "Protocol_1_9.h"
|
||||||
|
|
||||||
class cProtocol1100 :
|
|
||||||
public cProtocol194
|
|
||||||
|
|
||||||
|
|
||||||
|
class cProtocol_1_10_0 :
|
||||||
|
public cProtocol_1_9_4
|
||||||
{
|
{
|
||||||
typedef cProtocol194 super;
|
typedef cProtocol_1_9_4 super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cProtocol1100(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_10_0(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
virtual void SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
|
virtual void SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override;
|
||||||
|
|
189
src/Protocol/Protocol_1_11.cpp
Normal file
189
src/Protocol/Protocol_1_11.cpp
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
|
||||||
|
// Protocol_1_11.cpp
|
||||||
|
|
||||||
|
/*
|
||||||
|
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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "Protocol_1_11.h"
|
||||||
|
#include "ProtocolRecognizer.h"
|
||||||
|
#include "Packetizer.h"
|
||||||
|
|
||||||
|
#include "../Root.h"
|
||||||
|
#include "../Server.h"
|
||||||
|
#include "../ClientHandle.h"
|
||||||
|
#include "../CompositeChat.h"
|
||||||
|
#include "../Bindings/PluginManager.h"
|
||||||
|
#include "../Entities/Player.h"
|
||||||
|
#include "../Mobs/Monster.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define HANDLE_READ(ByteBuf, Proc, Type, Var) \
|
||||||
|
Type Var; \
|
||||||
|
if (!ByteBuf.Proc(Var))\
|
||||||
|
{\
|
||||||
|
return;\
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
|
||||||
|
{
|
||||||
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
|
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
|
||||||
|
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
|
||||||
|
Pkt.WriteVarInt32(a_Player.GetUniqueID());
|
||||||
|
Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::SendHideTitle(void)
|
||||||
|
{
|
||||||
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
|
cPacketizer Pkt(*this, 0x45); // Title packet
|
||||||
|
Pkt.WriteVarInt32(4); // Hide title
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::SendResetTitle(void)
|
||||||
|
{
|
||||||
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
|
cPacketizer Pkt(*this, 0x45); // Title packet
|
||||||
|
Pkt.WriteVarInt32(5); // Reset title
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob)
|
||||||
|
{
|
||||||
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
|
cPacketizer Pkt(*this, 0x0f); // Spawn Mob packet
|
||||||
|
Pkt.WriteVarInt32(a_Mob.GetUniqueID());
|
||||||
|
Pkt.WriteVarInt32(static_cast<UInt32>(a_Mob.GetMobType()));
|
||||||
|
Pkt.WriteFPInt(a_Mob.GetPosX());
|
||||||
|
Pkt.WriteFPInt(a_Mob.GetPosY());
|
||||||
|
Pkt.WriteFPInt(a_Mob.GetPosZ());
|
||||||
|
Pkt.WriteByteAngle(a_Mob.GetPitch());
|
||||||
|
Pkt.WriteByteAngle(a_Mob.GetHeadYaw());
|
||||||
|
Pkt.WriteByteAngle(a_Mob.GetYaw());
|
||||||
|
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedX() * 400));
|
||||||
|
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedY() * 400));
|
||||||
|
Pkt.WriteBEInt16(static_cast<Int16>(a_Mob.GetSpeedZ() * 400));
|
||||||
|
WriteEntityMetadata(Pkt, a_Mob);
|
||||||
|
Pkt.WriteBEUInt8(0x7f); // Metadata terminator
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks)
|
||||||
|
{
|
||||||
|
ASSERT(m_State == 3); // In game mode?
|
||||||
|
|
||||||
|
cPacketizer Pkt(*this, 0x45); // Title packet
|
||||||
|
Pkt.WriteVarInt32(3); // Set title display times
|
||||||
|
Pkt.WriteBEInt32(a_FadeInTicks);
|
||||||
|
Pkt.WriteBEInt32(a_DisplayTicks);
|
||||||
|
Pkt.WriteBEInt32(a_FadeOutTicks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::HandlePacketBlockPlace(cByteBuffer & a_ByteBuffer)
|
||||||
|
{
|
||||||
|
int BlockX, BlockY, BlockZ;
|
||||||
|
if (!a_ByteBuffer.ReadPosition64(BlockX, BlockY, BlockZ))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Face);
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand);
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorX);
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorY);
|
||||||
|
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, CursorZ);
|
||||||
|
m_Client->HandleRightClick(BlockX, BlockY, BlockZ, FaceIntToBlockFace(Face), FloorC(CursorX * 16), FloorC(CursorY * 16), FloorC(CursorZ * 16), m_Client->GetPlayer()->GetEquippedItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol_1_11_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer)
|
||||||
|
{
|
||||||
|
cServer * Server = cRoot::Get()->GetServer();
|
||||||
|
AString ServerDescription = Server->GetDescription();
|
||||||
|
int NumPlayers = Server->GetNumPlayers();
|
||||||
|
int MaxPlayers = Server->GetMaxPlayers();
|
||||||
|
AString Favicon = Server->GetFaviconData();
|
||||||
|
cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon);
|
||||||
|
|
||||||
|
// Version:
|
||||||
|
Json::Value Version;
|
||||||
|
Version["name"] = "Cuberite 1.11";
|
||||||
|
Version["protocol"] = cProtocolRecognizer::PROTO_VERSION_1_11_0;
|
||||||
|
|
||||||
|
// Players:
|
||||||
|
Json::Value Players;
|
||||||
|
Players["online"] = NumPlayers;
|
||||||
|
Players["max"] = MaxPlayers;
|
||||||
|
// TODO: Add "sample"
|
||||||
|
|
||||||
|
// Description:
|
||||||
|
Json::Value Description;
|
||||||
|
Description["text"] = ServerDescription.c_str();
|
||||||
|
|
||||||
|
// Create the response:
|
||||||
|
Json::Value ResponseValue;
|
||||||
|
ResponseValue["version"] = Version;
|
||||||
|
ResponseValue["players"] = Players;
|
||||||
|
ResponseValue["description"] = Description;
|
||||||
|
if (!Favicon.empty())
|
||||||
|
{
|
||||||
|
ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialize the response into a packet:
|
||||||
|
Json::FastWriter Writer;
|
||||||
|
cPacketizer Pkt(*this, 0x00); // Response packet
|
||||||
|
Pkt.WriteString(Writer.write(ResponseValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
41
src/Protocol/Protocol_1_11.h
Normal file
41
src/Protocol/Protocol_1_11.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
// Protocol_1_11.h
|
||||||
|
|
||||||
|
/*
|
||||||
|
Declares 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Protocol_1_10.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cProtocol_1_11_0 :
|
||||||
|
public cProtocol_1_10_0
|
||||||
|
{
|
||||||
|
typedef cProtocol_1_10_0 super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cProtocol_1_11_0(cClientHandle * a_Client, const AString &a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
|
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;
|
||||||
|
virtual void SendSpawnMob (const cMonster & a_Mob) override;
|
||||||
|
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void HandlePacketBlockPlace (cByteBuffer & a_ByteBuffer) override;
|
||||||
|
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
// Protocol18x.h
|
// Protocol_1_8.h
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Declares the 1.8.x protocol classes:
|
Declares the 1.8 protocol classes:
|
||||||
- cProtocol180
|
- cProtocol_1_8_0
|
||||||
- release 1.8.0 protocol (#47)
|
- release 1.8 protocol (#47)
|
||||||
(others may be added later in the future for the 1.8 release series)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -47,14 +46,14 @@ namespace Json
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cProtocol180 :
|
class cProtocol_1_8_0 :
|
||||||
public cProtocol
|
public cProtocol
|
||||||
{
|
{
|
||||||
typedef cProtocol super;
|
typedef cProtocol super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
cProtocol180(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_8_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
/** Called when client sends some data: */
|
/** Called when client sends some data: */
|
||||||
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
|
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
|
||||||
@ -70,7 +69,7 @@ public:
|
|||||||
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
||||||
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
||||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
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 SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
|
||||||
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
||||||
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
||||||
virtual void SendDisconnect (const AString & a_Reason) override;
|
virtual void SendDisconnect (const AString & a_Reason) override;
|
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,16 @@
|
|||||||
|
|
||||||
// Protocol19x.h
|
// Protocol_1_9.h
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Declares the 1.9.x protocol classes:
|
Declares the 1.9 protocol classes:
|
||||||
- cProtocol190
|
- cProtocol_1_9_0
|
||||||
- release 1.9.0 protocol (#107)
|
- release 1.9 protocol (#107)
|
||||||
- cProtocol191
|
- cProtocol_1_9_1
|
||||||
- release 1.9.1 protocol (#108)
|
- release 1.9.1 protocol (#108)
|
||||||
- cProtocol192
|
- cProtocol_1_9_2
|
||||||
- release 1.9.2 protocol (#109)
|
- release 1.9.2 protocol (#109)
|
||||||
- cProtocol194
|
- cProtocol_1_9_4
|
||||||
- release 1.9.4 protocol (#110)
|
- release 1.9.4 protocol (#110)
|
||||||
(others may be added later in the future for the 1.9 release series)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -53,14 +52,14 @@ namespace Json
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cProtocol190 :
|
class cProtocol_1_9_0 :
|
||||||
public cProtocol
|
public cProtocol
|
||||||
{
|
{
|
||||||
typedef cProtocol super;
|
typedef cProtocol super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
cProtocol190(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_9_0(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
/** Called when client sends some data: */
|
/** Called when client sends some data: */
|
||||||
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
|
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
|
||||||
@ -76,7 +75,7 @@ public:
|
|||||||
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
virtual void SendChat (const cCompositeChat & a_Message, eChatType a_Type, bool a_ShouldUseChatPrefixes) override;
|
||||||
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
virtual void SendChatRaw (const AString & a_MessageRaw, eChatType a_Type) override;
|
||||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
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 SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
|
||||||
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
virtual void SendDestroyEntity (const cEntity & a_Entity) override;
|
||||||
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
virtual void SendDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle) override;
|
||||||
virtual void SendDisconnect (const AString & a_Reason) override;
|
virtual void SendDisconnect (const AString & a_Reason) override;
|
||||||
@ -189,51 +188,50 @@ protected:
|
|||||||
void AddReceivedData(const char * a_Data, size_t a_Size);
|
void AddReceivedData(const char * a_Data, size_t a_Size);
|
||||||
|
|
||||||
/** Reads and handles the packet. The packet length and type have already been read.
|
/** 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
|
Returns true if the packet was understood, false if it was an unknown packet. */
|
||||||
*/
|
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType);
|
||||||
bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType);
|
|
||||||
|
|
||||||
// Packet handlers while in the Status state (m_State == 1):
|
// Packet handlers while in the Status state (m_State == 1):
|
||||||
virtual void HandlePacketStatusPing(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketStatusPing(cByteBuffer & a_ByteBuffer);
|
||||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer);
|
||||||
|
|
||||||
// Packet handlers while in the Login state (m_State == 2):
|
// Packet handlers while in the Login state (m_State == 2):
|
||||||
void HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketLoginStart(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketLoginStart(cByteBuffer & a_ByteBuffer);
|
||||||
|
|
||||||
// Packet handlers while in the Game state (m_State == 3):
|
// Packet handlers while in the Game state (m_State == 3):
|
||||||
void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketBlockPlace (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketBlockPlace (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketBoatSteer (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketBoatSteer (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketChatMessage (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketChatMessage (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketClientSettings (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketClientSettings (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketClientStatus (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketClientStatus (cByteBuffer & a_ByteBuffer);
|
||||||
void HandleConfirmTeleport (cByteBuffer & a_ByteBuffer);
|
virtual void HandleConfirmTeleport (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketCreativeInventoryAction(cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketEntityAction (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketEntityAction (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketKeepAlive (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketKeepAlive (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPlayer (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPlayer (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPlayerAbilities (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPlayerAbilities (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPlayerLook (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPlayerLook (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPlayerPos (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPlayerPos (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPlayerPosLook (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPlayerPosLook (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketPluginMessage (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketPluginMessage (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketSlotSelect (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketSlotSelect (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketSteerVehicle (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketSteerVehicle (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketSpectate (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketSpectate (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketTabComplete (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketUpdateSign (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketUseEntity (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketUseItem (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketUseItem (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketEnchantItem (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketEnchantItem (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketVehicleMove (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketVehicleMove (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
|
||||||
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);
|
virtual void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);
|
||||||
|
|
||||||
/** Parses Vanilla plugin messages into specific ClientHandle calls.
|
/** Parses Vanilla plugin messages into specific ClientHandle calls.
|
||||||
The message payload is still in the bytebuffer, the handler reads it specifically for each handled channel */
|
The message payload is still in the bytebuffer, the handler reads it specifically for each handled channel */
|
||||||
void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel);
|
virtual void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel);
|
||||||
|
|
||||||
|
|
||||||
/** Sends the data to the client, encrypting them if needed. */
|
/** Sends the data to the client, encrypting them if needed. */
|
||||||
@ -297,15 +295,15 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
/** The version 108 protocol, used by 1.9.1. Uses an int rather than a byte for dimension in join game. */
|
/** The version 108 protocol, used by 1.9.1. Uses an int rather than a byte for dimension in join game. */
|
||||||
class cProtocol191 :
|
class cProtocol_1_9_1 :
|
||||||
public cProtocol190
|
public cProtocol_1_9_0
|
||||||
{
|
{
|
||||||
typedef cProtocol190 super;
|
typedef cProtocol_1_9_0 super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cProtocol191(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_9_1(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
// cProtocol190 overrides:
|
// cProtocol_1_9_0 overrides:
|
||||||
virtual void SendLogin(const cPlayer & a_Player, const cWorld & a_World) override;
|
virtual void SendLogin(const cPlayer & a_Player, const cWorld & a_World) override;
|
||||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||||
|
|
||||||
@ -316,15 +314,15 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/** The version 109 protocol, used by 1.9.2. Same as 1.9.1, except the server list ping version number changed with the protocol number. */
|
/** The version 109 protocol, used by 1.9.2. Same as 1.9.1, except the server list ping version number changed with the protocol number. */
|
||||||
class cProtocol192 :
|
class cProtocol_1_9_2 :
|
||||||
public cProtocol191
|
public cProtocol_1_9_1
|
||||||
{
|
{
|
||||||
typedef cProtocol191 super;
|
typedef cProtocol_1_9_1 super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cProtocol192(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_9_2(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
// cProtocol190 overrides:
|
// cProtocol_1_9_1 overrides:
|
||||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
@ -334,16 +332,16 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
/** The version 110 protocol, used by 1.9.3 and 1.9.4. */
|
/** The version 110 protocol, used by 1.9.3 and 1.9.4. */
|
||||||
class cProtocol194 :
|
class cProtocol_1_9_4 :
|
||||||
public cProtocol192
|
public cProtocol_1_9_2
|
||||||
{
|
{
|
||||||
typedef cProtocol192 super;
|
typedef cProtocol_1_9_2 super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cProtocol194(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
|
||||||
|
|
||||||
// cProtocol190 overrides:
|
// cProtocol_1_9_2 overrides:
|
||||||
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player) override;
|
virtual void SendCollectEntity (const cEntity & a_Entity, const cPlayer & a_Player, int a_Count) override;
|
||||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
||||||
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
|
virtual void SendEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration) override;
|
||||||
virtual void SendEntityProperties(const cEntity & a_Entity) override;
|
virtual void SendEntityProperties(const cEntity & a_Entity) override;
|
@ -2446,9 +2446,9 @@ void cWorld::BroadcastChat(const cCompositeChat & a_Message, const cClientHandle
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, const cClientHandle * a_Exclude)
|
void cWorld::BroadcastCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude)
|
||||||
{
|
{
|
||||||
m_ChunkMap->BroadcastCollectEntity(a_Entity, a_Player, a_Exclude);
|
m_ChunkMap->BroadcastCollectEntity(a_Entity, a_Player, a_Count, a_Exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public:
|
|||||||
void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastChat (const cCompositeChat & a_Message, const cClientHandle * a_Exclude = nullptr);
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastCollectEntity (const cEntity & a_Pickup, const cPlayer & a_Player, int a_Count, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
|
||||||
void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
void BroadcastDetachEntity (const cEntity & a_Entity, const cEntity & a_PreviousVehicle);
|
||||||
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
void BroadcastEntityEffect (const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration, const cClientHandle * a_Exclude = nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user