summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-29 00:08:43 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-29 00:08:43 +0200
commita2bfeabfa7dda816daddbe113a3ae33618b32284 (patch)
treeae3d40058c337bf7f818fd0edf1f422accfad817 /src/localplayer.cpp
parent06fff57500242c37890459ceffdfff2bdf19f6d6 (diff)
downloadmana-a2bfeabfa7dda816daddbe113a3ae33618b32284.tar.gz
mana-a2bfeabfa7dda816daddbe113a3ae33618b32284.tar.bz2
mana-a2bfeabfa7dda816daddbe113a3ae33618b32284.tar.xz
mana-a2bfeabfa7dda816daddbe113a3ae33618b32284.zip
Fix negative XP on levelups.
This used to have an issue but i just can't find it anymore.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 78395438..16382adc 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -1031,10 +1031,17 @@ 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,
+ oldXp = event.getInt("oldValue"),
+ newXp = event.getInt("newValue");
- addMessageToQueue(toString(change) + " xp");
+ if (newXp < oldXp)
+ change = PlayerInfo::getAttribute(EXP_NEEDED) - oldXp;
+ else
+ change = newXp - oldXp;
+
+ if (change > 0)
+ addMessageToQueue(toString(change) + " xp");
}
}
}