summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-03-24 17:22:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-03-24 17:22:32 +0300
commit82df40f813bf90fd93bbff3aaf8cdb8a92473d27 (patch)
tree920a9b73d823f0fbb5ca9a9df15d21a330735079
parent2e64d3f76e9ad4233f2dd7e95625a73660c2f116 (diff)
downloadmv-82df40f813bf90fd93bbff3aaf8cdb8a92473d27.tar.gz
mv-82df40f813bf90fd93bbff3aaf8cdb8a92473d27.tar.bz2
mv-82df40f813bf90fd93bbff3aaf8cdb8a92473d27.tar.xz
mv-82df40f813bf90fd93bbff3aaf8cdb8a92473d27.zip
eathena: use exp packet to show exp and job messages.
-rw-r--r--src/being/localplayer.cpp48
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/net/eathena/playerhandler.cpp21
3 files changed, 51 insertions, 22 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index db37992f6..9da05d898 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -1055,18 +1055,8 @@ void LocalPlayer::optionChanged(const std::string &value)
mShowServerPos = config.getBoolValue("showserverpos");
}
-void LocalPlayer::statChanged(const int id,
- const int oldVal1,
- const int oldVal2)
+void LocalPlayer::addJobMessage(const int change)
{
- if (!mShowJobExp || id != Attributes::JOB)
- 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 (!mMessages.empty())
@@ -1095,6 +1085,34 @@ void LocalPlayer::statChanged(const int id,
}
}
+void LocalPlayer::addXpMessage(const int change)
+{
+ if (change != 0 && mMessages.size() < 20)
+ {
+ // TRANSLATORS: get xp message
+ addMessageToQueue(strprintf("%d %s", change, _("xp")));
+ }
+}
+
+void LocalPlayer::statChanged(const int id,
+ const int oldVal1,
+ const int oldVal2)
+{
+ if (!mShowJobExp ||
+ id != Attributes::JOB ||
+ serverFeatures->haveExpPacket())
+ {
+ return;
+ }
+
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
+ if (oldVal1 > exp.first || !oldVal2)
+ return;
+
+ const int change = exp.first - oldVal1;
+ addJobMessage(change);
+}
+
void LocalPlayer::attributeChanged(const int id,
const int oldVal,
const int newVal)
@@ -1103,15 +1121,13 @@ void LocalPlayer::attributeChanged(const int id,
{
case Attributes::EXP:
{
+ if (serverFeatures->haveExpPacket())
+ break;
if (oldVal > newVal)
break;
const int change = newVal - oldVal;
- if (change != 0)
- {
- // TRANSLATORS: get xp message
- addMessageToQueue(strprintf("%d %s", change, _("xp")));
- }
+ addXpMessage(change);
break;
}
case Attributes::LEVEL:
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index d63e5a7e6..a0865baa9 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -366,6 +366,10 @@ class LocalPlayer final : public Being,
void stopAdvert();
+ void addXpMessage(const int change);
+
+ void addJobMessage(const int change);
+
static bool checAttackPermissions(const Being *const target)
A_WARN_UNUSED;
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 9edb50e01..c2f3e7ee1 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -469,12 +469,21 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
void PlayerHandler::processPlayerGetExp(Net::MessageIn &msg)
{
- UNIMPLIMENTEDPACKET;
- msg.readInt32("player id");
- msg.readInt32("exp amount");
- msg.readInt16("exp type");
- msg.readInt16("is from quest");
-// Being *dstBeing = actorManager->findBeing(id);
+ if (!localPlayer)
+ return;
+ const int id = msg.readInt32("player id");
+ const int exp = msg.readInt32("exp amount");
+ const int stat = msg.readInt16("exp type");
+ const bool fromQuest = msg.readInt16("is from quest");
+ if (!fromQuest && id == localPlayer->getId())
+ {
+ if (stat == 1)
+ localPlayer->addXpMessage(exp);
+ else if (stat == 2)
+ localPlayer->addJobMessage(exp);
+ else
+ logger->log("unknown exp type");
+ }
// need show particle depend on isQuest flag, for now ignored
}