summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/pethandler.cpp28
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)