From ae550d179c25e149f7e8a8d70011b364fb0d85d6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 7 Apr 2013 14:57:08 +0300 Subject: some fixes after auto check. --- src/gui/killstats.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/gui/killstats.cpp') diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index c1d8fa8b1..61d8acfcb 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -185,7 +185,8 @@ void KillStats::resetTimes() void KillStats::gainXp(int xp) { - if (xp == PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)) + const int expNeed = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + if (xp == expNeed) xp = 0; else if (!xp) return; @@ -199,7 +200,7 @@ void KillStats::gainXp(int xp) mKillCounter = 1; const float AvgExp = static_cast(mExpCounter / mKillCounter); - int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)); + int xpNextLevel(expNeed); if (mKillTimer == 0) mKillTimer = cur_time; @@ -212,14 +213,13 @@ void KillStats::gainXp(int xp) if (timeDiff <= 0.001) timeDiff = 1; + const int exp = PlayerInfo::getAttribute(PlayerInfo::EXP); mLine1->setCaption(strprintf(_("Level: %d at %f%%"), - player_node->getLevel(), static_cast( - PlayerInfo::getAttribute(PlayerInfo::EXP)) / static_cast( + player_node->getLevel(), static_cast(exp) / static_cast( xpNextLevel) * 100.0)); - mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), - PlayerInfo::getAttribute(PlayerInfo::EXP), xpNextLevel, - xpNextLevel - PlayerInfo::getAttribute(PlayerInfo::EXP))); + mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), exp, + xpNextLevel, xpNextLevel - exp)); if (AvgExp >= 0.001f && AvgExp <= 0.001f) { @@ -242,8 +242,7 @@ void KillStats::gainXp(int xp) toString(AvgExp).c_str())); mLine6->setCaption(strprintf(_("No. of avg mob to next level: %s"), - toString(static_cast(xpNextLevel - - PlayerInfo::getAttribute(PlayerInfo::EXP)) / AvgExp).c_str())); + toString(static_cast(xpNextLevel - exp) / AvgExp).c_str())); } mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"), toString(mKillCounter).c_str(), toString(mExpCounter).c_str())); -- cgit v1.2.3-60-g2f50