From ecb86935f87ce2b9f1ae4671d8a8b722c798b8a2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 31 Jul 2014 22:52:06 +0200 Subject: Fixed UUIDs handling in cPlayer. The loading expected dashed UUIDs, MCS uses short UUIDs throughout. --- src/Entities/Player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 488884602..29bb4c39d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -536,7 +536,7 @@ protected: */ bool m_bIsTeleporting; - /** The UUID of the player, as read from the ClientHandle. + /** The short UUID (no dashes) of the player, as read from the ClientHandle. If no ClientHandle is given, the UUID is initialized to empty. */ AString m_UUID; -- cgit v1.2.3 From 84462ba8b20c28136c6a7923323f7cde28a86d70 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 31 Jul 2014 23:04:00 +0200 Subject: Fixed hunger bugs, Implemented golden apple, added jump statistic, added correct food effects. --- src/Entities/Player.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 65c1e33a8..f188789b8 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -284,10 +284,7 @@ public: bool Feed(int a_Food, double a_Saturation); /** Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values. */ - void AddFoodExhaustion(double a_Exhaustion) - { - m_FoodExhaustionLevel += a_Exhaustion; - } + void AddFoodExhaustion(double a_Exhaustion); /** Starts the food poisoning for the specified amount of ticks */ void FoodPoison(int a_NumTicks); -- cgit v1.2.3 From 3ffec92e7930c0b4bb14073f23a9d12313bd6cbc Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:27:27 -0700 Subject: Removed unused cPlayer::FoodPoison function --- src/Entities/Player.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 917e87a89..e3203d6d1 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -286,9 +286,6 @@ public: /** Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values. */ void AddFoodExhaustion(double a_Exhaustion); - /** Starts the food poisoning for the specified amount of ticks */ - void FoodPoison(int a_NumTicks); - /** Returns true if the player is currently in the process of eating the currently equipped item */ bool IsEating(void) const { return (m_EatingFinishTick >= 0); } -- cgit v1.2.3 From 836de13797577289e91478ce89de65d39096f9e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 3 Aug 2014 11:57:26 +0200 Subject: Added cPlayer::GetUUID(). --- src/Entities/Player.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index e3203d6d1..e26808bfc 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -417,6 +417,9 @@ public: /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } + + /** Returns the UUID (short format) that has been read from the client, or empty string if not available. */ + const AString & GetUUID(void) const { return m_UUID; } // tolua_end -- cgit v1.2.3 From dba672361164dc5dc5f94d24bde3176c7de89d4c Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:42:53 -0700 Subject: Player.cpp: change unnamed enum to constant integers --- src/Entities/Player.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index e26808bfc..f345a0207 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,13 @@ class cPlayer : typedef cPawn super; public: - enum - { - MAX_HEALTH = 20, - MAX_FOOD_LEVEL = 20, - EATING_TICKS = 30, ///< Number of ticks it takes to eat an item - } ; + static const int MAX_HEALTH = 20; + + static const int MAX_FOOD_LEVEL = 20; + + /** Number of ticks it takes to eat an item */ + static const int EATING_TICKS = 30; + // tolua_end CLASS_PROTODEF(cPlayer) -- cgit v1.2.3 From a7eb4032ee32f8299857ccdfc4ad9f45227abb05 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 10 Aug 2014 17:13:14 -0700 Subject: Fixed tolua error with static initialization --- src/Entities/Player.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f345a0207..d3ed1ef9d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,12 @@ class cPlayer : typedef cPawn super; public: - static const int MAX_HEALTH = 20; + static const int MAX_HEALTH; - static const int MAX_FOOD_LEVEL = 20; + static const int MAX_FOOD_LEVEL; /** Number of ticks it takes to eat an item */ - static const int EATING_TICKS = 30; + static const int EATING_TICKS; // tolua_end -- cgit v1.2.3 From 949aa2f3836cfa2b64ab5104b4b4103c4e2ad537 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 19 Aug 2014 17:34:11 +0200 Subject: cPlayer reads ranks from cRankManager. --- src/Entities/Player.h | 53 +++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index d3ed1ef9d..0ae014eeb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -236,24 +236,20 @@ public: // tolua_end - typedef std::list< cGroup* > GroupList; - typedef std::list< std::string > StringList; + bool HasPermission(const AString & a_Permission); // tolua_export - /** Adds a player to existing group or creates a new group when it doesn't exist */ - void AddToGroup( const AString & a_GroupName); // tolua_export - - /** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */ - void RemoveFromGroup( const AString & a_GroupName); // tolua_export - - bool HasPermission( const AString & a_Permission); // tolua_export - const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << - StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << - bool IsInGroup( const AString & a_Group); // tolua_export + /** Returns true iff a_Permission matches the a_Template. + A match is defined by either being exactly the same, or each sub-item matches until there's a wildcard in a_Template. + Ie. {"a", "b", "c"} matches {"a", "b", "*"} but doesn't match {"a", "b"} */ + static bool PermissionMatches(const AStringVector & a_Permission, const AStringVector & a_Template); // Exported in ManualBindings with AString params + + /** Returns all the permissions that the player has assigned to them. */ + const AStringVector & GetPermissions(void) { return m_Permissions; } // Exported in ManualBindings.cpp // tolua_begin - /** Returns the full color code to use for this player, based on their primary group or set in m_Color. - The returned value includes the cChatColor::Delimiter. */ + /** Returns the full color code to use for this player, based on their rank. + The returned value either is empty, or includes the cChatColor::Delimiter. */ AString GetColor(void) const; /** tosses the item in the selected hotbar slot */ @@ -347,8 +343,6 @@ public: */ bool LoadFromFile(const AString & a_FileName, cWorldPtr & a_World); - void LoadPermissionsFromDisk(void); // tolua_export - const AString & GetLoadedWorldName() { return m_LoadedWorldName; } void UseEquippedItem(int a_Amount = 1); @@ -424,6 +418,11 @@ public: // tolua_end + /** (Re)loads the rank and permissions from the cRankManager. + Expects the m_UUID member to be valid. + Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */ + void LoadRank(void); + // cEntity overrides: virtual bool IsCrouched (void) const { return m_IsCrouched; } virtual bool IsSprinting(void) const { return m_IsSprinting; } @@ -432,12 +431,22 @@ public: virtual void Detach(void); protected: - typedef std::map< std::string, bool > PermissionMap; - PermissionMap m_ResolvedPermissions; - PermissionMap m_Permissions; - GroupList m_ResolvedGroups; - GroupList m_Groups; + typedef std::vector > AStringVectorVector; + + /** The name of the rank assigned to this player. */ + AString m_Rank; + + /** All the permissions that this player has, based on their rank. */ + AStringVector m_Permissions; + + /** All the permissions that this player has, based on their rank, split into individual dot-delimited parts. + This is used mainly by the HasPermission() function to optimize the lookup. */ + AStringVectorVector m_SplitPermissions; + + // Message visuals: + AString m_MsgPrefix, m_MsgSuffix; + AString m_MsgNameColorCode; AString m_PlayerName; AString m_LoadedWorldName; @@ -482,8 +491,6 @@ protected: /** The player's last saved bed position */ Vector3i m_LastBedPos; - char m_Color; - eGameMode m_GameMode; AString m_IP; -- cgit v1.2.3 From 1b97e4e6ff202f63f5e6ae8a6130536be17b754a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 20 Aug 2014 20:37:51 +0200 Subject: cPlayer: Exported the LoadRank function to Lua API. --- src/Entities/Player.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 0ae014eeb..bfafcb7fb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -416,13 +416,13 @@ public: /** Returns the UUID (short format) that has been read from the client, or empty string if not available. */ const AString & GetUUID(void) const { return m_UUID; } - // tolua_end - /** (Re)loads the rank and permissions from the cRankManager. Expects the m_UUID member to be valid. Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */ void LoadRank(void); + // tolua_end + // cEntity overrides: virtual bool IsCrouched (void) const { return m_IsCrouched; } virtual bool IsSprinting(void) const { return m_IsSprinting; } -- cgit v1.2.3 From 263ea5464b6761f7442d642006f9b9728b153ec1 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 21 Aug 2014 15:53:22 +0200 Subject: Removed last remnant of cGroup. --- src/Entities/Player.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index bfafcb7fb..9821cc6d9 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -13,7 +13,6 @@ -class cGroup; class cWindow; class cClientHandle; class cTeam; -- cgit v1.2.3 From 1bb4d7941267ee55cdf7f35fa6a0055521115960 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 2 Sep 2014 19:12:35 +0200 Subject: Added SetCustomName() to players. --- src/Entities/Player.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 9821cc6d9..da64bd64f 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -251,6 +251,9 @@ public: The returned value either is empty, or includes the cChatColor::Delimiter. */ AString GetColor(void) const; + /** Returns the name that is used in the tablist. */ + AString GetTabListName(void) const; + /** tosses the item in the selected hotbar slot */ void TossEquippedItem(char a_Amount = 1); @@ -398,6 +401,16 @@ public: /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); + /** Is a custom name for this player set? */ + bool HasCustomName(void) const { return !m_CustomName.empty(); } + + /** Returns the custom name of this player. If the player hasn't a custom name, it will return an empty string. */ + const AString & GetCustomName(void) const { return m_CustomName; } + + /** Sets the custom name of this player. If you want to disable the custom name, simply set an empty string. + The custom name will be used in the tab-list, in the player nametag and in the tab-completion. */ + void SetCustomName(const AString & a_CustomName); + /** Gets the last position that the player slept in This is initialised to the world spawn point if the player has not slept in a bed as of yet */ @@ -562,6 +575,8 @@ protected: If no ClientHandle is given, the UUID is initialized to empty. */ AString m_UUID; + AString m_CustomName; + /** Sets the speed and sends it to the client, so that they are forced to move so. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override; -- cgit v1.2.3 From 079634d18cf63abad05db0fda9a4510aa75c0522 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 2 Sep 2014 19:20:59 +0200 Subject: Added the new functions to APIDump. --- src/Entities/Player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index da64bd64f..49380c776 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -401,7 +401,7 @@ public: /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); - /** Is a custom name for this player set? */ + /** Returns true if the player has a custom name. */ bool HasCustomName(void) const { return !m_CustomName.empty(); } /** Returns the custom name of this player. If the player hasn't a custom name, it will return an empty string. */ -- cgit v1.2.3 From 8dedbe4db52ee434595d9bdb32b3850a6c1e175f Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:02:27 +0200 Subject: Preparing 1.8 changes Added Spectator Gamemode --- src/Entities/Player.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 9821cc6d9..d64dd6b99 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -171,6 +171,9 @@ public: /** Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world */ bool IsGameModeAdventure(void) const; + /** Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world */ + bool IsGameModeSpectator(void) const; + AString GetIP(void) const { return m_IP; } // tolua_export /** Returns the associated team, NULL if none */ -- cgit v1.2.3 From fd11b574bdc31721b007b31f1734f9ea69a2cd94 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 1 Oct 2014 17:24:02 +0200 Subject: cPlayer: Removed useless functions from the Lua API. --- src/Entities/Player.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index ffd0b7e03..22d6a2ae2 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -182,11 +182,11 @@ public: /** Sets the player team, NULL if none */ void SetTeam(cTeam * a_Team); + // tolua_end + /** Forces the player to query the scoreboard for his team */ cTeam * UpdateTeam(void); - // tolua_end - /** Return the associated statistic and achievement manager. */ cStatManager & GetStatManager() { return m_Stats; } @@ -421,9 +421,13 @@ public: /** Sets the player's bed (home) position */ void SetBedPos(const Vector3i & a_Pos) { m_LastBedPos = a_Pos; } + + // tolua_end /** Update movement-related statistics. */ void UpdateMovementStats(const Vector3d & a_DeltaPos); + + // tolua_begin /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } -- cgit v1.2.3