cClientHandle: Added protocol version knowledge.
This commit is contained in:
parent
f28f5e4879
commit
a8aeceab9d
@ -529,6 +529,7 @@ end
|
|||||||
GetLocale = { Params = "", Return = "Locale", Notes = "Returns the locale string that the client sends as part of the protocol handshake. Can be used to provide localized strings." },
|
GetLocale = { Params = "", Return = "Locale", Notes = "Returns the locale string that the client sends as part of the protocol handshake. Can be used to provide localized strings." },
|
||||||
GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" },
|
GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" },
|
||||||
GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." },
|
GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." },
|
||||||
|
GetProtocolVersion = { Params = "", Return = "number", Notes = "Returns the protocol version number of the protocol that the client is talking. Returns zero if the protocol version is not (yet) known." },
|
||||||
GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" },
|
GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" },
|
||||||
GetUUID = { Params = "", Return = "string", Notes = "Returns the authentication-based UUID of the client. This UUID should be used to identify the player when persisting any player-related data. Returns a 32-char UUID (no dashes)" },
|
GetUUID = { Params = "", Return = "string", Notes = "Returns the authentication-based UUID of the client. This UUID should be used to identify the player when persisting any player-related data. Returns a 32-char UUID (no dashes)" },
|
||||||
GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" },
|
GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" },
|
||||||
|
@ -92,7 +92,8 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) :
|
|||||||
m_NumBlockChangeInteractionsThisTick(0),
|
m_NumBlockChangeInteractionsThisTick(0),
|
||||||
m_UniqueID(0),
|
m_UniqueID(0),
|
||||||
m_HasSentPlayerChunk(false),
|
m_HasSentPlayerChunk(false),
|
||||||
m_Locale("en_GB")
|
m_Locale("en_GB"),
|
||||||
|
m_ProtocolVersion(0)
|
||||||
{
|
{
|
||||||
m_Protocol = new cProtocolRecognizer(this);
|
m_Protocol = new cProtocolRecognizer(this);
|
||||||
|
|
||||||
@ -583,15 +584,22 @@ void cClientHandle::HandlePing(void)
|
|||||||
|
|
||||||
bool cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Username)
|
bool cClientHandle::HandleLogin(int a_ProtocolVersion, const AString & a_Username)
|
||||||
{
|
{
|
||||||
|
// If the protocol version hasn't been set yet, set it now:
|
||||||
|
if (m_ProtocolVersion == 0)
|
||||||
|
{
|
||||||
|
m_ProtocolVersion = a_ProtocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
m_Username = a_Username;
|
m_Username = a_Username;
|
||||||
|
|
||||||
|
// Let the plugins know about this event, they may refuse the player:
|
||||||
if (cRoot::Get()->GetPluginManager()->CallHookLogin(this, a_ProtocolVersion, a_Username))
|
if (cRoot::Get()->GetPluginManager()->CallHookLogin(this, a_ProtocolVersion, a_Username))
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule for authentication; until then, let them wait (but do not block)
|
// Schedule for authentication; until then, let the player wait (but do not block)
|
||||||
m_State = csAuthenticating;
|
m_State = csAuthenticating;
|
||||||
cRoot::Get()->GetAuthenticator().Authenticate(GetUniqueID(), GetUsername(), m_Protocol->GetAuthServerID());
|
cRoot::Get()->GetAuthenticator().Authenticate(GetUniqueID(), GetUsername(), m_Protocol->GetAuthServerID());
|
||||||
return true;
|
return true;
|
||||||
|
@ -316,6 +316,12 @@ public:
|
|||||||
|
|
||||||
/** Called when the player will enchant a Item */
|
/** Called when the player will enchant a Item */
|
||||||
void HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment);
|
void HandleEnchantItem(Byte & a_WindowID, Byte & a_Enchantment);
|
||||||
|
|
||||||
|
/** Called by the protocol recognizer when the protocol version is known. */
|
||||||
|
void SetProtocolVersion(UInt32 a_ProtocolVersion) { m_ProtocolVersion = a_ProtocolVersion; }
|
||||||
|
|
||||||
|
/** Returns the protocol version number of the protocol that the client is talking. Returns zero if the protocol version is not (yet) known. */
|
||||||
|
UInt32 GetProtocolVersion(void) const { return m_ProtocolVersion; } // tolua_export
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -427,6 +433,9 @@ private:
|
|||||||
/** The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin. */
|
/** The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin. */
|
||||||
AString m_ClientBrand;
|
AString m_ClientBrand;
|
||||||
|
|
||||||
|
/** The version of the protocol that the client is talking, or 0 if unknown. */
|
||||||
|
UInt32 m_ProtocolVersion;
|
||||||
|
|
||||||
|
|
||||||
/** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
|
/** Handles the block placing packet when it is a real block placement (not block-using, item-using or eating) */
|
||||||
void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
|
void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
|
||||||
|
@ -905,6 +905,7 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
m_Client->SetProtocolVersion(ProtocolVersion);
|
||||||
switch (ProtocolVersion)
|
switch (ProtocolVersion)
|
||||||
{
|
{
|
||||||
case PROTO_VERSION_1_7_2:
|
case PROTO_VERSION_1_7_2:
|
||||||
|
@ -134,7 +134,7 @@ protected:
|
|||||||
/// Tries to recognize protocol based on m_Buffer contents; returns true if recognized
|
/// Tries to recognize protocol based on m_Buffer contents; returns true if recognized
|
||||||
bool TryRecognizeProtocol(void);
|
bool TryRecognizeProtocol(void);
|
||||||
|
|
||||||
/** Tries to recognize a protocol in the leghted family (1.7+), based on m_Buffer; returns true if recognized.
|
/** 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 packet length and type have already been read, type is 0
|
||||||
The number of bytes remaining in the packet is passed as a_PacketLengthRemaining
|
The number of bytes remaining in the packet is passed as a_PacketLengthRemaining
|
||||||
**/
|
**/
|
||||||
|
Loading…
Reference in New Issue
Block a user