summaryrefslogtreecommitdiffstats
path: root/source/Entities/Player.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-11-17 23:12:09 +0100
committerMattes D <github@xoft.cz>2013-11-17 23:12:09 +0100
commitd169a1959dc5b6faa7033c78c9afd6f4c4eae604 (patch)
tree2a233fa7dc2b9f5fd4c9a5e040850313546403e5 /source/Entities/Player.h
parentLineBlockTracer: Using the coord-based block faces. (diff)
parentfix *.sdf? (diff)
downloadcuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar.gz
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar.bz2
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar.lz
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar.xz
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.tar.zst
cuberite-d169a1959dc5b6faa7033c78c9afd6f4c4eae604.zip
Diffstat (limited to 'source/Entities/Player.h')
-rw-r--r--source/Entities/Player.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index ab2f94d4c..bda25715d 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
@@ -71,21 +72,25 @@ public:
Returns true on success
"should" really only be called at init or player death, plugins excepted
*/
- bool SetExperience(int 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
+ /* 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
*/
- int AddExperience(int a_Xp_delta);
+ short DeltaExperience(short a_Xp_delta);
- /// Gets the experience total - XpTotal
- inline int 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
- int XpGetLevel(void);
+ short GetXpLevel(void);
/// Gets the experience bar percentage - XpP
- float XpGetPercentage(void);
+ float GetXpPercentage(void);
// tolua_end
@@ -269,6 +274,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(); }
@@ -413,13 +420,17 @@ protected:
Int64 m_EatingFinishTick;
/// Player Xp level
- 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 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_CurrentXp);
bool m_IsChargingBow;
int m_BowCharge;