summaryrefslogtreecommitdiff
path: root/src/net/eathena/homunculushandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena/homunculushandler.cpp')
-rw-r--r--src/net/eathena/homunculushandler.cpp41
1 files changed, 41 insertions, 0 deletions
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