summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-11-01 04:22:50 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-11-01 04:22:50 +0100
commita1e61f8446b7928d854a062f6494e75fe3fec9ab (patch)
tree953cba5593a49f818612f38de1149a2763a36aa8 /src/localplayer.cpp
parent79cb8fa1ca81440e21bcb186785d47c50a608e8e (diff)
parent8954a7ca0f70bbf167c9119d26c7bca8407e8da6 (diff)
downloadmana-a1e61f8446b7928d854a062f6494e75fe3fec9ab.tar.gz
mana-a1e61f8446b7928d854a062f6494e75fe3fec9ab.tar.bz2
mana-a1e61f8446b7928d854a062f6494e75fe3fec9ab.tar.xz
mana-a1e61f8446b7928d854a062f6494e75fe3fec9ab.zip
Merge github.com:mana/mana
Conflicts: src/localplayer.cpp src/net/manaserv/beinghandler.cpp src/net/manaserv/charhandler.cpp
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp20
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");