summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:45:45 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:50:18 +0100
commitca6ef58b1ee8521e4b940ee4883dee714960e413 (patch)
tree8532add455224b07c07a759e3d906f50c0695888 /src/Protocol
parentMerge pull request #2972 from marvinkopf/PlayerAutoComplete (diff)
downloadcuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/Authenticator.cpp2
-rw-r--r--src/Protocol/Authenticator.h6
-rw-r--r--src/Protocol/ChunkDataSerializer.cpp20
-rw-r--r--src/Protocol/ChunkDataSerializer.h10
-rw-r--r--src/Protocol/MojangAPI.h54
-rw-r--r--src/Protocol/Protocol.h8
-rw-r--r--src/Protocol/Protocol17x.cpp222
-rw-r--r--src/Protocol/Protocol17x.h36
-rw-r--r--src/Protocol/Protocol18x.cpp160
-rw-r--r--src/Protocol/Protocol18x.h34
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp2
-rw-r--r--src/Protocol/ProtocolRecognizer.h14
12 files changed, 284 insertions, 284 deletions
diff --git a/src/Protocol/Authenticator.cpp b/src/Protocol/Authenticator.cpp
index 304486935..12e963143 100644
--- a/src/Protocol/Authenticator.cpp
+++ b/src/Protocol/Authenticator.cpp
@@ -194,7 +194,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
a_UserName = root.get("name", "Unknown").asString();
a_UUID = cMojangAPI::MakeUUIDShort(root.get("id", "").asString());
a_Properties = root["properties"];
-
+
// Store the player's profile in the MojangAPI caches:
cRoot::Get()->GetMojangAPI().AddPlayerProfile(a_UserName, a_UUID, a_Properties);
diff --git a/src/Protocol/Authenticator.h b/src/Protocol/Authenticator.h
index 845277569..a8c551fc7 100644
--- a/src/Protocol/Authenticator.h
+++ b/src/Protocol/Authenticator.h
@@ -50,7 +50,7 @@ public:
/** Stops the authenticator thread. The thread may be started and stopped repeatedly */
void Stop(void);
-
+
private:
class cUser
@@ -76,13 +76,13 @@ private:
/** The server that is to be contacted for auth / UUID conversions */
AString m_Server;
-
+
/** The URL to use for auth, without server part.
%USERNAME% will be replaced with actual user name.
%SERVERID% will be replaced with server's ID.
For example "/session/minecraft/hasJoined?username=%USERNAME%&serverId=%SERVERID%". */
AString m_Address;
-
+
AString m_PropertiesAddress;
bool m_ShouldAuthenticate;
diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp
index 8c5569cc7..848a6f597 100644
--- a/src/Protocol/ChunkDataSerializer.cpp
+++ b/src/Protocol/ChunkDataSerializer.cpp
@@ -39,14 +39,14 @@ const AString & cChunkDataSerializer::Serialize(int a_Version, int a_ChunkX, int
{
return itr->second;
}
-
+
AString data;
switch (a_Version)
{
case RELEASE_1_3_2: Serialize39(data); break;
case RELEASE_1_8_0: Serialize47(data, a_ChunkX, a_ChunkZ); break;
// TODO: Other protocol versions may serialize the data differently; implement here
-
+
default:
{
LOGERROR("cChunkDataSerializer::Serialize(): Unknown version: %d", a_Version);
@@ -74,7 +74,7 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
const int DataSize = BiomeOffset + BiomeDataSize;
-
+
// Temporary buffer for the composed data:
char AllData [DataSize];
@@ -91,29 +91,29 @@ void cChunkDataSerializer::Serialize39(AString & a_Data)
char CompressedBlockData[CompressedMaxSize];
uLongf CompressedSize = compressBound(DataSize);
-
+
// Run-time check that our compile-time guess about CompressedMaxSize was enough:
ASSERT(CompressedSize <= CompressedMaxSize);
-
+
compress2(reinterpret_cast<Bytef*>(CompressedBlockData), &CompressedSize, reinterpret_cast<const Bytef*>(AllData), sizeof(AllData), Z_DEFAULT_COMPRESSION);
// Now put all those data into a_Data:
-
+
// "Ground-up continuous", or rather, "biome data present" flag:
a_Data.push_back('\x01');
-
+
// Two bitmaps; we're aways sending the full chunk with no additional data, so the bitmaps are 0xffff and 0, respectively
// Also, no endian flipping is needed because of the const values
unsigned short BitMap1 = 0xffff;
unsigned short BitMap2 = 0;
a_Data.append(reinterpret_cast<const char *>(&BitMap1), sizeof(short));
a_Data.append(reinterpret_cast<const char *>(&BitMap2), sizeof(short));
-
+
UInt32 CompressedSizeBE = htonl(static_cast<UInt32>(CompressedSize));
a_Data.append(reinterpret_cast<const char *>(&CompressedSizeBE), sizeof(CompressedSizeBE));
-
+
// Unlike 29, 39 doesn't have the "unused" int
-
+
a_Data.append(CompressedBlockData, CompressedSize);
}
diff --git a/src/Protocol/ChunkDataSerializer.h b/src/Protocol/ChunkDataSerializer.h
index 6acc1544b..823a93f15 100644
--- a/src/Protocol/ChunkDataSerializer.h
+++ b/src/Protocol/ChunkDataSerializer.h
@@ -17,21 +17,21 @@ protected:
const cChunkDef::BlockNibbles & m_BlockLight;
const cChunkDef::BlockNibbles & m_BlockSkyLight;
const unsigned char * m_BiomeData;
-
+
typedef std::map<int, AString> Serializations;
-
+
Serializations m_Serializations;
-
+
void Serialize39(AString & a_Data); // Release 1.3.1 to 1.7.10
void Serialize47(AString & a_Data, int a_ChunkX, int a_ChunkZ); // Release 1.8
-
+
public:
enum
{
RELEASE_1_3_2 = 39,
RELEASE_1_8_0 = 47,
} ;
-
+
cChunkDataSerializer(
const cChunkDef::BlockTypes & a_BlockTypes,
const cChunkDef::BlockNibbles & a_BlockMetas,
diff --git a/src/Protocol/MojangAPI.h b/src/Protocol/MojangAPI.h
index bea950740..65eb1b102 100644
--- a/src/Protocol/MojangAPI.h
+++ b/src/Protocol/MojangAPI.h
@@ -32,24 +32,24 @@ class cMojangAPI
{
public:
// tolua_end
-
+
cMojangAPI(void);
~cMojangAPI();
-
+
/** Initializes the API; reads the settings from the specified ini file.
Loads cached results from disk. */
void Start(cSettingsRepositoryInterface & a_Settings, bool a_ShouldAuth);
-
+
/** Connects to the specified server using SSL, sends the given request and receives the response.
Checks Mojang certificates using the hard-coded Starfield root CA certificate.
Returns true if all was successful, false on failure. */
static bool SecureRequest(const AString & a_ServerName, const AString & a_Request, AString & a_Response);
-
+
/** Normalizes the given UUID to its short form (32 bytes, no dashes, lowercase).
Logs a warning and returns empty string if not a UUID.
Note: only checks the string's length, not the actual content. */
static AString MakeUUIDShort(const AString & a_UUID);
-
+
/** Normalizes the given UUID to its dashed form (36 bytes, 4 dashes, lowercase).
Logs a warning and returns empty string if not a UUID.
Note: only checks the string's length, not the actual content. */
@@ -62,7 +62,7 @@ public:
operation, do not use this in world-tick thread!
If you have multiple names to resolve, use the GetUUIDsFromPlayerNames() function, it uses a single request for multiple names. */
AString GetUUIDFromPlayerName(const AString & a_PlayerName, bool a_UseOnlyCached = false);
-
+
/** Converts a UUID into a playername.
The returned playername will be empty on error.
Both short and dashed UUID formats are accepted.
@@ -71,7 +71,7 @@ public:
If a_UseOnlyCached is false and the name is not found in the cache, it is looked up online, which is a blocking
operation, do not use this in world-tick thread! */
AString GetPlayerNameFromUUID(const AString & a_UUID, bool a_UseOnlyCached = false);
-
+
/** Converts the player names into UUIDs.
a_PlayerName[idx] will be converted to UUID and returned as idx-th value
The UUID will be empty on error.
@@ -79,12 +79,12 @@ public:
If a_UseOnlyCached is false, the names not found in the cache are looked up online, which is a blocking
operation, do not use this in world-tick thread! */
AStringVector GetUUIDsFromPlayerNames(const AStringVector & a_PlayerName, bool a_UseOnlyCached = false);
-
+
/** Called by the Authenticator to add a PlayerName -> UUID mapping that it has received from
authenticating a user. This adds the cache item and "refreshes" it if existing, adjusting its datetime
stamp to now. */
void AddPlayerNameToUUIDMapping(const AString & a_PlayerName, const AString & a_UUID);
-
+
/** Called by the Authenticator to add a profile that it has received from authenticating a user. Adds
the profile to the respective mapping caches and updtes their datetime stamp to now. */
void AddPlayerProfile(const AString & a_PlayerName, const AString & a_UUID, const Json::Value & a_Properties);
@@ -105,7 +105,7 @@ protected:
AString m_Textures; // The Textures field of the profile properties
AString m_TexturesSignature; // The signature of the Textures field of the profile properties
Int64 m_DateTime; // UNIXtime of the profile lookup
-
+
/** Default constructor for the container's sake. */
sProfile(void) :
m_PlayerName(),
@@ -115,7 +115,7 @@ protected:
m_DateTime(time(nullptr))
{
}
-
+
/** Constructor for the storage creation. */
sProfile(
const AString & a_PlayerName,
@@ -131,7 +131,7 @@ protected:
m_DateTime(a_DateTime)
{
}
-
+
/** Constructor that parses the values from the Json profile. */
sProfile(
const AString & a_PlayerName,
@@ -142,37 +142,37 @@ protected:
};
typedef std::map<AString, sProfile> cProfileMap;
-
+
/** The server to connect to when converting player names to UUIDs. For example "api.mojang.com". */
AString m_NameToUUIDServer;
-
+
/** The URL to use for converting player names to UUIDs, without server part.
For example "/profiles/page/1". */
AString m_NameToUUIDAddress;
-
+
/** The server to connect to when converting UUID to profile. For example "sessionserver.mojang.com". */
AString m_UUIDToProfileServer;
-
+
/** The URL to use for converting UUID to profile, without the server part.
Will replace %UUID% with the actual UUID. For example "session/minecraft/profile/%UUID%?unsigned=false". */
AString m_UUIDToProfileAddress;
-
+
/** Cache for the Name-to-UUID lookups. The map key is lowercased PlayerName. Protected by m_CSNameToUUID. */
cProfileMap m_NameToUUID;
-
+
/** Protects m_NameToUUID against simultaneous multi-threaded access. */
cCriticalSection m_CSNameToUUID;
-
+
/** Cache for the Name-to-UUID lookups. The map key is lowercased short UUID. Protected by m_CSUUIDToName. */
cProfileMap m_UUIDToName;
-
+
/** Protects m_UUIDToName against simultaneous multi-threaded access. */
cCriticalSection m_CSUUIDToName;
-
+
/** Cache for the UUID-to-profile lookups. The map key is lowercased short UUID.
Protected by m_CSUUIDToProfile. */
cProfileMap m_UUIDToProfile;
-
+
/** Protects m_UUIDToProfile against simultaneous multi-threaded access. */
cCriticalSection m_CSUUIDToProfile;
@@ -184,14 +184,14 @@ protected:
/** The thread that periodically updates the stale data in the DB from the Mojang servers. */
SharedPtr<cUpdateThread> m_UpdateThread;
-
-
+
+
/** Loads the caches from a disk storage. */
void LoadCachesFromDisk(void);
-
+
/** Saves the caches to a disk storage. */
void SaveCachesToDisk(void);
-
+
/** Makes sure all specified names are in the m_PlayerNameToUUID cache. Downloads any missing ones from Mojang API servers.
Names that are not valid are not added into the cache.
ASSUMEs that a_PlayerNames contains lowercased player names. */
@@ -202,7 +202,7 @@ protected:
ASSUMEs that a_PlayerNames contans lowercased player names.
For performance reasons takes a non-const reference and modifies the list given to it, until empty. */
void QueryNamesToUUIDs(AStringVector & a_PlayerNames);
-
+
/** Makes sure the specified UUID is in the m_UUIDToProfile cache. If missing, downloads it from Mojang API servers.
UUIDs that are not valid will not be added into the cache.
ASSUMEs that a_UUID is a lowercased short UUID. */
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index af0485a78..62faf0b28 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -59,10 +59,10 @@ public:
}
virtual ~cProtocol() {}
-
+
/** Called when client sends some data */
virtual void DataReceived(const char * a_Data, size_t a_Size) = 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;
@@ -160,10 +160,10 @@ protected:
/** Buffer for composing the outgoing packets, through cPacketizer */
cByteBuffer m_OutPacketBuffer;
-
+
/** Buffer for composing packet length (so that each cPacketizer instance doesn't allocate a new cPacketBuffer) */
cByteBuffer m_OutPacketLenBuffer;
-
+
/** 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/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 1c8c81bbd..69b87e4d1 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -121,7 +121,7 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd
m_Client->SetUUID(cMojangAPI::MakeUUIDShort(Params[2]));
m_Client->SetProperties(Params[3]);
}
-
+
// Create the comm log file, if so requested:
if (g_ShouldLogCommIn || g_ShouldLogCommOut)
{
@@ -163,7 +163,7 @@ void cProtocol172::DataReceived(const char * a_Data, size_t a_Size)
void cProtocol172::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1b); // Attach Entity packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt32((a_Vehicle != nullptr) ? a_Vehicle->GetUniqueID() : 0);
@@ -177,7 +177,7 @@ void cProtocol172::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_
void cProtocol172::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x24); // Block Action packet
Pkt.WriteBEInt32(a_BlockX);
Pkt.WriteBEInt16(static_cast<Int16>(a_BlockY));
@@ -194,7 +194,7 @@ void cProtocol172::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, cha
void cProtocol172::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x25); // Block Break Animation packet
Pkt.WriteVarInt32(a_EntityID);
Pkt.WriteBEInt32(a_BlockX);
@@ -211,7 +211,7 @@ void cProtocol172::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_BlockY >= 0) && (a_BlockY < 256));
-
+
cPacketizer Pkt(*this, 0x23); // Block Change packet
Pkt.WriteBEInt32(a_BlockX);
Pkt.WriteBEUInt8(static_cast<UInt8>(a_BlockY));
@@ -227,7 +227,7 @@ void cProtocol172::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BLO
void cProtocol172::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x22); // Multi Block Change packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
@@ -283,11 +283,11 @@ void cProtocol172::SendChat(const cCompositeChat & a_Message, eChatType a_Type,
void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer)
{
ASSERT(m_State == 3); // In game mode?
-
+
// Serialize first, before creating the Packetizer (the packetizer locks a CS)
// This contains the flags and bitmasks, too
const AString & ChunkData = a_Serializer.Serialize(cChunkDataSerializer::RELEASE_1_3_2, a_ChunkX, a_ChunkZ);
-
+
cPacketizer Pkt(*this, 0x21); // Chunk Data packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
@@ -301,7 +301,7 @@ void cProtocol172::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt32(a_Player.GetUniqueID());
@@ -314,7 +314,7 @@ void cProtocol172::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a
void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x13); // Destroy Entities packet
Pkt.WriteBEUInt8(1);
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
@@ -352,7 +352,7 @@ void cProtocol172::SendDisconnect(const AString & a_Reason)
void cProtocol172::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x36); // Sign Editor Open packet
Pkt.WriteBEInt32(a_BlockX);
Pkt.WriteBEInt32(a_BlockY);
@@ -368,7 +368,7 @@ void cProtocol172::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
ASSERT(m_State == 3); // In game mode?
ASSERT((a_EffectID >= 0) && (a_EffectID < 256));
ASSERT((a_Amplifier >= 0) && (a_Amplifier < 256));
-
+
cPacketizer Pkt(*this, 0x1D); // Entity Effect packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<Byte>(a_EffectID));
@@ -383,7 +383,7 @@ void cProtocol172::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
void cProtocol172::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x04); // Entity Equipment packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt16(a_SlotNum);
@@ -397,7 +397,7 @@ void cProtocol172::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
void cProtocol172::SendEntityHeadLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x19); // Entity Head Look packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
@@ -410,7 +410,7 @@ void cProtocol172::SendEntityHeadLook(const cEntity & a_Entity)
void cProtocol172::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x16); // Entity Look packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetYaw());
@@ -424,7 +424,7 @@ void cProtocol172::SendEntityLook(const cEntity & a_Entity)
void cProtocol172::SendEntityMetadata(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
WriteEntityMetadata(Pkt, a_Entity);
@@ -438,7 +438,7 @@ void cProtocol172::SendEntityMetadata(const cEntity & a_Entity)
void cProtocol172::SendEntityProperties(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x20); // Entity Properties packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
WriteEntityProperties(Pkt, a_Entity);
@@ -451,7 +451,7 @@ void cProtocol172::SendEntityProperties(const cEntity & a_Entity)
void cProtocol172::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x15); // Entity Relative Move packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_RelX);
@@ -466,7 +466,7 @@ void cProtocol172::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char
void cProtocol172::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x17); // Entity Look And Relative Move packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_RelX);
@@ -483,7 +483,7 @@ void cProtocol172::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX,
void cProtocol172::SendEntityStatus(const cEntity & a_Entity, char a_Status)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1a); // Entity Status packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Status);
@@ -496,7 +496,7 @@ void cProtocol172::SendEntityStatus(const cEntity & a_Entity, char a_Status)
void cProtocol172::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
@@ -512,7 +512,7 @@ void cProtocol172::SendEntityVelocity(const cEntity & a_Entity)
void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x27); // Explosion packet
Pkt.WriteBEFloat(static_cast<float>(a_BlockX));
Pkt.WriteBEFloat(static_cast<float>(a_BlockY));
@@ -537,7 +537,7 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
void cProtocol172::SendGameMode(eGameMode a_GameMode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
Pkt.WriteBEUInt8(3); // Reason: Change game mode
Pkt.WriteBEFloat(static_cast<float>(a_GameMode)); // The protocol really represents the value with a float!
@@ -550,7 +550,7 @@ void cProtocol172::SendGameMode(eGameMode a_GameMode)
void cProtocol172::SendHealth(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x06); // Update Health packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(static_cast<float>(Player->GetHealth()));
@@ -574,7 +574,7 @@ void cProtocol172::SendHideTitle(void)
void cProtocol172::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2f); // Set Slot packet
Pkt.WriteBEInt8(a_WindowID);
Pkt.WriteBEInt16(a_SlotNum);
@@ -593,7 +593,7 @@ void cProtocol172::SendKeepAlive(UInt32 a_PingID)
LOGWARNING("Trying to send a KeepAlive packet to a player who's not yet fully logged in (%d). The protocol class prevented the packet.", m_State);
return;
}
-
+
cPacketizer Pkt(*this, 0x00); // Keep Alive packet
Pkt.WriteBEUInt32(a_PingID);
}
@@ -616,7 +616,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
Pkt.WriteString("default"); // Level type - wtf?
}
m_LastSentDimension = a_World.GetDimension();
-
+
// Send the spawn position:
{
cPacketizer Pkt(*this, 0x05); // Spawn Position packet
@@ -624,7 +624,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
Pkt.WriteBEInt32(static_cast<int>(a_World.GetSpawnY()));
Pkt.WriteBEInt32(static_cast<int>(a_World.GetSpawnZ()));
}
-
+
// Send player abilities:
SendPlayerAbilities();
}
@@ -635,7 +635,7 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
void cProtocol172::SendLoginSuccess(void)
{
ASSERT(m_State == 2); // State: login?
-
+
{
cPacketizer Pkt(*this, 0x02); // Login success packet
Pkt.WriteString(cMojangAPI::MakeUUIDDashed(m_Client->GetUUID()));
@@ -652,7 +652,7 @@ void cProtocol172::SendLoginSuccess(void)
void cProtocol172::SendPaintingSpawn(const cPainting & a_Painting)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x10); // Spawn Painting packet
Pkt.WriteVarInt32(a_Painting.GetUniqueID());
Pkt.WriteString(a_Painting.GetName().c_str());
@@ -724,7 +724,7 @@ void cProtocol172::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataS
void cProtocol172::SendPickupSpawn(const cPickup & a_Pickup)
{
ASSERT(m_State == 3); // In game mode?
-
+
{
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
Pkt.WriteVarInt32(a_Pickup.GetUniqueID());
@@ -752,7 +752,7 @@ void cProtocol172::SendPickupSpawn(const cPickup & a_Pickup)
void cProtocol172::SendPlayerAbilities(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x39); // Player Abilities packet
Byte Flags = 0;
cPlayer * Player = m_Client->GetPlayer();
@@ -781,7 +781,7 @@ void cProtocol172::SendPlayerAbilities(void)
void cProtocol172::SendEntityAnimation(const cEntity & a_Entity, char a_Animation)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0b); // Animation packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Animation);
@@ -794,7 +794,7 @@ void cProtocol172::SendEntityAnimation(const cEntity & a_Entity, char a_Animatio
void cProtocol172::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2A);
Pkt.WriteString(a_ParticleName);
Pkt.WriteBEFloat(a_SrcX);
@@ -883,7 +883,7 @@ void cProtocol172::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con
void cProtocol172::SendPlayerMaxSpeed(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x20); // Entity Properties
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEUInt32(Player->GetUniqueID());
@@ -912,15 +912,15 @@ void cProtocol172::SendPlayerMaxSpeed(void)
void cProtocol172::SendPlayerMoveLook(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEDouble(Player->GetPosX());
-
+
// Protocol docs say this is PosY, but #323 says this is eye-pos
// Moreover, the "+ 0.001" is there because otherwise the player falls through the block they were standing on.
Pkt.WriteBEDouble(Player->GetStance() + 0.001);
-
+
Pkt.WriteBEDouble(Player->GetPosZ());
Pkt.WriteBEFloat(static_cast<float>(Player->GetYaw()));
Pkt.WriteBEFloat(static_cast<float>(Player->GetPitch()));
@@ -944,7 +944,7 @@ void cProtocol172::SendPlayerPosition(void)
void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
-
+
// Called to spawn another player for the client
cPacketizer Pkt(*this, 0x0c); // Spawn Player packet
Pkt.WriteVarInt32(a_Player.GetUniqueID());
@@ -977,7 +977,7 @@ void cProtocol172::SendPluginMessage(const AString & a_Channel, const AString &
{
ASSERT(m_State == 3); // In game mode?
ASSERT(a_Message.size() <= std::numeric_limits<UInt16>::max());
-
+
cPacketizer Pkt(*this, 0x3f);
Pkt.WriteString(a_Channel);
Pkt.WriteBEUInt16(static_cast<UInt16>(a_Message.size()));
@@ -992,7 +992,7 @@ void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effect
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_EffectID >= 0) && (a_EffectID < 256));
-
+
cPacketizer Pkt(*this, 0x1e);
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<Byte>(a_EffectID));
@@ -1035,7 +1035,7 @@ void cProtocol172::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens
void cProtocol172::SendExperience (void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(Player->GetXpPercentage());
@@ -1051,7 +1051,7 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb)
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_ExpOrb.GetReward() >= 0) && (a_ExpOrb.GetReward() < SHRT_MAX));
-
+
cPacketizer Pkt(*this, 0x11);
Pkt.WriteVarInt32(a_ExpOrb.GetUniqueID());
Pkt.WriteFPInt(a_ExpOrb.GetPosX());
@@ -1067,7 +1067,7 @@ void cProtocol172::SendExperienceOrb(const cExpOrb & a_ExpOrb)
void cProtocol172::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3b);
Pkt.WriteString(a_Name);
Pkt.WriteString(a_DisplayName);
@@ -1081,7 +1081,7 @@ void cProtocol172::SendScoreboardObjective(const AString & a_Name, const AString
void cProtocol172::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3c);
Pkt.WriteString(a_Player);
Pkt.WriteBEUInt8(a_Mode);
@@ -1100,7 +1100,7 @@ void cProtocol172::SendScoreUpdate(const AString & a_Objective, const AString &
void cProtocol172::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3d);
Pkt.WriteBEUInt8(static_cast<Byte>(a_Display));
Pkt.WriteString(a_Objective);
@@ -1167,7 +1167,7 @@ void cProtocol172::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_SrcY >= 0) && (a_SrcY < 256));
-
+
cPacketizer Pkt(*this, 0x28); // Effect packet
Pkt.WriteBEInt32(static_cast<int>(a_EffectID));
Pkt.WriteBEInt32(a_SrcX);
@@ -1184,7 +1184,7 @@ void cProtocol172::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX
void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID());
Pkt.WriteBEUInt8(70); // Falling block
@@ -1206,7 +1206,7 @@ void cProtocol172::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
void cProtocol172::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.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType()));
@@ -1230,7 +1230,7 @@ void cProtocol172::SendSpawnMob(const cMonster & a_Mob)
void cProtocol172::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_ObjectType);
@@ -1255,7 +1255,7 @@ void cProtocol172::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
Pkt.WriteBEInt8(a_VehicleType);
@@ -1280,7 +1280,7 @@ void cProtocol172::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
void cProtocol172::SendStatistics(const cStatManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x37);
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
@@ -1302,7 +1302,7 @@ void cProtocol172::SendStatistics(const cStatManager & a_Manager)
void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size()));
@@ -1319,7 +1319,7 @@ void cProtocol172::SendTabCompletionResults(const AStringVector & a_Results)
void cProtocol172::SendTeleportEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x18);
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteFPInt(a_Entity.GetPosX());
@@ -1336,7 +1336,7 @@ void cProtocol172::SendTeleportEntity(const cEntity & a_Entity)
void cProtocol172::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2c); // Spawn Global Entity packet
Pkt.WriteVarInt32(0); // EntityID = 0, always
Pkt.WriteBEUInt8(1); // Type = Thunderbolt
@@ -1366,7 +1366,7 @@ void cProtocol172::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do
// When writing a "-" before the number the client ignores it but it will stop the client-side time expiration.
a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
}
-
+
cPacketizer Pkt(*this, 0x03);
Pkt.WriteBEInt64(a_WorldAge);
Pkt.WriteBEInt64(a_TimeOfDay);
@@ -1379,7 +1379,7 @@ void cProtocol172::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do
void cProtocol172::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x21); // Chunk Data packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
@@ -1395,7 +1395,7 @@ void cProtocol172::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
void cProtocol172::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x35); // Update tile entity packet
Pkt.WriteBEInt32(a_BlockEntity.GetPosX());
Pkt.WriteBEInt16(static_cast<short>(a_BlockEntity.GetPosY()));
@@ -1424,7 +1424,7 @@ void cProtocol172::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height));
-
+
cPacketizer Pkt(*this, 0x33);
Pkt.WriteBEInt32(a_BlockX);
Pkt.WriteBEInt16(static_cast<Int16>(a_BlockY));
@@ -1444,7 +1444,7 @@ void cProtocol172::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
{
ASSERT(m_State == 3); // In game mode?
ASSERT((a_BlockY >= 0) && (a_BlockY < cChunkDef::Height));
-
+
cPacketizer Pkt(*this, 0x0a);
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt32(a_BlockX);
@@ -1459,7 +1459,7 @@ void cProtocol172::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
void cProtocol172::SendWeather(eWeather a_Weather)
{
ASSERT(m_State == 3); // In game mode?
-
+
{
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
Pkt.WriteBEUInt8((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
@@ -1476,7 +1476,7 @@ void cProtocol172::SendWeather(eWeather a_Weather)
void cProtocol172::SendWholeInventory(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x30); // Window Items packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(static_cast<short>(a_Window.GetNumSlots()));
@@ -1495,7 +1495,7 @@ void cProtocol172::SendWholeInventory(const cWindow & a_Window)
void cProtocol172::SendWindowClose(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2e);
Pkt.WriteBEInt8(a_Window.GetWindowID());
}
@@ -1507,13 +1507,13 @@ void cProtocol172::SendWindowClose(const cWindow & a_Window)
void cProtocol172::SendWindowOpen(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
-
+
if (a_Window.GetWindowType() < 0)
{
// Do not send this packet for player inventory windows
return;
}
-
+
cPacketizer Pkt(*this, 0x2d);
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt8(static_cast<char>(a_Window.GetWindowType()));
@@ -1533,7 +1533,7 @@ void cProtocol172::SendWindowOpen(const cWindow & a_Window)
void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x31); // Window Property packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(a_Property);
@@ -1607,7 +1607,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
// Write one NUL extra, so that we can detect over-reads
bb.Write("\0", 1);
-
+
// Log the packet info into the comm log file:
if (g_ShouldLogCommIn)
{
@@ -1628,7 +1628,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
{
// Unknown packet, already been reported, but without the length. Log the length here:
LOGWARNING("Unhandled packet: type 0x%x, state %d, length %u", PacketType, m_State, PacketLen);
-
+
#ifdef _DEBUG
// Dump the packet contents into the log:
bb.ResetRead();
@@ -1639,13 +1639,13 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
CreateHexDump(Out, Packet.data(), Packet.size(), 24);
LOGD("Packet contents:\n%s", Out.c_str());
#endif // _DEBUG
-
+
// Put a message in the comm log:
if (g_ShouldLogCommIn)
{
m_CommLogFile.Printf("^^^^^^ Unhandled packet ^^^^^^\n\n\n");
}
-
+
return;
}
@@ -1705,7 +1705,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
}
break;
}
-
+
case 2:
{
// Login
@@ -1716,7 +1716,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
}
break;
}
-
+
case 3:
{
// Game
@@ -1753,9 +1753,9 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
// Received a packet in an unknown state, report:
LOGWARNING("Received a packet in an unknown protocol state %d. Ignoring further packets.", m_State);
-
+
// 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;
return false;
@@ -1767,7 +1767,7 @@ bool cProtocol172::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
return false;
}
} // switch (m_State)
-
+
// Unknown packet type, report to the ClientHandle:
m_Client->PacketUnknown(a_PacketType);
return false;
@@ -1887,7 +1887,7 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
m_Client->Kick("Hacked client");
return;
}
-
+
// Decrypt the symmetric encryption key using privkey:
Byte DecryptedKey[MAX_ENC_LEN];
res = rsaDecryptor.Decrypt(
@@ -1900,7 +1900,7 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
m_Client->Kick("Hacked client");
return;
}
-
+
StartEncryption(DecryptedKey);
m_Client->HandleLogin(4, m_Client->GetUsername());
}
@@ -1917,13 +1917,13 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
m_Client->Kick("Bad username");
return;
}
-
+
if (!m_Client->HandleHandshake(Username))
{
// The client is not welcome here, they have been sent a Kick packet already
return;
}
-
+
cServer * Server = cRoot::Get()->GetServer();
// If auth is required, then send the encryption request:
if (Server->ShouldAuthenticate())
@@ -1938,7 +1938,7 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
m_Client->SetUsername(Username);
return;
}
-
+
m_Client->HandleLogin(4, Username);
}
@@ -2008,7 +2008,7 @@ void cProtocol172::HandlePacketClientSettings(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, ChatColors);
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Difficulty);
HANDLE_READ(a_ByteBuffer, ReadBool, bool, ShowCape);
-
+
m_Client->SetLocale(Locale);
m_Client->SetViewDistance(ViewDistance);
// TODO: Do anything with the other values.
@@ -2182,14 +2182,14 @@ void cProtocol172::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
);
return;
}
-
+
// If the plugin channel is recognized vanilla, handle it directly:
if (Channel.substr(0, 3) == "MC|")
{
HandleVanillaPluginMessage(a_ByteBuffer, Channel, Length);
return;
}
-
+
// Read the plugin message and relay to clienthandle:
AString Data;
if (!a_ByteBuffer.ReadString(Data, Length))
@@ -2364,7 +2364,7 @@ void cProtocol172::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
}
// TODO: Entity-based commandblock update
-
+
default:
{
m_Client->SendChat(Printf("Failure setting command block command; unhandled mode %d", Mode), mtFailure);
@@ -2392,7 +2392,7 @@ void cProtocol172::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
{
m_Client->SetClientBrand(Brand);
}
-
+
// Send back our brand:
SendPluginMessage("MC|Brand", "Cuberite");
return;
@@ -2420,7 +2420,7 @@ void cProtocol172::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
return;
}
LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str());
-
+
// Read the payload and send it through to the clienthandle:
AString Message;
VERIFY(a_ByteBuffer.ReadString(Message, a_PayloadLength));
@@ -2466,12 +2466,12 @@ void cProtocol172::SendPacket(cPacketizer & a_Packet)
m_OutPacketLenBuffer.ReadAll(DataToSend);
SendData(DataToSend.data(), DataToSend.size());
m_OutPacketLenBuffer.CommitRead();
-
+
// Send the packet data:
m_OutPacketBuffer.ReadAll(DataToSend);
SendData(DataToSend.data(), DataToSend.size());
m_OutPacketBuffer.CommitRead();
-
+
// Log the comm into logfile:
if (g_ShouldLogCommOut)
{
@@ -2498,7 +2498,7 @@ bool cProtocol172::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item)
return true;
}
a_Item.m_ItemType = ItemType;
-
+
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt8, Int8, ItemCount);
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemDamage);
a_Item.m_ItemCount = ItemCount;
@@ -2515,7 +2515,7 @@ bool cProtocol172::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item)
{
return false;
}
-
+
ParseItemMetadata(a_Item, Metadata);
return true;
}
@@ -2535,7 +2535,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
LOGWARNING("Cannot unGZIP item metadata (" SIZE_T_FMT " bytes):\n%s", a_Metadata.size(), HexDump.c_str());
return;
}
-
+
// Parse into NBT:
cParsedNBT NBT(Uncompressed.data(), Uncompressed.size());
if (!NBT.IsValid())
@@ -2545,7 +2545,7 @@ void cProtocol172::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
LOGWARNING("Cannot parse NBT item metadata: (" SIZE_T_FMT " bytes)\n%s", Uncompressed.size(), HexDump.c_str());
return;
}
-
+
// Load enchantments and custom display names from the NBT data:
for (int tag = NBT.GetFirstChild(NBT.GetRoot()); tag >= 0; tag = NBT.GetNextSibling(tag))
{
@@ -2614,7 +2614,7 @@ void cProtocol172::StartEncryption(const Byte * a_Key)
m_Encryptor.Init(a_Key, a_Key);
m_Decryptor.Init(a_Key, a_Key);
m_IsEncrypted = true;
-
+
// Prepare the m_AuthServerID:
cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
@@ -2660,17 +2660,17 @@ void cProtocol172::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
// Fix, to make sure no invalid values are sent.
ItemType = -1;
}
-
+
if (a_Item.IsEmpty())
{
a_Pkt.WriteBEInt16(-1);
return;
}
-
+
a_Pkt.WriteBEInt16(ItemType);
a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage);
-
+
if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR) && !a_Item.m_ItemColor.IsValid())
{
a_Pkt.WriteBEInt16(-1);
@@ -2857,7 +2857,7 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
}
a_Pkt.WriteBEUInt8(0); // Byte(0) + index 0
a_Pkt.WriteBEUInt8(Flags);
-
+
switch (a_Entity.GetEntityType())
{
case cEntity::etPlayer: break; // TODO?
@@ -2884,7 +2884,7 @@ void cProtocol172::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
a_Pkt.WriteBEInt32(1); // Shaking direction, doesn't seem to affect anything
a_Pkt.WriteBEUInt8(0x73);
a_Pkt.WriteBEFloat(static_cast<float>(Minecart.LastDamage() + 10)); // Damage taken / shake effect multiplyer
-
+
if (Minecart.GetPayload() == cMinecart::mpNone)
{
auto & RideableMinecart = reinterpret_cast<const cRideableMinecart &>(Minecart);
@@ -2981,7 +2981,7 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(reinterpret_cast<const cBat &>(a_Mob).IsHanging() ? 1 : 0);
break;
} // case mtBat
-
+
case mtCreeper:
{
a_Pkt.WriteBEUInt8(0x10);
@@ -2990,7 +2990,7 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(reinterpret_cast<const cCreeper &>(a_Mob).IsCharged() ? 1 : 0);
break;
} // case mtCreeper
-
+
case mtEnderman:
{
auto & Enderman = reinterpret_cast<const cEnderman &>(a_Mob);
@@ -3002,14 +3002,14 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(Enderman.IsScreaming() ? 1 : 0);
break;
} // case mtEnderman
-
+
case mtGhast:
{
a_Pkt.WriteBEUInt8(0x10);
a_Pkt.WriteBEUInt8(reinterpret_cast<const cGhast &>(a_Mob).IsCharging());
break;
} // case mtGhast
-
+
case mtHorse:
{
auto & Horse = reinterpret_cast<const cHorse &>(a_Mob);
@@ -3062,14 +3062,14 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(static_cast<Byte>(reinterpret_cast<const cMagmaCube &>(a_Mob).GetSize()));
break;
} // case mtMagmaCube
-
+
case mtPig:
{
a_Pkt.WriteBEUInt8(0x10);
a_Pkt.WriteBEUInt8(reinterpret_cast<const cPig &>(a_Mob).IsSaddled() ? 1 : 0);
break;
} // case mtPig
-
+
case mtSheep:
{
a_Pkt.WriteBEUInt8(0x10);
@@ -3082,28 +3082,28 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(SheepMetadata);
break;
} // case mtSheep
-
+
case mtSkeleton:
{
a_Pkt.WriteBEUInt8(0x0d);
a_Pkt.WriteBEUInt8(reinterpret_cast<const cSkeleton &>(a_Mob).IsWither() ? 1 : 0);
break;
} // case mtSkeleton
-
+
case mtSlime:
{
a_Pkt.WriteBEUInt8(0x10);
a_Pkt.WriteBEUInt8(static_cast<Byte>(reinterpret_cast<const cSlime &>(a_Mob).GetSize()));
break;
} // case mtSlime
-
+
case mtVillager:
{
a_Pkt.WriteBEUInt8(0x50);
a_Pkt.WriteBEInt32(reinterpret_cast<const cVillager &>(a_Mob).GetVilType());
break;
} // case mtVillager
-
+
case mtWitch:
{
a_Pkt.WriteBEUInt8(0x15);
@@ -3119,7 +3119,7 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEFloat(static_cast<float>(a_Mob.GetHealth()));
break;
} // case mtWither
-
+
case mtWolf:
{
auto & Wolf = reinterpret_cast<const cWolf &>(a_Mob);
@@ -3147,7 +3147,7 @@ void cProtocol172::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
a_Pkt.WriteBEUInt8(static_cast<Byte>(Wolf.GetCollarColor()));
break;
} // case mtWolf
-
+
case mtZombie:
{
auto & Zombie = reinterpret_cast<const cZombie &>(a_Mob);
@@ -3184,7 +3184,7 @@ void cProtocol172::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_
// auto & Mob = reinterpret_cast<const cMonster &>(a_Entity);
// TODO: Send properties and modifiers based on the mob type
-
+
a_Pkt.WriteBEInt32(0); // NumProperties
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index 747ffe186..24d8f8898 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -52,11 +52,11 @@ class cProtocol172 :
public cProtocol
{
typedef cProtocol super;
-
+
public:
cProtocol172(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
-
+
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
@@ -147,30 +147,30 @@ public:
protected:
AString m_ServerAddress;
-
+
UInt16 m_ServerPort;
-
+
AString m_AuthServerID;
-
+
/** State of the protocol. 1 = status, 2 = login, 3 = game */
UInt32 m_State;
/** Buffer for the received data */
cByteBuffer m_ReceivedData;
-
+
bool m_IsEncrypted;
-
+
cAesCfb128Decryptor m_Decryptor;
cAesCfb128Encryptor m_Encryptor;
/** The logfile where the comm is logged, when g_ShouldLogComm is true */
cFile m_CommLogFile;
-
+
/** The dimension that was last sent to a player in a Respawn or Login packet.
Used to avoid Respawning into the same dimension, which confuses the client. */
eDimension m_LastSentDimension;
-
-
+
+
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
@@ -186,7 +186,7 @@ protected:
// Packet handlers while in the Login state (m_State == 2):
void HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer);
void HandlePacketLoginStart(cByteBuffer & a_ByteBuffer);
-
+
// Packet handlers while in the Game state (m_State == 3):
void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer);
@@ -211,11 +211,11 @@ protected:
void HandlePacketEnchantItem (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);
-
+
/** Parses Vanilla plugin messages into specific ClientHandle calls.
The message payload is still in the bytebuffer, to be read by this function. */
void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel, UInt16 a_PayloadLength);
-
+
/** Sends the data to the client, encrypting them if needed. */
virtual void SendData(const char * a_Data, size_t a_Size) override;
@@ -223,13 +223,13 @@ protected:
virtual void SendPacket(cPacketizer & a_Packet) override;
void SendCompass(const cWorld & a_World);
-
+
/** Reads an item out of the received data, sets a_Item to the values read. Returns false if not enough received data */
virtual bool ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item);
-
+
/** Parses item metadata as read by ReadItem(), into the item enchantments. */
void ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
-
+
void StartEncryption(const Byte * a_Key);
/** Converts the BlockFace received by the protocol into eBlockFace constants.
@@ -261,10 +261,10 @@ class cProtocol176 :
public cProtocol172
{
typedef cProtocol172 super;
-
+
public:
cProtocol176(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
-
+
// cProtocol172 overrides:
virtual void SendPlayerSpawn(const cPlayer & a_Player) override;
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index c80907ed8..eab6c4721 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -174,7 +174,7 @@ void cProtocol180::DataReceived(const char * a_Data, size_t a_Size)
void cProtocol180::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1b); // Attach Entity packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt32((a_Vehicle != nullptr) ? a_Vehicle->GetUniqueID() : 0);
@@ -188,7 +188,7 @@ void cProtocol180::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_
void cProtocol180::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x24); // Block Action packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
Pkt.WriteBEInt8(a_Byte1);
@@ -203,7 +203,7 @@ void cProtocol180::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, cha
void cProtocol180::SendBlockBreakAnim(UInt32 a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x25); // Block Break Animation packet
Pkt.WriteVarInt32(a_EntityID);
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
@@ -250,7 +250,7 @@ void cProtocol180::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockV
void cProtocol180::SendChat(const AString & a_Message, eChatType a_Type)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x02); // Chat Message packet
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Message).c_str()));
Pkt.WriteBEInt8(a_Type);
@@ -294,7 +294,7 @@ void cProtocol180::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerialize
void cProtocol180::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0d); // Collect Item packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteVarInt32(a_Player.GetUniqueID());
@@ -307,7 +307,7 @@ void cProtocol180::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a
void cProtocol180::SendDestroyEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x13); // Destroy Entities packet
Pkt.WriteVarInt32(1);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
@@ -345,7 +345,7 @@ void cProtocol180::SendDisconnect(const AString & a_Reason)
void cProtocol180::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x36); // Sign Editor Open packet
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
}
@@ -357,7 +357,7 @@ void cProtocol180::SendEditSign(int a_BlockX, int a_BlockY, int a_BlockZ)
void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, short a_Duration)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1D); // Entity Effect packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
@@ -373,7 +373,7 @@ void cProtocol180::SendEntityEffect(const cEntity & a_Entity, int a_EffectID, in
void cProtocol180::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x04); // Entity Equipment packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt16(a_SlotNum);
@@ -387,7 +387,7 @@ void cProtocol180::SendEntityEquipment(const cEntity & a_Entity, short a_SlotNum
void cProtocol180::SendEntityHeadLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x19); // Entity Head Look packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetHeadYaw());
@@ -400,7 +400,7 @@ void cProtocol180::SendEntityHeadLook(const cEntity & a_Entity)
void cProtocol180::SendEntityLook(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x16); // Entity Look packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteByteAngle(a_Entity.GetYaw());
@@ -415,7 +415,7 @@ void cProtocol180::SendEntityLook(const cEntity & a_Entity)
void cProtocol180::SendEntityMetadata(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1c); // Entity Metadata packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityMetadata(Pkt, a_Entity);
@@ -429,7 +429,7 @@ void cProtocol180::SendEntityMetadata(const cEntity & a_Entity)
void cProtocol180::SendEntityProperties(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x20); // Entity Properties packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
WriteEntityProperties(Pkt, a_Entity);
@@ -442,7 +442,7 @@ void cProtocol180::SendEntityProperties(const cEntity & a_Entity)
void cProtocol180::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x15); // Entity Relative Move packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_RelX);
@@ -458,7 +458,7 @@ void cProtocol180::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char
void cProtocol180::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x17); // Entity Look And Relative Move packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_RelX);
@@ -476,7 +476,7 @@ void cProtocol180::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX,
void cProtocol180::SendEntityStatus(const cEntity & a_Entity, char a_Status)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1a); // Entity Status packet
Pkt.WriteBEUInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Status);
@@ -489,7 +489,7 @@ void cProtocol180::SendEntityStatus(const cEntity & a_Entity, char a_Status)
void cProtocol180::SendEntityVelocity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
// 400 = 8000 / 20 ... Conversion from our speed in m / s to 8000 m / tick
@@ -505,7 +505,7 @@ void cProtocol180::SendEntityVelocity(const cEntity & a_Entity)
void cProtocol180::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x27); // Explosion packet
Pkt.WriteBEFloat(static_cast<float>(a_BlockX));
Pkt.WriteBEFloat(static_cast<float>(a_BlockY));
@@ -530,7 +530,7 @@ void cProtocol180::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc
void cProtocol180::SendGameMode(eGameMode a_GameMode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
Pkt.WriteBEUInt8(3); // Reason: Change game mode
Pkt.WriteBEFloat(static_cast<float>(a_GameMode)); // The protocol really represents the value with a float!
@@ -570,7 +570,7 @@ void cProtocol180::SendHideTitle(void)
void cProtocol180::SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem & a_Item)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2f); // Set Slot packet
Pkt.WriteBEInt8(a_WindowID);
Pkt.WriteBEInt16(a_SlotNum);
@@ -589,7 +589,7 @@ void cProtocol180::SendKeepAlive(UInt32 a_PingID)
LOGWARNING("Trying to send a KeepAlive packet to a player who's not yet fully logged in (%d). The protocol class prevented the packet.", m_State);
return;
}
-
+
cPacketizer Pkt(*this, 0x00); // Keep Alive packet
Pkt.WriteVarInt32(a_PingID);
}
@@ -613,7 +613,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
Pkt.WriteBool(false); // Reduced Debug Info - wtf?
}
m_LastSentDimension = a_World.GetDimension();
-
+
// Send the spawn position:
{
cPacketizer Pkt(*this, 0x05); // Spawn Position packet
@@ -625,7 +625,7 @@ void cProtocol180::SendLogin(const cPlayer & a_Player, const cWorld & a_World)
cPacketizer Pkt(*this, 0x41);
Pkt.WriteBEInt8(1);
}
-
+
// Send player abilities:
SendPlayerAbilities();
}
@@ -677,7 +677,7 @@ void cProtocol180::SendPaintingSpawn(const cPainting & a_Painting)
void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataStartY)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x34);
Pkt.WriteVarInt32(a_Map.GetID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Map.GetScale()));
@@ -708,7 +708,7 @@ void cProtocol180::SendMapData(const cMap & a_Map, int a_DataStartX, int a_DataS
void cProtocol180::SendPickupSpawn(const cPickup & a_Pickup)
{
ASSERT(m_State == 3); // In game mode?
-
+
{
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
Pkt.WriteVarInt32(a_Pickup.GetUniqueID());
@@ -737,7 +737,7 @@ void cProtocol180::SendPickupSpawn(const cPickup & a_Pickup)
void cProtocol180::SendPlayerAbilities(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x39); // Player Abilities packet
Byte Flags = 0;
cPlayer * Player = m_Client->GetPlayer();
@@ -766,7 +766,7 @@ void cProtocol180::SendPlayerAbilities(void)
void cProtocol180::SendEntityAnimation(const cEntity & a_Entity, char a_Animation)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0b); // Animation packet
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEInt8(a_Animation);
@@ -954,7 +954,7 @@ void cProtocol180::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, con
void cProtocol180::SendPlayerMaxSpeed(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x20); // Entity Properties
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteVarInt32(Player->GetUniqueID());
@@ -983,7 +983,7 @@ void cProtocol180::SendPlayerMaxSpeed(void)
void cProtocol180::SendPlayerMoveLook(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEDouble(Player->GetPosX());
@@ -1035,7 +1035,7 @@ void cProtocol180::SendPlayerSpawn(const cPlayer & a_Player)
void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString & a_Message)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3f);
Pkt.WriteString(a_Channel);
Pkt.WriteBuf(a_Message.data(), a_Message.size());
@@ -1048,7 +1048,7 @@ void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString &
void cProtocol180::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1e);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_EffectID));
@@ -1094,7 +1094,7 @@ void cProtocol180::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimens
void cProtocol180::SendExperience(void)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x1f); // Experience Packet
cPlayer * Player = m_Client->GetPlayer();
Pkt.WriteBEFloat(Player->GetXpPercentage());
@@ -1109,7 +1109,7 @@ void cProtocol180::SendExperience(void)
void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x11);
Pkt.WriteVarInt32(a_ExpOrb.GetUniqueID());
Pkt.WriteFPInt(a_ExpOrb.GetPosX());
@@ -1125,7 +1125,7 @@ void cProtocol180::SendExperienceOrb(const cExpOrb & a_ExpOrb)
void cProtocol180::SendScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3b);
Pkt.WriteString(a_Name);
Pkt.WriteBEUInt8(a_Mode);
@@ -1143,7 +1143,7 @@ void cProtocol180::SendScoreboardObjective(const AString & a_Name, const AString
void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString & a_Player, cObjective::Score a_Score, Byte a_Mode)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3c);
Pkt.WriteString(a_Player);
Pkt.WriteBEUInt8(a_Mode);
@@ -1162,7 +1162,7 @@ void cProtocol180::SendScoreUpdate(const AString & a_Objective, const AString &
void cProtocol180::SendDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3d);
Pkt.WriteBEUInt8(static_cast<UInt8>(a_Display));
Pkt.WriteString(a_Objective);
@@ -1238,7 +1238,7 @@ void cProtocol180::SendSoundEffect(const AString & a_SoundName, double a_X, doub
void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x28); // Effect packet
Pkt.WriteBEInt32(static_cast<int>(a_EffectID));
Pkt.WritePosition64(a_SrcX, a_SrcY, a_SrcZ);
@@ -1253,7 +1253,7 @@ void cProtocol180::SendSoundParticleEffect(const EffectID a_EffectID, int a_SrcX
void cProtocol180::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0e); // Spawn Object packet
Pkt.WriteVarInt32(a_FallingBlock.GetUniqueID());
Pkt.WriteBEUInt8(70); // Falling block
@@ -1275,7 +1275,7 @@ void cProtocol180::SendSpawnFallingBlock(const cFallingBlock & a_FallingBlock)
void cProtocol180::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.WriteBEUInt8(static_cast<Byte>(a_Mob.GetMobType()));
@@ -1331,7 +1331,7 @@ void cProtocol180::SendSpawnObject(const cEntity & a_Entity, char a_ObjectType,
void cProtocol180::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleType, char a_VehicleSubType)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0xe); // Spawn Object packet
Pkt.WriteVarInt32(a_Vehicle.GetUniqueID());
Pkt.WriteBEUInt8(static_cast<UInt8>(a_VehicleType));
@@ -1356,7 +1356,7 @@ void cProtocol180::SendSpawnVehicle(const cEntity & a_Vehicle, char a_VehicleTyp
void cProtocol180::SendStatistics(const cStatManager & a_Manager)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x37);
Pkt.WriteVarInt32(statCount); // TODO 2014-05-11 xdot: Optimization: Send "dirty" statistics only
@@ -1378,7 +1378,7 @@ void cProtocol180::SendStatistics(const cStatManager & a_Manager)
void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x3a); // Tab-Complete packet
Pkt.WriteVarInt32(static_cast<UInt32>(a_Results.size()));
@@ -1395,7 +1395,7 @@ void cProtocol180::SendTabCompletionResults(const AStringVector & a_Results)
void cProtocol180::SendTeleportEntity(const cEntity & a_Entity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x18);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WriteFPInt(a_Entity.GetPosX());
@@ -1413,7 +1413,7 @@ void cProtocol180::SendTeleportEntity(const cEntity & a_Entity)
void cProtocol180::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2c); // Spawn Global Entity packet
Pkt.WriteVarInt32(0); // EntityID = 0, always
Pkt.WriteBEUInt8(1); // Type = Thunderbolt
@@ -1450,7 +1450,7 @@ void cProtocol180::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do
// When writing a "-" before the number the client ignores it but it will stop the client-side time expiration.
a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
}
-
+
cPacketizer Pkt(*this, 0x03);
Pkt.WriteBEInt64(a_WorldAge);
Pkt.WriteBEInt64(a_TimeOfDay);
@@ -1463,7 +1463,7 @@ void cProtocol180::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_Do
void cProtocol180::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x21); // Chunk Data packet
Pkt.WriteBEInt32(a_ChunkX);
Pkt.WriteBEInt32(a_ChunkZ);
@@ -1478,7 +1478,7 @@ void cProtocol180::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
void cProtocol180::SendUpdateBlockEntity(cBlockEntity & a_BlockEntity)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x35); // Update tile entity packet
Pkt.WritePosition64(a_BlockEntity.GetPosX(), a_BlockEntity.GetPosY(), a_BlockEntity.GetPosZ());
@@ -1525,7 +1525,7 @@ void cProtocol180::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, cons
void cProtocol180::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x0a);
Pkt.WriteVarInt32(a_Entity.GetUniqueID());
Pkt.WritePosition64(a_BlockX, a_BlockY, a_BlockZ);
@@ -1538,7 +1538,7 @@ void cProtocol180::SendUseBed(const cEntity & a_Entity, int a_BlockX, int a_Bloc
void cProtocol180::SendWeather(eWeather a_Weather)
{
ASSERT(m_State == 3); // In game mode?
-
+
{
cPacketizer Pkt(*this, 0x2b); // Change Game State packet
Pkt.WriteBEUInt8((a_Weather == wSunny) ? 1 : 2); // End rain / begin rain
@@ -1555,7 +1555,7 @@ void cProtocol180::SendWeather(eWeather a_Weather)
void cProtocol180::SendWholeInventory(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x30); // Window Items packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(static_cast<Int16>(a_Window.GetNumSlots()));
@@ -1574,7 +1574,7 @@ void cProtocol180::SendWholeInventory(const cWindow & a_Window)
void cProtocol180::SendWindowClose(const cWindow & a_Window)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x2e);
Pkt.WriteBEInt8(a_Window.GetWindowID());
}
@@ -1627,7 +1627,7 @@ void cProtocol180::SendWindowOpen(const cWindow & a_Window)
void cProtocol180::SendWindowProperty(const cWindow & a_Window, short a_Property, short a_Value)
{
ASSERT(m_State == 3); // In game mode?
-
+
cPacketizer Pkt(*this, 0x31); // Window Property packet
Pkt.WriteBEInt8(a_Window.GetWindowID());
Pkt.WriteBEInt16(a_Property);
@@ -1832,7 +1832,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
m_ReceivedData.ResetRead();
break;
}
-
+
// Check packet for compression:
UInt32 UncompressedSize = 0;
AString UncompressedData;
@@ -1868,7 +1868,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
}
}
}
-
+
// Move the packet payload to a separate cByteBuffer, bb:
cByteBuffer bb(PacketLen + 1);
if (UncompressedSize == 0)
@@ -1892,7 +1892,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
// Write one NUL extra, so that we can detect over-reads
bb.Write("\0", 1);
-
+
// Log the packet info into the comm log file:
if (g_ShouldLogCommIn && m_CommLogFile.IsOpen())
{
@@ -1913,7 +1913,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
{
// Unknown packet, already been reported, but without the length. Log the length here:
LOGWARNING("Unhandled packet: type 0x%x, state %d, length %u", PacketType, m_State, PacketLen);
-
+
#ifdef _DEBUG
// Dump the packet contents into the log:
bb.ResetRead();
@@ -1924,13 +1924,13 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
CreateHexDump(Out, Packet.data(), Packet.size(), 24);
LOGD("Packet contents:\n%s", Out.c_str());
#endif // _DEBUG
-
+
// Put a message in the comm log:
if (g_ShouldLogCommIn && m_CommLogFile.IsOpen())
{
m_CommLogFile.Printf("^^^^^^ Unhandled packet ^^^^^^\n\n\n");
}
-
+
return;
}
@@ -1991,7 +1991,7 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
}
break;
}
-
+
case 2:
{
// Login
@@ -2002,7 +2002,7 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
}
break;
}
-
+
case 3:
{
// Game
@@ -2039,9 +2039,9 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
{
// Received a packet in an unknown state, report:
LOGWARNING("Received a packet in an unknown protocol state %d. Ignoring further packets.", m_State);
-
+
// 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;
return false;
@@ -2053,7 +2053,7 @@ bool cProtocol180::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType)
return false;
}
} // switch (m_State)
-
+
// Unknown packet type, report to the ClientHandle:
m_Client->PacketUnknown(a_PacketType);
return false;
@@ -2164,7 +2164,7 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
m_Client->Kick("Hacked client");
return;
}
-
+
// Decrypt the symmetric encryption key using privkey:
Byte DecryptedKey[MAX_ENC_LEN];
res = rsaDecryptor.Decrypt(reinterpret_cast<const Byte *>(EncKey.data()), EncKey.size(), DecryptedKey, sizeof(DecryptedKey));
@@ -2174,7 +2174,7 @@ void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe
m_Client->Kick("Hacked client");
return;
}
-
+
StartEncryption(DecryptedKey);
m_Client->HandleLogin(4, m_Client->GetUsername());
}
@@ -2191,13 +2191,13 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
m_Client->Kick("Bad username");
return;
}
-
+
if (!m_Client->HandleHandshake(Username))
{
// The client is not welcome here, they have been sent a Kick packet already
return;
}
-
+
cServer * Server = cRoot::Get()->GetServer();
// If auth is required, then send the encryption request:
if (Server->ShouldAuthenticate())
@@ -2212,7 +2212,7 @@ void cProtocol180::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
m_Client->SetUsername(Username);
return;
}
-
+
m_Client->HandleLogin(4, Username);
}
@@ -2287,7 +2287,7 @@ void cProtocol180::HandlePacketClientSettings(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, ChatFlags);
HANDLE_READ(a_ByteBuffer, ReadBool, bool, ChatColors);
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, SkinFlags);
-
+
m_Client->SetLocale(Locale);
m_Client->SetViewDistance(ViewDistance);
// TODO: Handle other values
@@ -2451,7 +2451,7 @@ void cProtocol180::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer)
void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
{
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel);
-
+
// If the plugin channel is recognized vanilla, handle it directly:
if (Channel.substr(0, 3) == "MC|")
{
@@ -2723,7 +2723,7 @@ void cProtocol180::HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const
return;
}
LOG("Unhandled vanilla plugin channel: \"%s\".", a_Channel.c_str());
-
+
// Read the payload and send it through to the clienthandle:
AString Message;
VERIFY(a_ByteBuffer.ReadString(Message, a_ByteBuffer.GetReadableSpace() - 1));
@@ -2768,7 +2768,7 @@ bool cProtocol180::ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a
return true;
}
a_Item.m_ItemType = ItemType;
-
+
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt8, Int8, ItemCount);
HANDLE_PACKET_READ(a_ByteBuffer, ReadBEInt16, Int16, ItemDamage);
a_Item.m_ItemCount = ItemCount;
@@ -2804,7 +2804,7 @@ void cProtocol180::ParseItemMetadata(cItem & a_Item, const AString & a_Metadata)
LOGWARNING("Cannot parse NBT item metadata: (" SIZE_T_FMT " bytes)\n%s", a_Metadata.size(), HexDump.c_str());
return;
}
-
+
// Load enchantments and custom display names from the NBT data:
for (int tag = NBT.GetFirstChild(NBT.GetRoot()); tag >= 0; tag = NBT.GetNextSibling(tag))
{
@@ -2873,7 +2873,7 @@ void cProtocol180::StartEncryption(const Byte * a_Key)
m_Encryptor.Init(a_Key, a_Key);
m_Decryptor.Init(a_Key, a_Key);
m_IsEncrypted = true;
-
+
// Prepare the m_AuthServerID:
cSha1Checksum Checksum;
cServer * Server = cRoot::Get()->GetServer();
@@ -2982,17 +2982,17 @@ void cProtocol180::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
// Fix, to make sure no invalid values are sent.
ItemType = -1;
}
-
+
if (a_Item.IsEmpty())
{
a_Pkt.WriteBEInt16(-1);
return;
}
-
+
a_Pkt.WriteBEInt16(ItemType);
a_Pkt.WriteBEInt8(a_Item.m_ItemCount);
a_Pkt.WriteBEInt16(a_Item.m_ItemDamage);
-
+
if (a_Item.m_Enchantments.IsEmpty() && a_Item.IsBothNameAndLoreEmpty() && (a_Item.m_ItemType != E_ITEM_FIREWORK_ROCKET) && (a_Item.m_ItemType != E_ITEM_FIREWORK_STAR) && !a_Item.m_ItemColor.IsValid())
{
a_Pkt.WriteBEInt8(0);
@@ -3218,7 +3218,7 @@ void cProtocol180::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_En
a_Pkt.WriteBEInt32(1); // Shaking direction, doesn't seem to affect anything
a_Pkt.WriteBEUInt8(0x73);
a_Pkt.WriteBEFloat(static_cast<float>(Minecart.LastDamage() + 10)); // Damage taken / shake effect multiplyer
-
+
if (Minecart.GetPayload() == cMinecart::mpNone)
{
auto & RideableMinecart = reinterpret_cast<const cRideableMinecart &>(Minecart);
@@ -3441,7 +3441,7 @@ void cProtocol180::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob)
auto & Sheep = reinterpret_cast<const cSheep &>(a_Mob);
a_Pkt.WriteBEUInt8(0x0c);
a_Pkt.WriteBEInt8(Sheep.IsBaby() ? -1 : (Sheep.IsInLoveCooldown() ? 1 : 0));
-
+
a_Pkt.WriteBEUInt8(0x10);
Byte SheepMetadata = 0;
SheepMetadata = static_cast<Byte>(Sheep.GetFurColor());
@@ -3575,7 +3575,7 @@ void cProtocol180::WriteEntityProperties(cPacketizer & a_Pkt, const cEntity & a_
// const cMonster & Mob = (const cMonster &)a_Entity;
// TODO: Send properties and modifiers based on the mob type
-
+
a_Pkt.WriteBEInt32(0); // NumProperties
}
diff --git a/src/Protocol/Protocol18x.h b/src/Protocol/Protocol18x.h
index 8b5b7ffa2..8a446a1b9 100644
--- a/src/Protocol/Protocol18x.h
+++ b/src/Protocol/Protocol18x.h
@@ -51,11 +51,11 @@ class cProtocol180 :
public cProtocol
{
typedef cProtocol super;
-
+
public:
cProtocol180(cClientHandle * a_Client, const AString & a_ServerAddress, UInt16 a_ServerPort, UInt32 a_State);
-
+
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
@@ -157,30 +157,30 @@ public:
protected:
AString m_ServerAddress;
-
+
UInt16 m_ServerPort;
-
+
AString m_AuthServerID;
-
+
/** State of the protocol. 1 = status, 2 = login, 3 = game */
UInt32 m_State;
/** Buffer for the received data */
cByteBuffer m_ReceivedData;
-
+
bool m_IsEncrypted;
-
+
cAesCfb128Decryptor m_Decryptor;
cAesCfb128Encryptor m_Encryptor;
/** The logfile where the comm is logged, when g_ShouldLogComm is true */
cFile m_CommLogFile;
-
+
/** The dimension that was last sent to a player in a Respawn or Login packet.
Used to avoid Respawning into the same dimension, which confuses the client. */
eDimension m_LastSentDimension;
-
-
+
+
/** Adds the received (unencrypted) data to m_ReceivedData, parses complete packets */
void AddReceivedData(const char * a_Data, size_t a_Size);
@@ -196,7 +196,7 @@ protected:
// Packet handlers while in the Login state (m_State == 2):
void HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer);
void HandlePacketLoginStart(cByteBuffer & a_ByteBuffer);
-
+
// Packet handlers while in the Game state (m_State == 3):
void HandlePacketAnimation (cByteBuffer & a_ByteBuffer);
void HandlePacketBlockDig (cByteBuffer & a_ByteBuffer);
@@ -221,12 +221,12 @@ protected:
void HandlePacketEnchantItem (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClick (cByteBuffer & a_ByteBuffer);
void HandlePacketWindowClose (cByteBuffer & a_ByteBuffer);
-
+
/** 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 */
void HandleVanillaPluginMessage(cByteBuffer & a_ByteBuffer, const AString & a_Channel);
-
-
+
+
/** Sends the data to the client, encrypting them if needed. */
virtual void SendData(const char * a_Data, size_t a_Size) override;
@@ -234,15 +234,15 @@ protected:
virtual void SendPacket(cPacketizer & a_Packet) override;
void SendCompass(const cWorld & a_World);
-
+
/** Reads an item out of the received data, sets a_Item to the values read.
Returns false if not enough received data.
a_KeepRemainingBytes tells the function to keep that many bytes at the end of the buffer. */
virtual bool ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes = 0);
-
+
/** Parses item metadata as read by ReadItem(), into the item enchantments. */
void ParseItemMetadata(cItem & a_Item, const AString & a_Metadata);
-
+
void StartEncryption(const Byte * a_Key);
/** Converts the BlockFace received by the protocol into eBlockFace constants.
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index c88bd8639..fff55b6e9 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -66,7 +66,7 @@ void cProtocolRecognizer::DataReceived(const char * a_Data, size_t a_Size)
m_Client->Kick("Unsupported protocol version");
return;
}
-
+
if (!TryRecognizeProtocol())
{
return;
diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h
index c548ad5ba..89dfaec38 100644
--- a/src/Protocol/ProtocolRecognizer.h
+++ b/src/Protocol/ProtocolRecognizer.h
@@ -29,7 +29,7 @@ class cProtocolRecognizer :
public cProtocol
{
typedef cProtocol super;
-
+
public:
enum
{
@@ -40,13 +40,13 @@ public:
cProtocolRecognizer(cClientHandle * a_Client);
virtual ~cProtocolRecognizer();
-
+
/** Translates protocol version number into protocol version text: 49 -> "1.4.4" */
static AString GetVersionTextFromInt(int a_ProtocolVersion);
-
+
/** Called when client sends some data: */
virtual void DataReceived(const char * a_Data, size_t a_Size) override;
-
+
/** Sending stuff to clients (alphabetically sorted): */
virtual void SendAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle) override;
virtual void SendBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType) override;
@@ -128,7 +128,7 @@ public:
virtual void SendWindowClose (const cWindow & a_Window) override;
virtual void SendWindowOpen (const cWindow & a_Window) override;
virtual void SendWindowProperty (const cWindow & a_Window, short a_Property, short a_Value) override;
-
+
virtual AString GetAuthServerID(void) override;
virtual void SendData(const char * a_Data, size_t a_Size) override;
@@ -139,11 +139,11 @@ protected:
/** Buffer for the incoming data until we recognize the protocol */
cByteBuffer m_Buffer;
-
+
/** Tries to recognize protocol based on m_Buffer contents; returns true if recognized */
bool TryRecognizeProtocol(void);
-
+
/** Tries to recognize a protocol in the lengthed family (1.7+), based on m_Buffer; returns true if recognized.
The packet length and type have already been read, type is 0
The number of bytes remaining in the packet is passed as a_PacketLengthRemaining. */