diff options
author | madmaxoft <github@xoft.cz> | 2013-11-21 22:09:11 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-11-21 22:09:11 +0100 |
commit | f92512ebdf9b163a8e830055d7887b7afe554699 (patch) | |
tree | 46ac08113dad504b372f9025f8f510707329e2f3 /source/Entities/Player.cpp | |
parent | APIDump: Documented cWorld:ForEachBlockEntityInChunk() and cWorld:DoWithBlockEntityAt(). (diff) | |
download | cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar.gz cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar.bz2 cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar.lz cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar.xz cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.tar.zst cuberite-f92512ebdf9b163a8e830055d7887b7afe554699.zip |
Diffstat (limited to 'source/Entities/Player.cpp')
-rw-r--r-- | source/Entities/Player.cpp | 15 |
1 files changed, 7 insertions, 8 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(); |