From 669a5f22c7ff9c63c1f19bf5fe757e8ac90ced0d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 26 Sep 2014 13:21:00 +0300 Subject: eathena: add packet SMSG_HOMUNCULUS_FOOD 0x022f. --- src/net/eathena/homunculushandler.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/net/eathena/homunculushandler.cpp') diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp index 6f7aaaa40..f96ad006b 100644 --- a/src/net/eathena/homunculushandler.cpp +++ b/src/net/eathena/homunculushandler.cpp @@ -22,6 +22,7 @@ #include "actormanager.h" #include "logger.h" +#include "notifymanager.h" #include "being/homunculusinfo.h" #include "being/playerinfo.h" @@ -33,6 +34,13 @@ #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" +#include "resources/iteminfo.h" +#include "resources/notifytypes.h" + +#include "resources/db/itemdb.h" + +#include "utils/stringutils.h" + #include "debug.h" extern Net::HomunculusHandler *homunculusHandler; @@ -49,6 +57,7 @@ HomunculusHandler::HomunculusHandler() : SMSG_HOMUNCULUS_DATA, SMSG_HOMUNCULUS_INFO, SMSG_HOMUNCULUS_SKILL_UP, + SMSG_HOMUNCULUS_FOOD, 0 }; handledMessages = _messages; @@ -75,6 +84,10 @@ void HomunculusHandler::handleMessage(Net::MessageIn &msg) processHomunculusSkillUp(msg); break; + case SMSG_HOMUNCULUS_FOOD: + processHomunculusFood(msg); + break; + default: break; } @@ -207,6 +220,22 @@ void HomunculusHandler::processHomunculusSkillUp(Net::MessageIn &msg) } } +void HomunculusHandler::processHomunculusFood(Net::MessageIn &msg) +{ + const int flag = msg.readUInt8("fail"); + const int itemId = msg.readInt16("food id"); + if (flag) + { + NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_OK); + } + else + { + const std::string name = strprintf("[@@%d|%s@@]", itemId, + ItemDB::get(itemId).getName().c_str()); + NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_FAIL, name); + } +} + void HomunculusHandler::setName(const std::string &name) const { createOutPacket(CMSG_HOMUNCULUS_SET_NAME); -- cgit v1.2.3-60-g2f50