diff options
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0a041021..0ee35ebe 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1032,14 +1032,24 @@ void LocalPlayer::event(Event::Channel channel, const Event &event) { if (event.getInt("id") == EXP) { - int change = 0, - oldXp = event.getInt("oldValue"), - newXp = event.getInt("newValue"); - + int change = 0; + int oldXp = event.getInt("oldValue"); + int newXp = event.getInt("newValue"); + + // When the new XP is lower than the old one, + // it means that a new level has been reached. + // Thus, the xp difference can only be obtained + // with the exp needed for the next level. + // The new XP value is then the XP obtained for the new level. if (newXp < oldXp) - change = PlayerInfo::getAttribute(EXP_NEEDED) - oldXp; + { + change = PlayerInfo::getAttribute(EXP_NEEDED) + - oldXp + newXp; + } else + { change = newXp - oldXp; + } if (change > 0) addMessageToQueue(toString(change) + " xp"); |