From f4f2fc7c3d76eb3dc5a91c5eefb36c10597d6cb7 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Fri, 25 Aug 2017 13:43:18 +0100 Subject: Add cUUID class (#3871) --- src/ClientHandle.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/ClientHandle.h') diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 2a661e283..09188f2ae 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -16,6 +16,7 @@ #include "json/json.h" #include "ChunkSender.h" #include "EffectID.h" +#include "UUID.h" @@ -72,13 +73,13 @@ public: // tolua_export cPlayer * GetPlayer(void) { return m_Player; } // tolua_export - /** Returns the player's UUID, as used by the protocol, in the short form (no dashes) */ - const AString & GetUUID(void) const { return m_UUID; } // tolua_export + /** Returns the player's UUID, as used by the protocol */ + const cUUID & GetUUID(void) const { return m_UUID; } // Exported in ManualBindings.cpp - /** Sets the player's UUID, as used by the protocol. Short UUID form (no dashes) is expected. + /** Sets the player's UUID, as used by the protocol. Used mainly by BungeeCord compatibility code - when authenticating is done on the BungeeCord server and the results are passed to MCS running in offline mode. */ - void SetUUID(const AString & a_UUID) { ASSERT(a_UUID.size() == 32); m_UUID = a_UUID; } + void SetUUID(const cUUID & a_UUID) { ASSERT(!a_UUID.IsNil()); m_UUID = a_UUID; } const Json::Value & GetProperties(void) const { return m_Properties; } @@ -95,15 +96,12 @@ public: // tolua_export /** Generates an UUID based on the player name provided. This is used for the offline (non-auth) mode, when there's no UUID source. - Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. - Returns a 32-char UUID (no dashes). */ - static AString GenerateOfflineUUID(const AString & a_Username); // tolua_export + Each username generates a unique and constant UUID, so that when the player reconnects with the same name, their UUID is the same. */ + static cUUID GenerateOfflineUUID(const AString & a_Username); // Exported in ManualBindings.cpp /** Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. - We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. - Accepts both 32-char and 36-char UUIDs (with and without dashes). - If the string given is not a valid UUID, returns false. */ - static bool IsUUIDOnline(const AString & a_UUID); // tolua_export + We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. */ + static bool IsUUIDOnline(const cUUID & a_UUID); // Exported in ManualBindings.cpp /** Formats the type of message with the proper color and prefix for sending to the client. */ static AString FormatMessageType(bool ShouldAppendChatPrefixes, eMessageType a_ChatPrefix, const AString & a_AdditionalData); @@ -113,7 +111,7 @@ public: // tolua_export void Kick(const AString & a_Reason); // tolua_export /** Authenticates the specified user, called by cAuthenticator */ - void Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties); + void Authenticate(const AString & a_Name, const cUUID & a_UUID, const Json::Value & a_Properties); /** This function sends a new unloaded chunk to the player. Returns true if all chunks are loaded. */ bool StreamNextChunk(); @@ -336,7 +334,7 @@ public: // tolua_export void HandleRespawn (void); void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem); void HandleSlotSelected (Int16 a_SlotNum); - void HandleSpectate (const AString & a_PlayerUUID); + void HandleSpectate (const cUUID & a_PlayerUUID); void HandleSteerVehicle (float Forward, float Sideways); void HandleTabCompletion (const AString & a_Text); void HandleUpdateSign ( @@ -498,8 +496,8 @@ private: /** ID used for identification during authenticating. Assigned sequentially for each new instance. */ int m_UniqueID; - /** Contains the UUID used by Mojang to identify the player's account. Short UUID stored here (without dashes) */ - AString m_UUID; + /** Contains the UUID used by Mojang to identify the player's account. */ + cUUID m_UUID; /** Set to true when the chunk where the player is is sent to the client. Used for spawning the player */ bool m_HasSentPlayerChunk; -- cgit v1.2.3