From 22ae95c948a4d1ec988a234213592500e52d4947 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 Sep 2014 13:59:50 +0300 Subject: eathena: show pets hungry level messages in chat. --- src/net/eathena/pethandler.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index f8984d10b..1e51aa3b5 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -24,6 +24,7 @@ #include "inventory.h" #include "notifymanager.h" +#include "being/localplayer.h" #include "being/petinfo.h" #include "being/playerinfo.h" @@ -31,6 +32,8 @@ #include "gui/windows/eggselectiondialog.h" +#include "gui/widgets/tabs/chattab.h" + #include "net/chathandler.h" #include "net/net.h" @@ -42,6 +45,9 @@ #include "resources/notifytypes.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + #include "debug.h" extern Net::PetHandler *petHandler; @@ -143,8 +149,26 @@ void PetHandler::setName(const std::string &name) const void PetHandler::processPetMessage(Net::MessageIn &msg) { - msg.readInt32("pet id"); - msg.readInt32("param"); + const int id = msg.readInt32("pet id"); + const int data = msg.readInt32("param"); + Being *const dstBeing = actorManager->findBeing(id); + if (!dstBeing) + return; + + const int hungry = data - (dstBeing->getSubType() - 100) * 100 - 50; + if (hungry >= 0 && hungry <= 4) + { + if (localChatTab && localPlayer) + { + std::string nick = strprintf(_("%s's pet"), + localPlayer->getName().c_str()); + localChatTab->chatLog(nick, strprintf("hungry level %d", hungry)); + } + PetInfo *const info = PlayerInfo::getPet(); + if (!info || info->id != id) + return; + info->hungry = hungry; + } } void PetHandler::processPetRoulette(Net::MessageIn &msg) -- cgit v1.2.3-70-g09d2