summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-23 00:42:38 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-23 00:42:38 +0300
commit2acd4cd73813e8cd0bf6d662e10e34af59cfac99 (patch)
tree2fa62d81b7849510df10a9efb8cec8b3384fa12b /src/net/eathena
parentc4122f537ce74b55c6e465d2020f17b791b278a4 (diff)
downloadplus-2acd4cd73813e8cd0bf6d662e10e34af59cfac99.tar.gz
plus-2acd4cd73813e8cd0bf6d662e10e34af59cfac99.tar.bz2
plus-2acd4cd73813e8cd0bf6d662e10e34af59cfac99.tar.xz
plus-2acd4cd73813e8cd0bf6d662e10e34af59cfac99.zip
eathena: use petinfo for loading and storing data about pet.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/pethandler.cpp65
1 files changed, 56 insertions, 9 deletions
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
index 899e836bf..f8984d10b 100644
--- a/src/net/eathena/pethandler.cpp
+++ b/src/net/eathena/pethandler.cpp
@@ -20,9 +20,11 @@
#include "net/eathena/pethandler.h"
+#include "actormanager.h"
#include "inventory.h"
#include "notifymanager.h"
+#include "being/petinfo.h"
#include "being/playerinfo.h"
#include "gui/chatconsts.h"
@@ -183,20 +185,65 @@ void PetHandler::processEggsList(Net::MessageIn &msg)
void PetHandler::processPetData(Net::MessageIn &msg)
{
- msg.readUInt8("type");
- msg.readInt32("pet id");
- msg.readInt32("param");
+ const int cmd = msg.readUInt8("type");
+ const int id = msg.readInt32("pet id");
+ Being *const dstBeing = actorManager->findBeing(id);
+ const int data = msg.readInt32("data");
+ if (!cmd) // pre init
+ {
+ PetInfo *const info = new PetInfo;
+ info->id = id;
+ PlayerInfo::setPet(info);
+ PlayerInfo::setPetBeing(dstBeing);
+ return;
+ }
+ PetInfo *const info = PlayerInfo::getPet();
+ 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;
+ case 4: // performance
+ info->performance = data;
+ break;
+ case 5: // hair style
+ info->hairStyle = data;
+ break;
+ default:
+ break;
+ }
}
void PetHandler::processPetStatus(Net::MessageIn &msg)
{
- msg.readString(24, "pet name");
+ const std::string name = msg.readString(24, "pet name");
msg.readUInt8("rename flag");
- msg.readInt16("level");
- msg.readInt16("hungry");
- msg.readInt16("intimate");
- msg.readInt16("equip");
- msg.readInt16("class");
+ const int level = msg.readInt16("level");
+ const int hungry = msg.readInt16("hungry");
+ const int intimacy = msg.readInt16("intimacy");
+ const int equip = msg.readInt16("equip");
+ const int race = msg.readInt16("class");
+
+// Being *const being = PlayerInfo::getPetBeing();
+// if (being)
+// being->setLevel(level);
+
+ PetInfo *const info = PlayerInfo::getPet();
+ if (!info)
+ return;
+ info->level = level;
+ info->hungry = hungry;
+ info->intimacy = intimacy;
+ info->equip = equip;
+ info->race = race;
}
} // namespace EAthena