summaryrefslogtreecommitdiff
path: root/src/being/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-27 16:24:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-27 16:24:12 +0300
commita6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0 (patch)
treebd1e6b6a1cdb42b5e6d4489158d438fe8c05f533 /src/being/localplayer.cpp
parentaf0ae4d0b7c56d540639bb1f4ba7cc458ec718c1 (diff)
downloadmanaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.gz
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.bz2
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.xz
manaverse-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.zip
Add StatListener.
Diffstat (limited to 'src/being/localplayer.cpp')
-rw-r--r--src/being/localplayer.cpp82
1 files changed, 32 insertions, 50 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index ad26a15c2..08dce56ad 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -97,6 +97,7 @@ extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(const int id, const int subtype) :
Being(id, PLAYER, subtype, nullptr),
AttributeListener(),
+ StatListener(),
mGMLevel(0),
mInvertDirection(0),
mCrazyMoveType(config.getIntValue("crazyMoveType")),
@@ -176,8 +177,6 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) :
{
logger->log1("LocalPlayer::LocalPlayer");
- listen(CHANNEL_ATTRIBUTES);
-
mAttackRange = 0;
mLevel = 1;
mAdvanced = true;
@@ -1025,59 +1024,42 @@ void LocalPlayer::optionChanged(const std::string &value)
mShowServerPos = config.getBoolValue("showserverpos");
}
-void LocalPlayer::processEvent(const Channels channel,
- const DepricatedEvent &event)
+void LocalPlayer::statChanged(const int id,
+ const int oldVal1,
+ const int oldVal2)
{
- if (channel == CHANNEL_ATTRIBUTES)
+ if (!mShowJobExp || id != Net::getPlayerHandler()->getJobLocation())
+ return;
+
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
+ if (oldVal1 > exp.first || !oldVal2)
+ return;
+
+ const int change = exp.first - oldVal1;
+ if (change != 0 && mMessages.size() < 20)
{
- if (event.getName() == EVENT_UPDATESTAT)
+ if (!mMessages.empty())
{
- if (!mShowJobExp)
- return;
-
- const int id = event.getInt("id");
- if (id == Net::getPlayerHandler()->getJobLocation())
+ MessagePair pair = mMessages.back();
+ // TRANSLATORS: this is normal experience
+ if (pair.first.find(strprintf(" %s", _("xp")))
+ == pair.first.size() - strlen(_("xp")) - 1)
{
- const std::pair<int, int> exp
- = PlayerInfo::getStatExperience(id);
- if (event.getInt("oldValue1") > exp.first
- || !event.getInt("oldValue2"))
- {
- return;
- }
-
- const int change = exp.first - event.getInt("oldValue1");
- if (change != 0 && mMessages.size() < 20)
- {
- if (!mMessages.empty())
- {
- MessagePair pair = mMessages.back();
- // TRANSLATORS: this is normal experience
- if (pair.first.find(strprintf(" %s",
- _("xp"))) == pair.first.size()
- - strlen(_("xp")) - 1)
- {
- mMessages.pop_back();
- // TRANSLATORS: this is job experience
- pair.first.append(strprintf(", %d %s",
- change, _("job")));
- mMessages.push_back(pair);
- }
- else
- {
- // TRANSLATORS: this is job experience
- addMessageToQueue(strprintf("%d %s",
- change, _("job")));
- }
- }
- else
- {
- // TRANSLATORS: this is job experience
- addMessageToQueue(strprintf(
- "%d %s", change, _("job")));
- }
- }
+ mMessages.pop_back();
+ // TRANSLATORS: this is job experience
+ pair.first.append(strprintf(", %d %s", change, _("job")));
+ mMessages.push_back(pair);
}
+ else
+ {
+ // TRANSLATORS: this is job experience
+ addMessageToQueue(strprintf("%d %s", change, _("job")));
+ }
+ }
+ else
+ {
+ // TRANSLATORS: this is job experience
+ addMessageToQueue(strprintf("%d %s", change, _("job")));
}
}
}