From 1b2e6e74736f975386879aa5eb064df5b2f88dac Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Fri, 15 Nov 2013 22:42:09 +1100 Subject: added cProtocol function to pass xp to client --- source/Entities/Player.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index ab2f94d4c..1e43dd954 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -71,18 +71,18 @@ public: Returns true on success "should" really only be called at init or player death, plugins excepted */ - bool SetExperience(int a_XpTotal); + bool SetExperience(short a_XpTotal); /* Adds Xp, "should" not inc more than MAX_EXPERIENCE_ORB_SIZE unless you're a plugin being funny, *cough* cheating Returns the new total experience, -1 on error */ - int AddExperience(int a_Xp_delta); + short AddExperience(short a_Xp_delta); /// Gets the experience total - XpTotal - inline int XpGetTotal(void) { return m_XpTotal; } + inline short XpGetTotal(void) { return m_XpTotal; } /// Gets the current level - XpLevel - int XpGetLevel(void); + short XpGetLevel(void); /// Gets the experience bar percentage - XpP float XpGetPercentage(void); @@ -413,13 +413,13 @@ protected: Int64 m_EatingFinishTick; /// Player Xp level - int m_XpTotal; + short int m_XpTotal; /// Caculates the Xp needed for a given level, ref: http://minecraft.gamepedia.com/XP - static int XpForLevel(int a_Level); + static short XpForLevel(short int a_Level); /// inverse of XpAtLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations - static int CalcLevelFromXp(int a_XpTotal); + static short CalcLevelFromXp(short int a_XpTotal); bool m_IsChargingBow; int m_BowCharge; -- cgit v1.2.3 From 04dff4882a3d75f3a0d432fb3377cc3f59fdf251 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 02:23:50 +1100 Subject: finished #143 I believe --- source/Entities/Player.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 1e43dd954..aeec9f361 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -269,6 +269,8 @@ public: void UseEquippedItem(void); void SendHealth(void); + + void SendExperience(void); // In UI windows, the item that the player is dragging: bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); } -- cgit v1.2.3 From c0c8fe1bcd68c35435eafdfd3dbb9793fba970cd Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 20:29:57 +1100 Subject: fix possible threadlock issue, changed function names to be closer to standard --- source/Entities/Player.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index aeec9f361..2fc0d5ac9 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -71,21 +71,24 @@ public: Returns true on success "should" really only be called at init or player death, plugins excepted */ - bool SetExperience(short a_XpTotal); + bool SetCurrentExperience(short a_XpTotal); /* Adds Xp, "should" not inc more than MAX_EXPERIENCE_ORB_SIZE unless you're a plugin being funny, *cough* cheating - Returns the new total experience, -1 on error + Returns the new current experience, -1 on error */ short AddExperience(short a_Xp_delta); - /// Gets the experience total - XpTotal - inline short XpGetTotal(void) { return m_XpTotal; } + /// Gets the experience total - XpTotal for score on death + inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; } + + /// Gets the currrent experience + inline short GetCurrentXp(void) { return m_CurrentXp; } /// Gets the current level - XpLevel - short XpGetLevel(void); + short GetXpLevel(void); /// Gets the experience bar percentage - XpP - float XpGetPercentage(void); + float GetXpPercentage(void); // tolua_end @@ -415,13 +418,17 @@ protected: Int64 m_EatingFinishTick; /// Player Xp level - short int m_XpTotal; + short int m_LifetimeTotalXp; + short int m_CurrentXp; + + // flag saying we need to send a xp update to client + bool m_bDirtyExperience; /// Caculates the Xp needed for a given level, ref: http://minecraft.gamepedia.com/XP static short XpForLevel(short int a_Level); /// inverse of XpAtLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations - static short CalcLevelFromXp(short int a_XpTotal); + static short CalcLevelFromXp(short int a_XpCurrent); bool m_IsChargingBow; int m_BowCharge; -- cgit v1.2.3 From 359539293782713d47e51775b65ee91fc89994e4 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 21:38:57 +1100 Subject: fixed bug and added SpendExperience() --- source/Entities/Player.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 2fc0d5ac9..01a864149 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -32,6 +32,7 @@ public: 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 + MIN_EXPERIENCE = 0, } ; // tolua_end @@ -78,6 +79,9 @@ public: */ short AddExperience(short a_Xp_delta); + /// "Spend" some experience - ie on enchanting, returns new currentXp + short SpendExperience(short a_Xp_delta); + /// Gets the experience total - XpTotal for score on death inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; } -- cgit v1.2.3 From b72ced31649f8a851ffe60778e8a603bda941dc9 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:00:45 +1100 Subject: removed SpendExperience and changed AddExperience to handle removing Xp --- source/Entities/Player.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 01a864149..463a6d8dc 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -74,13 +74,10 @@ public: */ bool SetCurrentExperience(short a_XpTotal); - /* Adds Xp, "should" not inc more than MAX_EXPERIENCE_ORB_SIZE unless you're a plugin being funny, *cough* cheating + /* changes Xp by Xp_delta, you "shouldn't" not inc more than MAX_EXPERIENCE_ORB_SIZE Returns the new current experience, -1 on error */ - short AddExperience(short a_Xp_delta); - - /// "Spend" some experience - ie on enchanting, returns new currentXp - short SpendExperience(short a_Xp_delta); + short DeltaExperience(short a_Xp_delta); /// Gets the experience total - XpTotal for score on death inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; } -- cgit v1.2.3 From b3bb34974fddfae6cea9ca59d71f95e32621793d Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:17:46 +1100 Subject: updated plugin again... --- source/Entities/Player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 463a6d8dc..5abca9899 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -429,7 +429,7 @@ protected: static short XpForLevel(short int a_Level); /// inverse of XpAtLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations - static short CalcLevelFromXp(short int a_XpCurrent); + static short CalcLevelFromXp(short int a_CurrentXp); bool m_IsChargingBow; int m_BowCharge; -- cgit v1.2.3 From d2d8b1d0736c2af002dc3b91f5281fa4d866470f Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:43:42 +1100 Subject: edited comment and changed error behavior of DeltaXp --- source/Entities/Player.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Entities/Player.h') diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 5abca9899..bda25715d 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -74,7 +74,8 @@ public: */ bool SetCurrentExperience(short a_XpTotal); - /* changes Xp by Xp_delta, you "shouldn't" not inc more than MAX_EXPERIENCE_ORB_SIZE + /* changes Xp by Xp_delta, you "shouldn't" inc more than MAX_EXPERIENCE_ORB_SIZE + Wont't allow xp to go negative Returns the new current experience, -1 on error */ short DeltaExperience(short a_Xp_delta); -- cgit v1.2.3