summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.h
diff options
context:
space:
mode:
authorJulian Laubstein <julianlaubstein@yahoo.de>2016-02-06 11:37:34 +0100
committerJulian Laubstein <julianlaubstein@yahoo.de>2016-02-06 11:37:34 +0100
commit6fdd7194c81be7234a126bdc3b48f0291fce3567 (patch)
tree7d5ac74b7385ce4ebf77588d80549c884c2b993c /src/ClientHandle.h
parentMerge pull request #2958 from LogicParrot/fence (diff)
parentBulk clearing of whitespace (diff)
downloadcuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar.gz
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar.bz2
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar.lz
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar.xz
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.tar.zst
cuberite-6fdd7194c81be7234a126bdc3b48f0291fce3567.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.h108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 22d052f22..899b0a5ab 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -62,56 +62,56 @@ public: // tolua_export
#endif
static const int MAX_VIEW_DISTANCE = 32;
static const int MIN_VIEW_DISTANCE = 1;
-
+
/** Creates a new client with the specified IP address in its description and the specified initial view distance. */
cClientHandle(const AString & a_IPString, int a_ViewDistance);
virtual ~cClientHandle();
const AString & GetIPString(void) const { return m_IPString; } // tolua_export
-
+
/** Sets the IP string that the client is using. Overrides the IP string that was read from the socket.
Used mainly by BungeeCord compatibility code. */
void SetIPString(const AString & a_IPString) { m_IPString = a_IPString; }
-
+
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
-
+
/** Sets the player's UUID, as used by the protocol. Short UUID form (no dashes) is expected.
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; }
const Json::Value & GetProperties(void) const { return m_Properties; }
-
+
/** Sets the player's properties, such as skin image and signature.
Used mainly by BungeeCord compatibility code - property querying is done on the BungeeCord server
and the results are passed to MCS running in offline mode. */
void SetProperties(const Json::Value & a_Properties) { m_Properties = a_Properties; }
-
+
/** Generates an UUID based on the username stored for this client, and stores it in the m_UUID member.
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.
Internally calls the GenerateOfflineUUID static function. */
void GenerateOfflineUUID(void);
-
+
/** 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
-
+
/** 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
-
+
/** 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);
-
+
static AString FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2);
void Kick(const AString & a_Reason); // tolua_export
@@ -124,20 +124,20 @@ public: // tolua_export
/** Remove all loaded chunks that are no longer in range */
void UnloadOutOfRangeChunks(void);
-
+
// Removes the client from all chunks. Used when switching worlds or destroying the player
void RemoveFromAllChunks(void);
-
+
inline bool IsLoggedIn(void) const { return (m_State >= csAuthenticating); }
/** Called while the client is being ticked from the world via its cPlayer object */
void Tick(float a_Dt);
-
+
/** Called while the client is being ticked from the cServer object */
void ServerTick(float a_Dt);
void Destroy(void);
-
+
bool IsPlaying (void) const { return (m_State == csPlaying); }
bool IsDestroyed (void) const { return (m_State == csDestroyed); }
bool IsDestroying(void) const { return (m_State == csDestroying); }
@@ -229,9 +229,9 @@ public: // tolua_export
// tolua_begin
const AString & GetUsername(void) const;
void SetUsername( const AString & a_Username);
-
+
inline short GetPing(void) const { return static_cast<short>(std::chrono::duration_cast<std::chrono::milliseconds>(m_Ping).count()); }
-
+
/** Sets the maximal view distance. */
void SetViewDistance(int a_ViewDistance);
@@ -245,24 +245,24 @@ public: // tolua_export
AString GetLocale(void) const { return m_Locale; }
int GetUniqueID(void) const { return m_UniqueID; }
-
+
bool HasPluginChannel(const AString & a_PluginChannel);
-
+
/** Called by the protocol when it receives the MC|Brand plugin message. Also callable by plugins.
Simply stores the string value. */
void SetClientBrand(const AString & a_ClientBrand) { m_ClientBrand = a_ClientBrand; }
-
+
/** Returns the client brand received in the MC|Brand plugin message or set by a plugin. */
const AString & GetClientBrand(void) const { return m_ClientBrand; }
-
+
// tolua_end
-
+
/** Returns true if the client wants the chunk specified to be sent (in m_ChunksToSend) */
bool WantsSendChunk(int a_ChunkX, int a_ChunkZ);
-
+
/** Adds the chunk specified to the list of chunks wanted for sending (m_ChunksToSend) */
void AddWantedChunk(int a_ChunkX, int a_ChunkZ);
-
+
// Calls that cProtocol descendants use to report state:
void PacketBufferFull(void);
void PacketUnknown(UInt32 a_PacketType);
@@ -270,26 +270,26 @@ public: // tolua_export
// Calls that cProtocol descendants use for handling packets:
void HandleAnimation(int a_Animation);
-
+
/** Called when the protocol receives a MC|ItemName plugin message, indicating that the player named
an item in the anvil UI. */
void HandleAnvilItemName(const AString & a_ItemName);
-
+
/** Called when the protocol receives a MC|Beacon plugin message, indicating that the player set an effect
in the beacon UI. */
void HandleBeaconSelection(int a_PrimaryEffect, int a_SecondaryEffect);
-
+
/** Called when the protocol detects a chat packet. */
void HandleChat(const AString & a_Message);
-
+
/** Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new
command in the command block UI, for a block-based commandblock. */
void HandleCommandBlockBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_NewCommand);
-
+
/** Called when the protocol receives a MC|AdvCdm plugin message, indicating that the player set a new
command in the command block UI, for an entity-based commandblock (minecart?). */
void HandleCommandBlockEntityChange(UInt32 a_EntityID, const AString & a_NewCommand);
-
+
/** Called when the client clicks the creative inventory window.
a_ClickAction specifies whether the click was inside the window or not (caLeftClick or caLeftClickOutside). */
void HandleCreativeInventory(Int16 a_SlotNum, const cItem & a_HeldItem, eClickAction a_ClickAction);
@@ -300,24 +300,24 @@ public: // tolua_export
void HandleEntityCrouch (UInt32 a_EntityID, bool a_IsCrouching);
void HandleEntityLeaveBed (UInt32 a_EntityID);
void HandleEntitySprinting (UInt32 a_EntityID, bool a_IsSprinting);
-
+
/** Kicks the client if the same username is already logged in.
Returns false if the client has been kicked, true otherwise. */
bool CheckMultiLogin(const AString & a_Username);
-
+
/** Called when the protocol handshake has been received (for protocol versions that support it;
otherwise the first instant when a username is received).
Returns true if the player is to be let in, false if they were disconnected
*/
bool HandleHandshake (const AString & a_Username);
-
+
void HandleKeepAlive (UInt32 a_KeepAliveID);
void HandleLeftClick (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, UInt8 a_Status);
-
+
/** Called when the protocol receives a MC|TrSel packet, indicating that the player used a trade in
the NPC UI. */
void HandleNPCTrade(int a_SlotNum);
-
+
void HandlePing (void);
void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed);
void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround);
@@ -350,19 +350,19 @@ public: // tolua_export
Return true to allow the user in; false to kick them.
*/
bool HandleLogin(UInt32 a_ProtocolVersion, const AString & a_Username);
-
+
void SendData(const char * a_Data, size_t a_Size);
-
+
/** Called when the player moves into a different world.
Sends an UnloadChunk packet for each loaded chunk and resets the streamed chunks. */
void RemoveFromWorld(void);
-
+
/** 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:
friend class cServer; // Needs access to SetSelf()
@@ -407,7 +407,7 @@ private:
Vector3d m_ConfirmPosition;
cPlayer * m_Player;
-
+
bool m_HasSentDC; ///< True if a Disconnect packet has been sent in either direction
// Chunk position when the last StreamChunks() was called; used to avoid re-streaming while in the same chunk
@@ -416,7 +416,7 @@ private:
/** Number of ticks since the last network packet was received (increased in Tick(), reset in OnReceivedData()) */
std::atomic<int> m_TicksSinceLastPacket;
-
+
/** Duration of the last completed client ping. */
std::chrono::steady_clock::duration m_Ping;
@@ -449,12 +449,12 @@ private:
csPlaying, ///< Normal gameplay
csDestroying, ///< The client is being destroyed, don't queue any more packets / don't add to chunks
csDestroyed, ///< The client has been destroyed, the destructor is to be called from the owner thread
-
+
// TODO: Add Kicking here as well
} ;
-
+
std::atomic<eState> m_State;
-
+
/** m_State needs to be locked in the Destroy() function so that the destruction code doesn't run twice on two different threads */
cCriticalSection m_CSDestroyingState;
@@ -466,15 +466,15 @@ private:
/** Number of place or break interactions this tick */
int m_NumBlockChangeInteractionsThisTick;
-
+
static int s_ClientCount;
-
+
/** 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;
-
+
/** Set to true when the chunk where the player is is sent to the client. Used for spawning the player */
bool m_HasSentPlayerChunk;
@@ -483,10 +483,10 @@ private:
/** The positions from the last sign that the player placed. It's needed to verify the sign text change. */
Vector3i m_LastPlacedSign;
-
+
/** The plugin channels that the client has registered. */
cChannels m_PluginChannels;
-
+
/** The brand identification of the client, as received in the MC|Brand plugin message or set from a plugin. */
AString m_ClientBrand;
@@ -503,13 +503,13 @@ private:
/** Returns true if the rate block interactions is within a reasonable limit (bot protection) */
bool CheckBlockInteractionsRate(void);
-
+
/** Adds a single chunk to be streamed to the client; used by StreamChunks() */
void StreamChunk(int a_ChunkX, int a_ChunkZ, cChunkSender::eChunkPriority a_Priority);
-
+
/** Handles the DIG_STARTED dig packet: */
void HandleBlockDigStarted (int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
-
+
/** Handles the DIG_FINISHED dig packet: */
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
@@ -518,10 +518,10 @@ private:
/** Converts the protocol-formatted channel list (NUL-separated) into a proper string vector. */
AStringVector BreakApartPluginChannels(const AString & a_PluginChannels);
-
+
/** Adds all of the channels to the list of current plugin channels. Handles duplicates gracefully. */
void RegisterPluginChannels(const AStringVector & a_ChannelList);
-
+
/** Removes all of the channels from the list of current plugin channels. Ignores channels that are not found. */
void UnregisterPluginChannels(const AStringVector & a_ChannelList);