summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-30 17:52:22 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-30 17:52:22 +0200
commit5d115b5fd4d9915c4e72c33d800ddbd8a48802b5 (patch)
treef90af41a0ad0ef42b0eb0f408d7f1731f50610f1 /src
parentb9ef24610683211dbd847d93f7d29de88bf0f170 (diff)
downloadmana-5d115b5fd4d9915c4e72c33d800ddbd8a48802b5.tar.gz
mana-5d115b5fd4d9915c4e72c33d800ddbd8a48802b5.tar.bz2
mana-5d115b5fd4d9915c4e72c33d800ddbd8a48802b5.tar.xz
mana-5d115b5fd4d9915c4e72c33d800ddbd8a48802b5.zip
Fixed the negative XP notifications on levelups.
This used to have an associated issue but I just can't find it anymore. Reviewed-by: Thorbjorn.
Diffstat (limited to 'src')
-rw-r--r--src/localplayer.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 78395438..494bbb5a 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1031,10 +1031,27 @@ void LocalPlayer::event(Event::Channel channel, const Event &event)
{
if (event.getInt("id") == EXP)
{
- int change = event.getInt("newValue")
- - event.getInt("oldValue");
+ 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 + newXp;
+ }
+ else
+ {
+ change = newXp - oldXp;
+ }
- addMessageToQueue(toString(change) + " xp");
+ if (change > 0)
+ addMessageToQueue(toString(change) + " xp");
}
}
}