From 94a3b513dda2189a49f8f5e0d131b9f644d60cef Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Sep 2014 21:40:11 +0300 Subject: eathena: add packet SMSG_HOMUNCULUS_DATA 0x0230. --- src/net/eathena/homunculushandler.cpp | 41 +++++++++++++++++++++++++++++++++++ src/net/eathena/homunculushandler.h | 2 ++ src/net/eathena/packets.h | 2 +- src/net/eathena/protocol.h | 1 + 4 files changed, 45 insertions(+), 1 deletion(-) (limited to 'src/net') diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp index e99f7f1d0..6b752daad 100644 --- a/src/net/eathena/homunculushandler.cpp +++ b/src/net/eathena/homunculushandler.cpp @@ -20,8 +20,10 @@ #include "net/eathena/homunculushandler.h" +#include "actormanager.h" #include "logger.h" +#include "being/homunculusinfo.h" #include "being/playerinfo.h" #include "gui/windows/skilldialog.h" @@ -44,6 +46,7 @@ HomunculusHandler::HomunculusHandler() : static const uint16_t _messages[] = { SMSG_HOMUNCULUS_SKILLS, + SMSG_HOMUNCULUS_DATA, 0 }; handledMessages = _messages; @@ -58,6 +61,10 @@ void HomunculusHandler::handleMessage(Net::MessageIn &msg) processHomunculusSkills(msg); break; + case SMSG_HOMUNCULUS_DATA: + processHomunculusData(msg); + break; + default: break; } @@ -93,4 +100,38 @@ void HomunculusHandler::processHomunculusSkills(Net::MessageIn &msg) skillDialog->updateModels(); } +void HomunculusHandler::processHomunculusData(Net::MessageIn &msg) +{ + msg.readUInt8("unused"); + const int cmd = msg.readUInt8("state"); + const int id = msg.readInt32("homunculus id"); + Being *const dstBeing = actorManager->findBeing(id); + const int data = msg.readInt32("data"); + if (!cmd) // pre init + { + HomunculusInfo *const info = new HomunculusInfo; + info->id = id; + PlayerInfo::setHomunculus(info); + PlayerInfo::setHomunculusBeing(dstBeing); + return; + } + HomunculusInfo *const info = PlayerInfo::getHomunculus(); + if (!info) + return; + switch (cmd) + { + case 1: // intimacy + info->intimacy = data; + break; + case 2: // hunger + info->hungry = data; + break; + case 3: // accesory + info->equip = data; + break; + default: + break; + } +} + } // namespace EAthena diff --git a/src/net/eathena/homunculushandler.h b/src/net/eathena/homunculushandler.h index 25ea59622..c172adb90 100644 --- a/src/net/eathena/homunculushandler.h +++ b/src/net/eathena/homunculushandler.h @@ -41,6 +41,8 @@ class HomunculusHandler final : public MessageHandler, protected: void processHomunculusSkills(Net::MessageIn &msg); + + void processHomunculusData(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index feead5c1a..28002d4e4 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -86,7 +86,7 @@ int16_t packet_lengths[] = 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0, 22, -1, 16, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 122, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 19, 0, 0, - 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 12, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // #0x0240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 024743c8f..74ddf6dda 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -259,6 +259,7 @@ #define SMSG_MERCENARY_SKILLS 0x029d #define SMSG_HOMUNCULUS_SKILLS 0x0235 +#define SMSG_HOMUNCULUS_DATA 0x0230 /********************************** * Packets from client to server * -- cgit v1.2.3-70-g09d2