summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-27 19:58:59 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-27 19:58:59 +0300
commit2dbb62e760853f88a19e6e783870de156d52f8c6 (patch)
tree45bdc2d1de608a9f6580bd183c515f4282dcdfc7 /src/net/eathena
parenta23b30e3a3051393c8abd309be7376daf699a527 (diff)
downloadmanaplus-2dbb62e760853f88a19e6e783870de156d52f8c6.tar.gz
manaplus-2dbb62e760853f88a19e6e783870de156d52f8c6.tar.bz2
manaplus-2dbb62e760853f88a19e6e783870de156d52f8c6.tar.xz
manaplus-2dbb62e760853f88a19e6e783870de156d52f8c6.zip
Move receive code from mercenaryhandler into separate file.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/chatrecv.cpp4
-rw-r--r--src/net/eathena/mercenaryhandler.cpp109
-rw-r--r--src/net/eathena/mercenaryhandler.h9
-rw-r--r--src/net/eathena/mercenaryrecv.cpp146
-rw-r--r--src/net/eathena/mercenaryrecv.h40
5 files changed, 192 insertions, 116 deletions
diff --git a/src/net/eathena/chatrecv.cpp b/src/net/eathena/chatrecv.cpp
index 69785731b..f058593c9 100644
--- a/src/net/eathena/chatrecv.cpp
+++ b/src/net/eathena/chatrecv.cpp
@@ -38,11 +38,11 @@
#include "gui/widgets/tabs/chat/chattab.h"
-#include "net/mercenaryhandler.h"
#include "net/serverfeatures.h"
#include "net/ea/chatrecv.h"
+#include "net/eathena/mercenaryrecv.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -130,7 +130,7 @@ void ChatRecv::processFormatMessage(Net::MessageIn &msg)
std::string chatMsg;
if (msgId >= 1266 && msgId <= 1269)
{
- mercenaryHandler->handleMercenaryMessage(msgId - 1266);
+ MercenaryRecv::handleMercenaryMessage(msgId - 1266);
return;
}
switch (msgId)
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
index 3d5f0a72c..c4c6741a7 100644
--- a/src/net/eathena/mercenaryhandler.cpp
+++ b/src/net/eathena/mercenaryhandler.cpp
@@ -33,6 +33,7 @@
#include "net/serverfeatures.h"
+#include "net/eathena/mercenaryrecv.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -62,15 +63,15 @@ void MercenaryHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_MERCENARY_UPDATE:
- processMercenaryUpdate(msg);
+ MercenaryRecv::processMercenaryUpdate(msg);
break;
case SMSG_MERCENARY_INFO:
- processMercenaryInfo(msg);
+ MercenaryRecv::processMercenaryInfo(msg);
break;
case SMSG_MERCENARY_SKILLS:
- processMercenarySkills(msg);
+ MercenaryRecv::processMercenarySkills(msg);
break;
default:
@@ -78,108 +79,6 @@ void MercenaryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void MercenaryHandler::processMercenaryUpdate(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- // +++ need create if need mercenary being and update stats
- msg.readInt16("type");
- msg.readInt32("value");
-}
-
-void MercenaryHandler::processMercenaryInfo(Net::MessageIn &msg)
-{
- // +++ need create if need mercenary being and update stats
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- msg.readInt16("atk");
- msg.readInt16("matk");
- msg.readInt16("hit");
- msg.readInt16("crit/10");
- msg.readInt16("def");
- msg.readInt16("mdef");
- msg.readInt16("flee");
- msg.readInt16("attack speed");
- const std::string name = msg.readString(24, "name");
- const int level = msg.readInt16("level");
- msg.readInt32("hp");
- msg.readInt32("max hp");
- msg.readInt32("sp");
- msg.readInt32("max sp");
- msg.readInt32("expire time");
- msg.readInt16("faith");
- msg.readInt32("calls");
- msg.readInt32("kills");
- const int range = msg.readInt16("attack range");
- if (dstBeing && localPlayer)
- {
- MercenaryInfo *const mercenary = new MercenaryInfo;
- mercenary->id = dstBeing->getId();
- mercenary->name = name;
- mercenary->level = level;
- mercenary->range = range;
- PlayerInfo::setMercenary(mercenary);
- PlayerInfo::setMercenaryBeing(dstBeing);
- }
-}
-
-void MercenaryHandler::processMercenarySkills(Net::MessageIn &msg)
-{
- if (skillDialog)
- skillDialog->hideSkills(SkillOwner::Mercenary);
- const int count = (msg.readInt16("len") - 4) / 37;
- for (int f = 0; f < count; f ++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Mercenary,
- skillId, name, level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog)
- skillDialog->updateModels();
-}
-
-void MercenaryHandler::handleMercenaryMessage(const int cmd)
-{
- PlayerInfo::setMercenary(nullptr);
- if (skillDialog)
- {
- skillDialog->hideSkills(SkillOwner::Mercenary);
- skillDialog->updateModels();
- }
-
- switch (cmd)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MERCENARY_EXPIRED);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MERCENARY_KILLED);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::MERCENARY_FIRED);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::MERCENARY_RUN);
- break;
- default:
- NotifyManager::notify(NotifyTypes::MERCENARY_UNKNOWN);
- break;
- }
-}
-
void MercenaryHandler::fire()
{
createOutPacket(CMSG_MERCENARY_ACTION);
diff --git a/src/net/eathena/mercenaryhandler.h b/src/net/eathena/mercenaryhandler.h
index 643f4ec74..9c41e15d3 100644
--- a/src/net/eathena/mercenaryhandler.h
+++ b/src/net/eathena/mercenaryhandler.h
@@ -37,8 +37,6 @@ class MercenaryHandler final : public MessageHandler,
void handleMessage(Net::MessageIn &msg) override final;
- void handleMercenaryMessage(const int cmd) override final;
-
void fire() override final;
void moveToMaster() const override final;
@@ -53,13 +51,6 @@ class MercenaryHandler final : public MessageHandler,
void emote(const uint8_t emoteId) const override final;
void setDirection(const unsigned char type) const override final;
-
- protected:
- static void processMercenaryUpdate(Net::MessageIn &msg);
-
- static void processMercenaryInfo(Net::MessageIn &msg);
-
- static void processMercenarySkills(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/eathena/mercenaryrecv.cpp b/src/net/eathena/mercenaryrecv.cpp
new file mode 100644
index 000000000..c96340703
--- /dev/null
+++ b/src/net/eathena/mercenaryrecv.cpp
@@ -0,0 +1,146 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/eathena/mercenaryrecv.h"
+
+#include "actormanager.h"
+#include "notifymanager.h"
+
+#include "being/localplayer.h"
+#include "being/mercenaryinfo.h"
+#include "being/playerinfo.h"
+
+#include "enums/resources/notifytypes.h"
+
+#include "gui/windows/skilldialog.h"
+
+#include "net/serverfeatures.h"
+
+#include "net/eathena/messageout.h"
+#include "net/eathena/protocol.h"
+
+#include "debug.h"
+
+namespace EAthena
+{
+
+void MercenaryRecv::processMercenaryUpdate(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ // +++ need create if need mercenary being and update stats
+ msg.readInt16("type");
+ msg.readInt32("value");
+}
+
+void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg)
+{
+ // +++ need create if need mercenary being and update stats
+ Being *const dstBeing = actorManager->findBeing(
+ msg.readBeingId("being id"));
+ msg.readInt16("atk");
+ msg.readInt16("matk");
+ msg.readInt16("hit");
+ msg.readInt16("crit/10");
+ msg.readInt16("def");
+ msg.readInt16("mdef");
+ msg.readInt16("flee");
+ msg.readInt16("attack speed");
+ const std::string name = msg.readString(24, "name");
+ const int level = msg.readInt16("level");
+ msg.readInt32("hp");
+ msg.readInt32("max hp");
+ msg.readInt32("sp");
+ msg.readInt32("max sp");
+ msg.readInt32("expire time");
+ msg.readInt16("faith");
+ msg.readInt32("calls");
+ msg.readInt32("kills");
+ const int range = msg.readInt16("attack range");
+ if (dstBeing && localPlayer)
+ {
+ MercenaryInfo *const mercenary = new MercenaryInfo;
+ mercenary->id = dstBeing->getId();
+ mercenary->name = name;
+ mercenary->level = level;
+ mercenary->range = range;
+ PlayerInfo::setMercenary(mercenary);
+ PlayerInfo::setMercenaryBeing(dstBeing);
+ }
+}
+
+void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg)
+{
+ if (skillDialog)
+ skillDialog->hideSkills(SkillOwner::Mercenary);
+ const int count = (msg.readInt16("len") - 4) / 37;
+ for (int f = 0; f < count; f ++)
+ {
+ const int skillId = msg.readInt16("skill id");
+ const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
+ msg.readInt32("inf"));
+ const int level = msg.readInt16("skill level");
+ const int sp = msg.readInt16("sp");
+ const int range = msg.readInt16("range");
+ const std::string name = msg.readString(24, "skill name");
+ const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
+ PlayerInfo::setSkillLevel(skillId, level);
+ if (skillDialog)
+ {
+ if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
+ {
+ skillDialog->addSkill(SkillOwner::Mercenary,
+ skillId, name, level, range, up, inf, sp);
+ }
+ }
+ }
+ if (skillDialog)
+ skillDialog->updateModels();
+}
+
+void MercenaryRecv::handleMercenaryMessage(const int cmd)
+{
+ PlayerInfo::setMercenary(nullptr);
+ if (skillDialog)
+ {
+ skillDialog->hideSkills(SkillOwner::Mercenary);
+ skillDialog->updateModels();
+ }
+
+ switch (cmd)
+ {
+ case 0:
+ NotifyManager::notify(NotifyTypes::MERCENARY_EXPIRED);
+ break;
+ case 1:
+ NotifyManager::notify(NotifyTypes::MERCENARY_KILLED);
+ break;
+ case 2:
+ NotifyManager::notify(NotifyTypes::MERCENARY_FIRED);
+ break;
+ case 3:
+ NotifyManager::notify(NotifyTypes::MERCENARY_RUN);
+ break;
+ default:
+ NotifyManager::notify(NotifyTypes::MERCENARY_UNKNOWN);
+ break;
+ }
+}
+
+} // namespace EAthena
diff --git a/src/net/eathena/mercenaryrecv.h b/src/net/eathena/mercenaryrecv.h
new file mode 100644
index 000000000..18fed7069
--- /dev/null
+++ b/src/net/eathena/mercenaryrecv.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_MERCENARYRECV_H
+#define NET_EATHENA_MERCENARYRECV_H
+
+#include "net/mercenaryhandler.h"
+
+#include "net/eathena/messagehandler.h"
+
+namespace EAthena
+{
+ namespace MercenaryRecv
+ {
+ void handleMercenaryMessage(const int cmd);
+ void processMercenaryUpdate(Net::MessageIn &msg);
+ void processMercenaryInfo(Net::MessageIn &msg);
+ void processMercenarySkills(Net::MessageIn &msg);
+};
+
+} // namespace EAthena
+
+#endif // NET_EATHENA_MERCENARYRECV_H