From 574efa8ae89f7786239753537eb32c222686f4a1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 10 Sep 2015 12:36:08 +0300 Subject: Impliment packets CMSG_SOLVE_CHAR_NAME and SMSG_SOLVE_CHAR_NAME. --- src/actormanager.cpp | 22 ++++++++++++++++++++++ src/actormanager.h | 8 ++++++++ src/net/beinghandler.h | 2 ++ src/net/eathena/beinghandler.cpp | 6 ++++++ src/net/eathena/beinghandler.h | 2 ++ src/net/eathena/beingrecv.cpp | 8 ++++++++ src/net/eathena/beingrecv.h | 1 + src/net/eathena/packetsin.inc | 2 +- src/net/tmwa/beinghandler.cpp | 4 ++++ src/net/tmwa/beinghandler.h | 2 ++ 10 files changed, 56 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index ef4eac8c6..fd7f51368 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -191,6 +191,9 @@ ActorManager::ActorManager() : mActors(), mDeleteActors(), mBlockedBeings(), +#ifdef EATHENA_SUPPORT + mChars(), +#endif mMap(nullptr), mSpellHeal1(serverConfig.getValue("spellHeal1", "#lum")), mSpellHeal2(serverConfig.getValue("spellHeal2", "#inma")), @@ -908,6 +911,10 @@ void ActorManager::clear() if (localPlayer) mActors.insert(localPlayer); + +#ifdef EATHENA_SUPPORT + mChars.clear(); +#endif } Being *ActorManager::findNearestPvpPlayer() const @@ -1980,4 +1987,19 @@ void ActorManager::updateRoom(const ChatObject *const newChat) } } } + +std::string ActorManager::findCharById(const int32_t id) +{ + std::map::const_iterator it = mChars.find(id); + if (it == mChars.end()) + return std::string(); + return (*it).second; +} + +void ActorManager::addChar(const int32_t id, + const std::string &name) +{ + mChars[id] = name; +} + #endif diff --git a/src/actormanager.h b/src/actormanager.h index 989947f83..00c8eb052 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -347,6 +347,11 @@ class ActorManager final: public ConfigListener void removeRoom(const int chatId); void updateRoom(const ChatObject *const newChat); + + std::string findCharById(const int32_t id); + + void addChar(const int32_t id, + const std::string &name); #endif protected: @@ -371,6 +376,9 @@ class ActorManager final: public ConfigListener ActorSprites mActors; ActorSprites mDeleteActors; std::set mBlockedBeings; +#ifdef EATHENA_SUPPORT + std::map mChars; +#endif Map *mMap; std::string mSpellHeal1; std::string mSpellHeal2; diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index 4e0ac021e..81a9e5a79 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -37,6 +37,8 @@ class BeingHandler notfinal virtual void requestNameById(const BeingId id) const = 0; + virtual void requestNameByCharId(const int id) const = 0; + virtual void undress(Being *const being) const = 0; #ifdef EATHENA_SUPPORT diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index ddee2d6fa..2d4686786 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -73,4 +73,10 @@ void BeingHandler::viewPlayerEquipment(const Being *const being) outMsg.writeBeingId(being->getId(), "account id"); } +void BeingHandler::requestNameByCharId(const int id) const +{ + createOutPacket(CMSG_SOLVE_CHAR_NAME); + outMsg.writeInt32(id, "character id"); +} + } // namespace EAthena diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index 6780e9bc3..11d2250ff 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -41,6 +41,8 @@ class BeingHandler final : public Ea::BeingHandler void requestRanks(const RankT rank) const override final; + void requestNameByCharId(const int id) const override final; + protected: void viewPlayerEquipment(const Being *const being); }; diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 2aaf6be7e..31a7bd371 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -1672,4 +1672,12 @@ void BeingRecv::processSkillCancel(Net::MessageIn &msg) msg.readInt32("id?"); } +void BeingRecv::processSolveCharName(Net::MessageIn &msg) +{ + const int id = msg.readInt32("char id"); + const std::string name = msg.readString(24, "name"); + if (actorManager) + actorManager->addChar(id, name); +} + } // namespace EAthena diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h index 95f7b50eb..31b35d5a3 100644 --- a/src/net/eathena/beingrecv.h +++ b/src/net/eathena/beingrecv.h @@ -110,6 +110,7 @@ namespace EAthena void processPvpSet(Net::MessageIn &msg); void processNameResponse2(Net::MessageIn &msg); void processSkillCancel(Net::MessageIn &msg); + void processSolveCharName(Net::MessageIn &msg); Being *createBeing2(Net::MessageIn &msg, const BeingId id, const int16_t job, diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc index 7d463d043..a2ffcfcbe 100644 --- a/src/net/eathena/packetsin.inc +++ b/src/net/eathena/packetsin.inc @@ -399,7 +399,7 @@ packet(SMSG_SKILL_NO_DAMAGE, 0x011a, 15, &Ea::BeingRecv::processS packet(SMSG_SKILL_SNAP, 0x08d2, 10, &SkillRecv::processSkillSnap); packet(SMSG_SKILL_UNIT_UPDATE, 0x01ac, 6, &SkillRecv::processSkillUnitUpdate); packet(SMSG_SKILL_WARP_POINT, 0x011c, 68, &SkillRecv::processSkillWarpPoint); -packet(SMSG_SOLVE_CHAR_NAME, 0x0194, 30, nullptr); +packet(SMSG_SOLVE_CHAR_NAME, 0x0194, 30, &BeingRecv::processSolveCharName); packet(SMSG_SPIRIT_BALLS, 0x01d0, 8, &BeingRecv::processSpiritBalls); packet(SMSG_SPIRIT_BALL_SINGLE, 0x01e1, 8, &BeingRecv::processSpiritBallSingle); packet(SMSG_STARS_KILL, 0x020e, 32, &BeingRecv::processStarsKill); diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 2cbd41835..61da647e1 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -68,4 +68,8 @@ void BeingHandler::viewPlayerEquipment(const Being *const being A_UNUSED) { } +void BeingHandler::requestNameByCharId(const int id A_UNUSED) const +{ +} + } // namespace TmwAthena diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index 1776ddd96..bb39983d5 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -43,6 +43,8 @@ class BeingHandler final : public Ea::BeingHandler void requestRanks(const RankT rank A_UNUSED) const override final; #endif + void requestNameByCharId(const int id) const override final; + protected: void viewPlayerEquipment(const Being *const being); }; -- cgit v1.2.3-60-g2f50