diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-23 13:59:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-23 13:59:50 +0300 |
commit | 22ae95c948a4d1ec988a234213592500e52d4947 (patch) | |
tree | e3c168d6d1a3cae241b580b5c6a5977204f911bd | |
parent | 2acd4cd73813e8cd0bf6d662e10e34af59cfac99 (diff) | |
download | manaverse-22ae95c948a4d1ec988a234213592500e52d4947.tar.gz manaverse-22ae95c948a4d1ec988a234213592500e52d4947.tar.bz2 manaverse-22ae95c948a4d1ec988a234213592500e52d4947.tar.xz manaverse-22ae95c948a4d1ec988a234213592500e52d4947.zip |
eathena: show pets hungry level messages in chat.
-rw-r--r-- | src/net/eathena/pethandler.cpp | 28 |
1 files 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) |