summaryrefslogtreecommitdiffstats
path: root/source/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-24 15:55:08 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-11-24 15:55:08 +0100
commitf95064a85c83e1a77a5de2f8a09e5907573f8277 (patch)
tree9896aa6cff228acbc0b188b6c37e2032152fe661 /source/Entities
parentFixed some comments and added debug logging (diff)
parentRCONClient: Initial implementation. (diff)
downloadcuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar.gz
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar.bz2
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar.lz
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar.xz
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.tar.zst
cuberite-f95064a85c83e1a77a5de2f8a09e5907573f8277.zip
Diffstat (limited to 'source/Entities')
-rw-r--r--source/Entities/Player.cpp15
-rw-r--r--source/Entities/Player.h18
2 files changed, 15 insertions, 18 deletions
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index 436ae0cfc..f37a23f22 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -358,11 +358,10 @@ bool cPlayer::SetCurrentExperience(short int a_CurrentXp)
short cPlayer::DeltaExperience(short a_Xp_delta)
{
- //ToDo: figure out a better name?...
- if(a_Xp_delta > (SHRT_MAX - m_LifetimeTotalXp))
+ if (a_Xp_delta > (SHRT_MAX - m_CurrentXp))
{
// Value was bad, abort and report
- LOGWARNING("Attempt was made to increment Xp by %d, which was bad",
+ LOGWARNING("Attempt was made to increment Xp by %d, which overflowed the short datatype. Ignoring.",
a_Xp_delta);
return -1; // Should we instead just return the current Xp?
}
@@ -370,13 +369,13 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
m_CurrentXp += a_Xp_delta;
// Make sure they didn't subtract too much
- if(m_CurrentXp < MIN_EXPERIENCE)
+ if (m_CurrentXp < 0)
{
- m_CurrentXp = MIN_EXPERIENCE;
+ m_CurrentXp = 0;
}
// Update total for score calculation
- if(a_Xp_delta > 0)
+ if (a_Xp_delta > 0)
{
m_LifetimeTotalXp += a_Xp_delta;
}
@@ -803,8 +802,8 @@ void cPlayer::Respawn(void)
m_FoodSaturationLevel = 5;
// Reset Experience
- m_CurrentXp = MIN_EXPERIENCE;
- m_LifetimeTotalXp = MIN_EXPERIENCE;
+ m_CurrentXp = 0;
+ m_LifetimeTotalXp = 0;
// ToDo: send score to client? How?
m_ClientHandle->SendRespawn();
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index bda25715d..44cab7d74 100644
--- a/source/Entities/Player.h
+++ b/source/Entities/Player.h
@@ -32,7 +32,6 @@ 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
@@ -92,6 +91,12 @@ public:
/// 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
+ static short XpForLevel(short int a_Level);
+
+ /// 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
@@ -326,9 +331,7 @@ public:
virtual bool IsCrouched (void) const { return m_IsCrouched; }
virtual bool IsSprinting(void) const { return m_IsSprinting; }
virtual bool IsRclking (void) const { return IsEating(); }
-
-
-
+
protected:
typedef std::map< std::string, bool > PermissionMap;
PermissionMap m_ResolvedPermissions;
@@ -426,15 +429,10 @@ protected:
// 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_CurrentXp);
-
bool m_IsChargingBow;
int m_BowCharge;
+
virtual void Destroyed(void);
/// Filters out damage for creative mode