diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 56 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.h | 6 |
2 files changed, 55 insertions, 7 deletions
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 1d341e520..f222feada 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -285,6 +285,47 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } +Being *BeingHandler::createBeing2(const int id, + const int16_t job, + const BeingType::BeingType beingType) const +{ + if (!actorManager) + return nullptr; + + ActorType::Type type = ActorType::Unknown; + switch (beingType) + { + case BeingType::PC: + type = ActorType::Player; + break; + case BeingType::NPC: + case BeingType::NPC_EVENT: + type = ActorType::Npc; + break; + case BeingType::MONSTER: + type = ActorType::Monster; + break; + case BeingType::ITEM: + case BeingType::SKILL: + case BeingType::ELEMENTAL: + logger->log("not supported object type: %d, job: %d", + static_cast<int>(beingType), static_cast<int>(job)); + break; + case BeingType::CHAT: + case BeingType::PET: + case BeingType::HOMUN: + case BeingType::MERSOL: + type = ActorType::Monster; + logger->log("not supported object type: %d, job: %d", + static_cast<int>(beingType), static_cast<int>(job)); + break; + } + if (job == 45 && beingType == BeingType::NPC_EVENT) + type = ActorType::Portal; + + return actorManager->createBeing(id, type, job); +} + void BeingHandler::undress(Being *const being) const { being->setSprite(SPRITE_BOTTOMCLOTHES, 0); @@ -885,7 +926,8 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg) return; msg.readInt16("len"); - msg.readUInt8("object type"); + const BeingType::BeingType type = static_cast<BeingType::BeingType>( + msg.readUInt8("object type")); // Information about a being in range const int id = msg.readInt32("being id"); @@ -919,7 +961,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg) if (actorManager->isBlocked(id) == true) return; - dstBeing = createBeing(id, job); + dstBeing = createBeing2(id, job, type); if (!dstBeing) return; @@ -1047,7 +1089,8 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) return; msg.readInt16("len"); - msg.readUInt8("object type"); + const BeingType::BeingType type = static_cast<BeingType::BeingType>( + msg.readUInt8("object type")); // Information about a being in range const int id = msg.readInt32("being id"); @@ -1089,7 +1132,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg) if (actorManager->isBlocked(id) == true) return; - dstBeing = createBeing(id, job); + dstBeing = createBeing2(id, job, type); if (!dstBeing) return; @@ -1217,7 +1260,8 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) return; msg.readInt16("len"); - msg.readUInt8("object type"); + const BeingType::BeingType type = static_cast<BeingType::BeingType>( + msg.readUInt8("object type")); // Information about a being in range const int id = msg.readInt32("being id"); @@ -1255,7 +1299,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg) if (actorManager->isBlocked(id) == true) return; - dstBeing = createBeing(id, job); + dstBeing = createBeing2(id, job, type); if (!dstBeing) return; diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index d5a3867ef..9bd811f10 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -25,6 +25,7 @@ #include "net/ea/beinghandler.h" +#include "net/eathena/beingtype.h" #include "net/eathena/messagehandler.h" namespace EAthena @@ -46,6 +47,10 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void requestRanks(const Rank::Rank rank) const override final; protected: + Being *createBeing2(const int id, + const int16_t job, + const BeingType::BeingType beingType) const; + void processBeingChangeLook(Net::MessageIn &msg) const; void processBeingChangeLook2(Net::MessageIn &msg) const; @@ -97,7 +102,6 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void viewPlayerEquipment(const Being *const being) override final; - protected: void processSkillGroundNoDamage(Net::MessageIn &msg) const; void processSkillEntry(Net::MessageIn &msg) const; |