From 4e5d11c6d14dc255070c61d5bb867d2c52039f30 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Mon, 19 Aug 2019 20:48:52 +0300
Subject: Update packet SMSG_HOMUNCULUS_INFO

---
 src/net/eathena/homunculusrecv.cpp | 77 ++++++++++++++++++++++++++++++++++++++
 src/net/eathena/homunculusrecv.h   |  1 +
 src/net/eathena/packetsin.inc      | 18 +++++++++
 3 files changed, 96 insertions(+)

(limited to 'src/net')

diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp
index 95117e967..1e9a0d7a7 100644
--- a/src/net/eathena/homunculusrecv.cpp
+++ b/src/net/eathena/homunculusrecv.cpp
@@ -267,6 +267,83 @@ void HomunculusRecv::processHomunculusInfo2(Net::MessageIn &msg)
     PlayerInfo::setHomunculusBeing(dstBeing);
 }
 
+void HomunculusRecv::processHomunculusInfo3(Net::MessageIn &msg)
+{
+    if (actorManager == nullptr)
+        return;
+    const std::string name = msg.readString(24, "name");
+    msg.readUInt8("flags");  // 0x01 - renamed, 0x02 - vaporize, 0x04 - alive
+    const int level = msg.readInt16("level");
+    PlayerInfo::setStatBase(Attributes::HOMUN_LEVEL,
+        level,
+        Notify_true);
+    const int hungry = msg.readInt16("hungry");
+    const int intimacy = msg.readInt16("intimacy");
+    PlayerInfo::setStatBase(Attributes::HOMUN_ATK,
+        msg.readInt16("atk"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_MATK,
+        msg.readInt16("matk"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_HIT,
+        msg.readInt16("hit"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_CRIT,
+        msg.readInt16("luk/3 or crit/10"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_DEF,
+        msg.readInt16("def"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_MDEF,
+        msg.readInt16("mdef"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_FLEE,
+        msg.readInt16("flee"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_ATTACK_DELAY,
+        msg.readInt16("attack speed"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_HP,
+        msg.readInt32("hp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_MAX_HP,
+        msg.readInt32("max hp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_MP,
+        msg.readInt16("sp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_MAX_MP,
+        msg.readInt16("max sp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_EXP,
+        msg.readInt32("exp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_EXP_NEEDED,
+        msg.readInt32("next exp"),
+        Notify_true);
+    PlayerInfo::setStatBase(Attributes::HOMUN_SKILL_POINTS,
+        msg.readInt16("skill points"),
+        Notify_true);
+    const int range = msg.readInt16("attack range");
+    PlayerInfo::setStatBase(Attributes::HOMUN_ATTACK_RANGE,
+        range,
+        Notify_true);
+
+    PlayerInfo::updateAttrs();
+    HomunculusInfo *const info = PlayerInfo::getHomunculus();
+    if (info == nullptr)
+        return;
+    Being *const dstBeing = actorManager->findBeing(info->id);
+
+    info->name = name;
+    info->level = level;
+    info->range = range;
+    info->hungry = hungry;
+    info->intimacy = intimacy;
+    info->equip = 0;
+    PlayerInfo::setHomunculusBeing(dstBeing);
+}
+
 void HomunculusRecv::processHomunculusSkillUp(Net::MessageIn &msg)
 {
     const int skillId = msg.readInt16("skill id");
diff --git a/src/net/eathena/homunculusrecv.h b/src/net/eathena/homunculusrecv.h
index 8183db1f9..4949e8bac 100644
--- a/src/net/eathena/homunculusrecv.h
+++ b/src/net/eathena/homunculusrecv.h
@@ -34,6 +34,7 @@ namespace EAthena
         void processHomunculusData(Net::MessageIn &msg);
         void processHomunculusInfo1(Net::MessageIn &msg);
         void processHomunculusInfo2(Net::MessageIn &msg);
+        void processHomunculusInfo3(Net::MessageIn &msg);
         void processHomunculusSkillUp(Net::MessageIn &msg);
         void processHomunculusFood(Net::MessageIn &msg);
         void processHomunculusExp(Net::MessageIn &msg);
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
index 492ca268d..0cdbf304e 100644
--- a/src/net/eathena/packetsin.inc
+++ b/src/net/eathena/packetsin.inc
@@ -1791,6 +1791,24 @@ if (packetVersionMain >= 20190522)
     packet(SMSG_PLAYER_SHORTCUTS,          0x0b20, 271, &PlayerRecv::processPlayerShortcuts3,           20190522);
 }
 
+// 20190605 re
+if (packetVersionRe >= 20190605)
+{
+    packet(SMSG_HOMUNCULUS_INFO,           0x0b2f,  73, &HomunculusRecv::processHomunculusInfo3,        20190605);
+}
+
+// 20190619 main
+if (packetVersionMain >= 20190619)
+{
+    packet(SMSG_HOMUNCULUS_INFO,           0x0b2f,  73, &HomunculusRecv::processHomunculusInfo3,        20190619);
+}
+
+// 20190626 zero
+if (packetVersionZero >= 20190626)
+{
+    packet(SMSG_HOMUNCULUS_INFO,           0x0b2f,  73, &HomunculusRecv::processHomunculusInfo3,        20190626);
+}
+
 // 0
 // evol always packets
 packet(SMSG_SERVER_VERSION_RESPONSE,       0x7531,  -1, &LoginRecv::processServerVersion,               0);
-- 
cgit v1.2.3-70-g09d2