From 2b943610598c193a349107fd9345d321724aff98 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 19 Jan 2014 14:20:57 +0200 Subject: Basic scoreboard implementation --- src/Entities/Player.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index bf3ca08e8..52e629dc3 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -13,6 +13,7 @@ class cGroup; class cWindow; class cClientHandle; +class cTeam; @@ -153,6 +154,12 @@ public: AString GetIP(void) const { return m_IP; } // tolua_export + /// Returns the associated team, NULL if none + cTeam* GetTeam(void) { return m_Team; } // tolua_export + + /// Sets the player team, NULL if none + void SetTeam(cTeam* a_Team); + // tolua_end void SetIP(const AString & a_IP); @@ -456,6 +463,8 @@ protected: int m_FloaterID; + cTeam* m_Team; + void ResolvePermissions(void); @@ -463,7 +472,7 @@ protected: virtual void Destroyed(void); - /// Filters out damage for creative mode + /// Filters out damage for creative mode/friendly fire virtual void DoTakeDamage(TakeDamageInfo & TDI) override; /// Called in each tick to handle food-related processing -- cgit v1.2.3 From 7728f4bcbee7fa61f005c7b972685deb4bf04f2a Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 20 Jan 2014 16:10:39 +0200 Subject: Scoreboard deserialization --- src/Entities/Player.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 52e629dc3..52ba2065c 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -155,10 +155,13 @@ public: AString GetIP(void) const { return m_IP; } // tolua_export /// Returns the associated team, NULL if none - cTeam* GetTeam(void) { return m_Team; } // tolua_export + cTeam * GetTeam(void) { return m_Team; } // tolua_export /// Sets the player team, NULL if none - void SetTeam(cTeam* a_Team); + void SetTeam(cTeam * a_Team); + + /// Forces the player to query the scoreboard for his team + cTeam * UpdateTeam(void); // tolua_end -- cgit v1.2.3 From 41b05416c75b9cbe31406f04b58b5da9892872f8 Mon Sep 17 00:00:00 2001 From: Mike Hunsinger Date: Thu, 23 Jan 2014 00:27:39 -0700 Subject: Split TossItem into three Toss functions (Held, Equipped and Pickup) --- src/Entities/Player.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index bf3ca08e8..71033ab77 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -214,7 +214,14 @@ public: /// Returns the full color code to use for this player, based on their primary group or set in m_Color AString GetColor(void) const; - void TossItem(bool a_bDraggingItem, char a_Amount = 1, short a_CreateType = 0, short a_CreateHealth = 0); + // tosses the item in the selected hotbar slot + void TossEquippedItem(char a_Amount = 1); + + // tosses the item held in hand (when in UI windows) + void TossHeldItem(char a_Amount = 1); + + // tosses a pickup newly created from a_Item + void TossPickup(const cItem & a_Item); /// Heals the player by the specified amount of HPs (positive only); sends health update void Heal(int a_Health); -- cgit v1.2.3 From 11948b1d4b98e0147217eef2928a2391c2d8e958 Mon Sep 17 00:00:00 2001 From: Mike Hunsinger Date: Thu, 23 Jan 2014 19:54:00 -0700 Subject: Fixed spacing and doxycomments. --- 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 71033ab77..7925e70a1 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -214,13 +214,13 @@ public: /// Returns the full color code to use for this player, based on their primary group or set in m_Color AString GetColor(void) const; - // tosses the item in the selected hotbar slot + /** tosses the item in the selected hotbar slot */ void TossEquippedItem(char a_Amount = 1); - // tosses the item held in hand (when in UI windows) + /** tosses the item held in hand (when in UI windows) */ void TossHeldItem(char a_Amount = 1); - // tosses a pickup newly created from a_Item + /** tosses a pickup newly created from a_Item */ void TossPickup(const cItem & a_Item); /// Heals the player by the specified amount of HPs (positive only); sends health update -- cgit v1.2.3 From fd7fc7e59efebd6b28012c8e8433f53ac853c555 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 24 Jan 2014 23:58:51 +0000 Subject: All mobs now drown (fixes #54) * Implemented mob drowning * Iron Golems and squids are excluded --- src/Entities/Player.h | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 46d0de69d..449df978f 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -31,8 +31,6 @@ public: MAX_HEALTH = 20, MAX_FOOD_LEVEL = 20, EATING_TICKS = 30, ///< Number of ticks it takes to eat an item - MAX_AIR_LEVEL = 300, - DROWNING_TICKS = 10, //number of ticks per heart of damage } ; // tolua_end @@ -241,8 +239,6 @@ public: int GetFoodTickTimer (void) const { return m_FoodTickTimer; } double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; } int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; } - - int GetAirLevel (void) const { return m_AirLevel; } /// Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); } @@ -353,12 +349,6 @@ public: /// If true the player can fly even when he's not in creative. void SetCanFly(bool a_CanFly); - /// Returns whether the player is swimming or not - virtual bool IsSwimming(void) const{ return m_IsSwimming; } - - /// Return whether the player is under water or not - virtual bool IsSubmerged(void) const{ return m_IsSubmerged; } - /// Returns wheter the player can fly or not. virtual bool CanFly(void) const { return m_CanFly; } // tolua_end @@ -389,12 +379,6 @@ protected: XP_TO_LEVEL30 = 825 } ; - /// Player's air level (for swimming) - int m_AirLevel; - - /// used to time ticks between damage taken via drowning/suffocation - int m_AirTickTimer; - bool m_bVisible; // Food-related variables: @@ -490,12 +474,6 @@ protected: /// Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. void HandleFloater(void); - - /// Called in each tick to handle air-related processing i.e. drowning - void HandleAir(); - - /// Called once per tick to set IsSwimming and IsSubmerged - void SetSwimState(cChunk & a_Chunk); /// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) void ApplyFoodExhaustionFromMovement(); -- cgit v1.2.3 From 7468ba0f107ed01275f346c87ff5bb265dbbff3d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 25 Jan 2014 19:02:13 +0000 Subject: Implemented fall damage for mobs + Implemented mobile fall damage * Formatting fixes + Defined new Position->Integer macros --- 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 449df978f..50f7560d6 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -415,7 +415,7 @@ protected: float m_LastBlockActionTime; int m_LastBlockActionCnt; eGameMode m_GameMode; - std::string m_IP; + AString m_IP; /// The item being dragged by the cursor while in a UI window cItem m_DraggingItem; -- cgit v1.2.3 From 3583a58cf7bbeb867e568f4210f270cd5058e9f3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 3 Feb 2014 22:46:56 +0000 Subject: Added SendMessageXXX() to cPlayer As requested by @bearbin, one no longer needs to download a file that links to Core. The server does it! Hopefully this encourages standards compliance. --- 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 50f7560d6..764b47ae0 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -196,6 +196,9 @@ public: cClientHandle * GetClientHandle(void) const { return m_ClientHandle; } void SendMessage(const AString & a_Message); + void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); } + void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } + void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } -- cgit v1.2.3 From 9eeeb91fa6e3df67aa1dc8aae54da8e6631d25be Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 4 Feb 2014 22:39:57 +0000 Subject: Added more SendMessageXXX() functions --- src/Entities/Player.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 764b47ae0..784aac327 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -199,6 +199,10 @@ public: void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); } void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } + void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); } + void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } + void SendMessageDeath(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtDeath)); } + void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); } const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } -- cgit v1.2.3 From ea2ce1595f51c141342991378c372529f26434c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 4 Feb 2014 23:27:13 +0000 Subject: Fixed annoying creative on fire bug --- 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 784aac327..925011c9c 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -475,6 +475,9 @@ protected: /// Filters out damage for creative mode/friendly fire virtual void DoTakeDamage(TakeDamageInfo & TDI) override; + + /** Stops players from burning in creative mode */ + virtual void TickBurning(cChunk & a_Chunk) override; /// Called in each tick to handle food-related processing void HandleFood(void); -- cgit v1.2.3 From 89ec774fd60630b167185fc2526655880a975752 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 5 Feb 2014 20:20:11 +0100 Subject: Removed deprecated HasCommand function --- 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 50f7560d6..5c56c927a 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -211,7 +211,6 @@ public: /// Removes a player from the group, resolves permissions and group inheritance (case sensitive) void RemoveFromGroup( const AString & a_GroupName ); // tolua_export - bool CanUseCommand( const AString & a_Command ); // tolua_export bool HasPermission( const AString & a_Permission ); // tolua_export const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS << StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS << -- cgit v1.2.3 From 3450f0ca42c8f72920045709d0a57d5443b086a7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 5 Feb 2014 23:24:02 +0000 Subject: Added more chat functions --- 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 925011c9c..f2830a0c7 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -201,7 +201,6 @@ public: void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); } void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } - void SendMessageDeath(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtDeath)); } void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); } const AString & GetName(void) const { return m_PlayerName; } -- cgit v1.2.3 From 88a64ec40df87f21a89de43fe8bb78f10ee7eeb7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 7 Feb 2014 18:58:52 +0000 Subject: Improved chat messaging functions * Moved string manipulation into cClientHandle and therefore... + Added configuration option for prefixes. * Cleaned up code. * Updated documentation for API. --- src/Entities/Player.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f2830a0c7..869e67775 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -5,6 +5,7 @@ #include "../Inventory.h" #include "../Defines.h" #include "../World.h" +#include "../ClientHandle.h" @@ -195,13 +196,13 @@ public: cClientHandle * GetClientHandle(void) const { return m_ClientHandle; } - void SendMessage(const AString & a_Message); - void SendMessageInfo(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtInformation)); } - void SendMessageFailure(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } - void SendMessageSuccess(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtSuccess)); } - void SendMessageWarning(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtWarning)); } - void SendMessageFatal(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtFailure)); } - void SendMessagePrivateMsg(const AString & a_Message) { SendMessage(AppendChatEpithet(a_Message, mtPrivateMessage)); } + void SendMessage (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtCustom); } + void SendMessageInfo (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtInformation); } + void SendMessageFailure (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); } + void SendMessageSuccess (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtSuccess); } + void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); } + void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); } + void SendMessagePrivateMsg(const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); } const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } -- cgit v1.2.3 From 0f1f7583aeea65335b2ee051585a857b1142a927 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 15 Feb 2014 23:16:44 +0100 Subject: Implemented cCompositeChat. This allows plugins to send composite chat messages, containing URLs, commands to run and cmdline suggestions. Fixes #678. --- src/Entities/Player.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 7db9544cb..53e4b56db 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -203,6 +203,7 @@ public: void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); } void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); } void SendMessagePrivateMsg(const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); } + void SendMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChat(a_Message); } const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } -- cgit v1.2.3 From f3bd288f020a8f004179513c0e260ac0f2855767 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 14 Feb 2014 22:49:23 +0100 Subject: Add Exp Bottle Effects --- src/Entities/Player.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 53e4b56db..838f0301d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -208,6 +208,8 @@ public: const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } + void PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch); + // tolua_end typedef std::list< cGroup* > GroupList; -- cgit v1.2.3 From 4908b6f500aa31ca550536c7e5a49e660ff72b65 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 16 Feb 2014 13:37:36 +0000 Subject: Fixed minor formatting issues from #682 - Removed unused PlaySoundEffect * Simplified and parenthesised code --- src/Entities/Player.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 838f0301d..53e4b56db 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -208,8 +208,6 @@ public: const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } - void PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch); - // tolua_end typedef std::list< cGroup* > GroupList; -- cgit v1.2.3 From ea55a22a71a6fd46877bc4b6b56d6205dd20608f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 16 Feb 2014 23:51:32 +0100 Subject: Links sent via chat messages are clickable. Fixes #658. --- src/Entities/Player.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 53e4b56db..a795bb9eb 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -226,7 +226,8 @@ public: // tolua_begin - /// Returns the full color code to use for this player, based on their primary group or set in m_Color + /** 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. */ AString GetColor(void) const; /** tosses the item in the selected hotbar slot */ -- cgit v1.2.3 From c05a1db88d2a81b5aa93881c9791bcaadaad6304 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 1 Mar 2014 21:24:36 +0000 Subject: CheckBlockInteractionsRate() fixed & enabled --- src/Entities/Player.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index a795bb9eb..f9404dfaf 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -50,7 +50,7 @@ public: /// Returns the curently equipped weapon; empty item if none virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } - /// Returns the currently equipped helmet; empty item if nonte + /// Returns the currently equipped helmet; empty item if none virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); } /// Returns the currently equipped chestplate; empty item if none @@ -165,11 +165,6 @@ public: // tolua_end void SetIP(const AString & a_IP); - - float GetLastBlockActionTime() { return m_LastBlockActionTime; } - int GetLastBlockActionCnt() { return m_LastBlockActionCnt; } - void SetLastBlockActionCnt( int ); - void SetLastBlockActionTime(); // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); @@ -416,12 +411,8 @@ protected: cWindow * m_CurrentWindow; cWindow * m_InventoryWindow; - float m_TimeLastPickupCheck; - char m_Color; - float m_LastBlockActionTime; - int m_LastBlockActionCnt; eGameMode m_GameMode; AString m_IP; -- cgit v1.2.3 From b64e9fb7f52e4a2b75b49413fdc2194132885370 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 9 Mar 2014 00:17:23 +0000 Subject: Beds now work properly fixes #707 Also fixes FS392 Conflicts: src/Blocks/WorldInterface.h src/ClientHandle.cpp --- src/Entities/Player.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index a795bb9eb..83a553821 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -275,6 +275,9 @@ public: /// Returns true if the player is currently flying. bool IsFlying(void) const { return m_IsFlying; } + /** Returns if a player is sleeping in a bed */ + bool IsInBed(void) const { return m_bIsInBed; } + /// returns true if the player has thrown out a floater. bool IsFishing(void) const { return m_IsFishing; } @@ -283,6 +286,9 @@ public: int GetFloaterID(void) const { return m_FloaterID; } // tolua_end + + /** Sets a player's in-bed state; we can't be sure plugins will keep this value updated, so no exporting */ + void SetIsInBed(bool a_Flag) { m_bIsInBed = a_Flag; } /// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet void StartEating(void); @@ -376,8 +382,8 @@ protected: GroupList m_ResolvedGroups; GroupList m_Groups; - std::string m_PlayerName; - std::string m_LoadedWorldName; + AString m_PlayerName; + AString m_LoadedWorldName; /// Xp Level stuff enum @@ -465,7 +471,7 @@ protected: int m_FloaterID; - cTeam* m_Team; + cTeam * m_Team; @@ -488,6 +494,11 @@ protected: /// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) void ApplyFoodExhaustionFromMovement(); + + /** Flag representing whether the player is currently in a bed + Set by a right click on unoccupied bed, unset by a time fast forward or teleport */ + bool m_bIsInBed; + } ; // tolua_export -- cgit v1.2.3 From 64d9390069650bbbc1850d5602b9854a1c1a7257 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 20 Mar 2014 15:45:42 +0100 Subject: Rewritten player speeds to be relative unit-less. Value of 1 means "default speed", 2 means "double the speed", 0.5 means "half the speed". This allows for easier plugins and is more future-proof. --- src/Entities/Player.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index c25053c21..451dde8fc 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -331,13 +331,13 @@ public: // tolua_begin - /// Returns the current maximum speed, as reported in the 1.6.1+ protocol (takes current sprinting state into account) + /// Returns the current relative maximum speed (takes current sprinting state into account) double GetMaxSpeed(void) const; - /// Gets the normal maximum speed, as reported in the 1.6.1+ protocol, in the protocol units + /// Gets the normal relative maximum speed double GetNormalMaxSpeed(void) const { return m_NormalMaxSpeed; } - /// Gets the sprinting maximum speed, as reported in the 1.6.1+ protocol, in the protocol units + /// Gets the sprinting relative maximum speed double GetSprintingMaxSpeed(void) const { return m_SprintingMaxSpeed; } /// Sets the normal maximum speed, as reported in the 1.6.1+ protocol. Sends the update to player, if needed. @@ -432,10 +432,14 @@ protected: cSlotNums m_InventoryPaintSlots; - /// Max speed, in ENTITY_PROPERTIES packet's units, when the player is walking. 0.1 by default + /** Max speed, relative to the game default. + 1 means regular speed, 2 means twice as fast, 0.5 means half-speed. + Default value is 1. */ double m_NormalMaxSpeed; - /// Max speed, in ENTITY_PROPERTIES packet's units, when the player is sprinting. 0.13 by default + /** Max speed, relative to the game default max speed. + 1 means regular speed, 2 means twice as fast, 0.5 means half-speed. + Default value is 1.3 */ double m_SprintingMaxSpeed; bool m_IsCrouched; -- cgit v1.2.3 From b370cacf0c0e1234aef1efd9c442ff335a379258 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 20 Mar 2014 16:14:40 +0100 Subject: Plugins can set flying speed. --- src/Entities/Player.h | 160 +++++++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 72 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 451dde8fc..ea32dbfb9 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -47,19 +47,19 @@ public: virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }; - /// Returns the curently equipped weapon; empty item if none + /** Returns the curently equipped weapon; empty item if none */ virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } - /// Returns the currently equipped helmet; empty item if none + /** Returns the currently equipped helmet; empty item if none */ virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); } - /// Returns the currently equipped chestplate; empty item if none + /** Returns the currently equipped chestplate; empty item if none */ virtual cItem GetEquippedChestplate(void) const override { return m_Inventory.GetEquippedChestplate(); } - /// Returns the currently equipped leggings; empty item if none + /** Returns the currently equipped leggings; empty item if none */ virtual cItem GetEquippedLeggings(void) const override { return m_Inventory.GetEquippedLeggings(); } - /// Returns the currently equipped boots; empty item if none + /** Returns the currently equipped boots; empty item if none */ virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); } @@ -77,36 +77,41 @@ public: */ short DeltaExperience(short a_Xp_delta); - /// Gets the experience total - XpTotal for score on death + /** Gets the experience total - XpTotal for score on death */ inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; } - /// Gets the currrent experience + /** Gets the currrent experience */ inline short GetCurrentXp(void) { return m_CurrentXp; } - /// Gets the current level - XpLevel + /** Gets the current level - XpLevel */ short GetXpLevel(void); - /// Gets the experience bar percentage - XpP + /** Gets the experience bar percentage - XpP */ float GetXpPercentage(void); - /// Caculates the amount of XP needed for a given level, ref: http://minecraft.gamepedia.com/XP + /** Caculates the amount of XP needed for a given level + Ref: http://minecraft.gamepedia.com/XP + */ static short XpForLevel(short int a_Level); - /// inverse of XpForLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations + /** Inverse of XpForLevel + Ref: http://minecraft.gamepedia.com/XP + values are as per this with pre-calculations + */ static short CalcLevelFromXp(short int a_CurrentXp); // tolua_end - /// Starts charging the equipped bow + /** Starts charging the equipped bow */ void StartChargingBow(void); - /// Finishes charging the current bow. Returns the number of ticks for which the bow has been charged + /** Finishes charging the current bow. Returns the number of ticks for which the bow has been charged */ int FinishChargingBow(void); - /// Cancels the current bow charging + /** Cancels the current bow charging */ void CancelChargingBow(void); - /// Returns true if the player is currently charging the bow + /** Returns true if the player is currently charging the bow */ bool IsChargingBow(void) const { return m_IsChargingBow; } void SetTouchGround( bool a_bTouchGround ); @@ -124,16 +129,16 @@ public: // tolua_begin - /// Returns the position where projectiles thrown by this player should start, player eye position + adjustment + /** Returns the position where projectiles thrown by this player should start, player eye position + adjustment */ Vector3d GetThrowStartPos(void) const; - /// Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff. + /** Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff. */ Vector3d GetThrowSpeed(double a_SpeedCoeff) const; - /// Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable + /** Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */ eGameMode GetGameMode(void) const { return m_GameMode; } - /// Returns the current effective gamemode (inherited gamemode is resolved before returning) + /** Returns the current effective gamemode (inherited gamemode is resolved before returning) */ eGameMode GetEffectiveGameMode(void) const { return (m_GameMode == gmNotSet) ? m_World->GetGameMode() : m_GameMode; } /** Sets the gamemode for the player. @@ -142,24 +147,24 @@ public: */ void SetGameMode(eGameMode a_GameMode); - /// Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world + /** Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world */ bool IsGameModeCreative(void) const; - /// Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world + /** Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world */ bool IsGameModeSurvival(void) const; - /// Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world + /** Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world */ bool IsGameModeAdventure(void) const; AString GetIP(void) const { return m_IP; } // tolua_export - /// Returns the associated team, NULL if none + /** Returns the associated team, NULL if none */ cTeam * GetTeam(void) { return m_Team; } // tolua_export - /// Sets the player team, NULL if none + /** Sets the player team, NULL if none */ void SetTeam(cTeam * a_Team); - /// Forces the player to query the scoreboard for his team + /** Forces the player to query the scoreboard for his team */ cTeam * UpdateTeam(void); // tolua_end @@ -169,24 +174,24 @@ public: // Sets the current gamemode, doesn't check validity, doesn't send update packets to client void LoginSetGameMode(eGameMode a_GameMode); - /// Forces the player to move in the given direction. + /** Forces the player to move in the given direction. */ void ForceSetSpeed(Vector3d a_Direction); // tolua_export - /// Tries to move to a new position, with attachment-related checks (y == -999) + /** Tries to move to a new position, with attachment-related checks (y == -999) */ void MoveTo(const Vector3d & a_NewPos); // tolua_export cWindow * GetWindow(void) { return m_CurrentWindow; } // tolua_export const cWindow * GetWindow(void) const { return m_CurrentWindow; } - /// Opens the specified window; closes the current one first using CloseWindow() + /** Opens the specified window; closes the current one first using CloseWindow() */ void OpenWindow(cWindow * a_Window); // Exported in ManualBindings.cpp // tolua_begin - /// Closes the current window, resets current window to m_InventoryWindow. A plugin may refuse the closing if a_CanRefuse is true + /** Closes the current window, resets current window to m_InventoryWindow. A plugin may refuse the closing if a_CanRefuse is true */ void CloseWindow(bool a_CanRefuse = true); - /// Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow + /** Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow */ void CloseWindowIfID(char a_WindowID, bool a_CanRefuse = true); cClientHandle * GetClientHandle(void) const { return m_ClientHandle; } @@ -208,10 +213,10 @@ public: typedef std::list< cGroup* > GroupList; typedef std::list< std::string > StringList; - /// Adds a player to existing group or creates a new group when it doesn't exist + /** 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) + /** 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 @@ -234,7 +239,7 @@ public: /** tosses a pickup newly created from a_Item */ void TossPickup(const cItem & a_Item); - /// Heals the player by the specified amount of HPs (positive only); sends health update + /** Heals the player by the specified amount of HPs (positive only); sends health update */ void Heal(int a_Health); int GetFoodLevel (void) const { return m_FoodLevel; } @@ -243,7 +248,7 @@ public: double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; } int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; } - /// Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore + /** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */ bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); } void SetFoodLevel (int a_FoodLevel); @@ -252,28 +257,28 @@ public: void SetFoodExhaustionLevel (double a_FoodExhaustionLevel); void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining); - /// Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" + /** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */ bool Feed(int a_Food, double a_Saturation); - /// Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values. + /** Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values. */ void AddFoodExhaustion(double a_Exhaustion) { m_FoodExhaustionLevel += a_Exhaustion; } - /// Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two + /** Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two */ void FoodPoison(int a_NumTicks); - /// Returns true if the player is currently in the process of eating the currently equipped item + /** Returns true if the player is currently in the process of eating the currently equipped item */ bool IsEating(void) const { return (m_EatingFinishTick >= 0); } - /// Returns true if the player is currently flying. + /** Returns true if the player is currently flying. */ bool IsFlying(void) const { return m_IsFlying; } /** Returns if a player is sleeping in a bed */ bool IsInBed(void) const { return m_bIsInBed; } - /// returns true if the player has thrown out a floater. + /** returns true if the player has thrown out a floater. */ bool IsFishing(void) const { return m_IsFishing; } void SetIsFishing(bool a_IsFishing, int a_FloaterID = -1) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; } @@ -285,13 +290,13 @@ public: /** Sets a player's in-bed state; we can't be sure plugins will keep this value updated, so no exporting */ void SetIsInBed(bool a_Flag) { m_bIsInBed = a_Flag; } - /// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet + /** Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet */ void StartEating(void); - /// Finishes eating the currently equipped item. Consumes the item, updates health and broadcasts the packets + /** Finishes eating the currently equipped item. Consumes the item, updates health and broadcasts the packets */ void FinishEating(void); - /// Aborts the current eating operation + /** Aborts the current eating operation */ void AbortEating(void); virtual void KilledBy(cEntity * a_Killer) override; @@ -320,45 +325,51 @@ public: cItem & GetDraggingItem(void) {return m_DraggingItem; } // In UI windows, when inventory-painting: - /// Clears the list of slots that are being inventory-painted. To be used by cWindow only + /** Clears the list of slots that are being inventory-painted. To be used by cWindow only */ void ClearInventoryPaintSlots(void); - /// Adds a slot to the list for inventory painting. To be used by cWindow only + /** Adds a slot to the list for inventory painting. To be used by cWindow only */ void AddInventoryPaintSlot(int a_SlotNum); - /// Returns the list of slots currently stored for inventory painting. To be used by cWindow only + /** Returns the list of slots currently stored for inventory painting. To be used by cWindow only */ const cSlotNums & GetInventoryPaintSlots(void) const; // tolua_begin - /// Returns the current relative maximum speed (takes current sprinting state into account) + /** Returns the current relative maximum speed (takes current sprinting / flying state into account) */ double GetMaxSpeed(void) const; - /// Gets the normal relative maximum speed + /** Gets the normal relative maximum speed */ double GetNormalMaxSpeed(void) const { return m_NormalMaxSpeed; } - /// Gets the sprinting relative maximum speed + /** Gets the sprinting relative maximum speed */ double GetSprintingMaxSpeed(void) const { return m_SprintingMaxSpeed; } - /// Sets the normal maximum speed, as reported in the 1.6.1+ protocol. Sends the update to player, if needed. + /** Gets the flying relative maximum speed */ + double GetFlyingMaxSpeed(void) const { return m_FlyingMaxSpeed; } + + /** Sets the normal relative maximum speed. Sends the update to player, if needed. */ void SetNormalMaxSpeed(double a_Speed); - /// Sets the sprinting maximum speed, as reported in the 1.6.1+ protocol. Sends the update to player, if needed. + /** Sets the sprinting relative maximum speed. Sends the update to player, if needed. */ void SetSprintingMaxSpeed(double a_Speed); - /// Sets the crouch status, broadcasts to all visible players + /** Sets the flying relative maximum speed. Sends the update to player, if needed. */ + void SetFlyingMaxSpeed(double a_Speed); + + /** Sets the crouch status, broadcasts to all visible players */ void SetCrouch(bool a_IsCrouched); - /// Starts or stops sprinting, sends the max speed update to the client, if needed + /** Starts or stops sprinting, sends the max speed update to the client, if needed */ void SetSprint(bool a_IsSprinting); - /// Flags the player as flying + /** Flags the player as flying */ void SetFlying(bool a_IsFlying); - /// If true the player can fly even when he's not in creative. + /** If true the player can fly even when he's not in creative. */ void SetCanFly(bool a_CanFly); - /// Returns wheter the player can fly or not. + /** Returns wheter the player can fly or not. */ virtual bool CanFly(void) const { return m_CanFly; } // tolua_end @@ -380,7 +391,7 @@ protected: AString m_PlayerName; AString m_LoadedWorldName; - /// Xp Level stuff + /** Xp Level stuff */ enum { XP_TO_LEVEL15 = 255, @@ -391,22 +402,22 @@ protected: bool m_bVisible; // Food-related variables: - /// Represents the food bar, one point equals half a "drumstick" + /** Represents the food bar, one point equals half a "drumstick" */ int m_FoodLevel; - /// "Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel + /** "Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel */ double m_FoodSaturationLevel; - /// Count-up to the healing or damaging action, based on m_FoodLevel + /** Count-up to the healing or damaging action, based on m_FoodLevel */ int m_FoodTickTimer; - /// A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little + /** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */ double m_FoodExhaustionLevel; - /// Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned + /** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */ int m_FoodPoisonedTicksRemaining; - /// Last position that has been recorded for food-related processing: + /** Last position that has been recorded for food-related processing: */ Vector3d m_LastFoodPos; float m_LastJumpHeight; @@ -422,7 +433,7 @@ protected: eGameMode m_GameMode; AString m_IP; - /// The item being dragged by the cursor while in a UI window + /** The item being dragged by the cursor while in a UI window */ cItem m_DraggingItem; long long m_LastPlayerListTime; @@ -437,11 +448,16 @@ protected: Default value is 1. */ double m_NormalMaxSpeed; - /** Max speed, relative to the game default max speed. + /** Max speed, relative to the game default max speed, when sprinting. 1 means regular speed, 2 means twice as fast, 0.5 means half-speed. - Default value is 1.3 */ + Default value is 1.3. */ double m_SprintingMaxSpeed; + /** Max speed, relative to the game default flying max speed, when flying. + 1 means regular speed, 2 means twice as fast, 0.5 means half-speed. + Default value is 1. */ + double m_FlyingMaxSpeed; + bool m_IsCrouched; bool m_IsSprinting; bool m_IsFlying; @@ -451,10 +467,10 @@ protected: bool m_CanFly; // If this is true the player can fly. Even if he is not in creative. - /// The world tick in which eating will be finished. -1 if not eating + /** The world tick in which eating will be finished. -1 if not eating */ Int64 m_EatingFinishTick; - /// Player Xp level + /** Player Xp level */ short int m_LifetimeTotalXp; short int m_CurrentXp; @@ -475,19 +491,19 @@ protected: virtual void Destroyed(void); - /// Filters out damage for creative mode/friendly fire + /** Filters out damage for creative mode/friendly fire */ virtual void DoTakeDamage(TakeDamageInfo & TDI) override; /** Stops players from burning in creative mode */ virtual void TickBurning(cChunk & a_Chunk) override; - /// Called in each tick to handle food-related processing + /** Called in each tick to handle food-related processing */ void HandleFood(void); - /// Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. + /** Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. */ void HandleFloater(void); - /// Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) + /** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */ void ApplyFoodExhaustionFromMovement(); /** Flag representing whether the player is currently in a bed -- cgit v1.2.3 From 1cab52f86799b98940da910e84e207b6037a5cd2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Apr 2014 23:06:47 +0200 Subject: Added cPlayer:SendRotation() API function. --- src/Entities/Player.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index ea32dbfb9..05377a117 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -129,6 +129,12 @@ public: // tolua_begin + /** Sends the "look" packet to the player, forcing them to set their rotation to the specified values. + a_YawDegrees is clipped to range [-180, +180), + a_PitchDegrees is clipped to range [-180, +180) but the client only uses [-90, +90] + */ + void SendRotation(double a_YawDegrees, double a_PitchDegrees); + /** Returns the position where projectiles thrown by this player should start, player eye position + adjustment */ Vector3d GetThrowStartPos(void) const; -- cgit v1.2.3