summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-24 21:40:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-24 21:40:11 +0300
commit94a3b513dda2189a49f8f5e0d131b9f644d60cef (patch)
treee2027f225f9a14cb935df099e74eec5c190c6d39
parent73c360768c4d0a9013073fb86123eab858ff79d7 (diff)
downloadmv-94a3b513dda2189a49f8f5e0d131b9f644d60cef.tar.gz
mv-94a3b513dda2189a49f8f5e0d131b9f644d60cef.tar.bz2
mv-94a3b513dda2189a49f8f5e0d131b9f644d60cef.tar.xz
mv-94a3b513dda2189a49f8f5e0d131b9f644d60cef.zip
eathena: add packet SMSG_HOMUNCULUS_DATA 0x0230.
-rw-r--r--src/being/playerinfo.cpp22
-rw-r--r--src/being/playerinfo.h7
-rw-r--r--src/net/eathena/homunculushandler.cpp41
-rw-r--r--src/net/eathena/homunculushandler.h2
-rw-r--r--src/net/eathena/packets.h2
-rw-r--r--src/net/eathena/protocol.h1
6 files changed, 74 insertions, 1 deletions
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 6c4e1c92d..4f40b2c58 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -26,6 +26,7 @@
#include "inventory.h"
#include "being/attributes.h"
+#include "being/homunculusinfo.h"
#include "being/localplayer.h"
#include "being/mercenaryinfo.h"
#include "being/petinfo.h"
@@ -57,6 +58,7 @@ int mCharId = 0;
Inventory *mInventory = nullptr;
Equipment *mEquipment = nullptr;
MercenaryInfo *mMercenary = nullptr;
+HomunculusInfo *mHomunculus = nullptr;
PetInfo *mPet = nullptr;
bool mTrading = false;
@@ -511,4 +513,24 @@ PetInfo *getPet()
return mPet;
}
+void setHomunculus(HomunculusInfo *const info)
+{
+ if (mHomunculus)
+ delete mHomunculus;
+ mHomunculus = info;
+}
+
+void setHomunculusBeing(Being *const being)
+{
+ if (!being || !mPet)
+ return;
+ being->setName(mHomunculus->name);
+ being->setOwner(localPlayer);
+}
+
+HomunculusInfo *getHomunculus()
+{
+ return mHomunculus;
+}
+
} // namespace PlayerInfo
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index 23fb41731..aa2251bbe 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -63,6 +63,7 @@ class FloorItem;
class Inventory;
class Item;
+struct HomunculusInfo;
struct MercenaryInfo;
struct PetInfo;
@@ -249,6 +250,12 @@ namespace PlayerInfo
void setPet(PetInfo *const info);
void setPetBeing(Being *const being);
+
+ HomunculusInfo *getHomunculus();
+
+ void setHomunculus(HomunculusInfo *const info);
+
+ void setHomunculusBeing(Being *const being);
} // namespace PlayerInfo
#endif // BEING_PLAYERINFO_H
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 *