diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-10 15:47:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-10 15:47:42 +0300 |
commit | a3635c94a9f1074736f243b0f7de7ab1c8aa14d0 (patch) | |
tree | 6c0b4c6231def1f391ee5dd5dbad715c57d4005f /src/net/ea | |
parent | 3efda43abd11979adfd048fc62fe4f09e702f772 (diff) | |
download | manaverse-a3635c94a9f1074736f243b0f7de7ab1c8aa14d0.tar.gz manaverse-a3635c94a9f1074736f243b0f7de7ab1c8aa14d0.tar.bz2 manaverse-a3635c94a9f1074736f243b0f7de7ab1c8aa14d0.tar.xz manaverse-a3635c94a9f1074736f243b0f7de7ab1c8aa14d0.zip |
Improve partyhandler class.
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/partyhandler.cpp | 49 | ||||
-rw-r--r-- | src/net/ea/partyhandler.h | 32 |
2 files changed, 35 insertions, 46 deletions
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 92cf48a2d..642688ddb 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -49,28 +49,21 @@ PartyHandler::~PartyHandler() partyTab = nullptr; } -void PartyHandler::join(int partyId A_UNUSED) +void PartyHandler::join(const int partyId A_UNUSED) const { - // TODO? } -void PartyHandler::requestPartyMembers() const -{ - // Our eAthena doesn't have this message - // Not needed anyways -} - -void PartyHandler::reload() +void PartyHandler::reload() const { taParty = Party::getParty(1); } -void PartyHandler::clear() +void PartyHandler::clear() const { taParty = nullptr; } -void PartyHandler::processPartyCreate(Net::MessageIn &msg) +void PartyHandler::processPartyCreate(Net::MessageIn &msg) const { if (msg.readInt8()) NotifyManager::notify(NotifyManager::PARTY_CREATE_FAILED); @@ -78,7 +71,7 @@ void PartyHandler::processPartyCreate(Net::MessageIn &msg) NotifyManager::notify(NotifyManager::PARTY_CREATED); } -void PartyHandler::processPartyInfo(Net::MessageIn &msg) +void PartyHandler::processPartyInfo(Net::MessageIn &msg) const { bool oldParty = false; std::set<std::string> names; @@ -126,15 +119,13 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) { if (oldParty) { - //member = Ea::taParty->getMember(id); if (names.find(nick) == names.end()) { NotifyManager::notify(NotifyManager::PARTY_USER_JOINED, nick); } } - PartyMember *member = Ea::taParty->addMember(id, nick); - + PartyMember *const member = Ea::taParty->addMember(id, nick); if (member) { member->setLeader(leader); @@ -154,12 +145,12 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) } } -void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg) +void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg) const { if (!Ea::partyTab) return; - std::string nick = msg.readString(24); + const std::string nick = msg.readString(24); switch (msg.readInt8()) { @@ -183,16 +174,16 @@ void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg) } } -void PartyHandler::processPartyInvited(Net::MessageIn &msg) +void PartyHandler::processPartyInvited(Net::MessageIn &msg) const { const int id = msg.readInt32(); - std::string partyName = msg.readString(24); - std::string nick(""); - const Being *being; + const std::string partyName = msg.readString(24); + std::string nick; if (actorSpriteManager) { - if ((being = actorSpriteManager->findBeing(id))) + const Being *const being = actorSpriteManager->findBeing(id); + if (being) { if (being->getType() == Being::PLAYER) nick = being->getName(); @@ -273,7 +264,7 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) } } -void PartyHandler::processPartyMove(Net::MessageIn &msg) +void PartyHandler::processPartyMove(Net::MessageIn &msg) const { const int id = msg.readInt32(); // id PartyMember *m = nullptr; @@ -301,10 +292,10 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg) } } -void PartyHandler::processPartyLeave(Net::MessageIn &msg) +void PartyHandler::processPartyLeave(Net::MessageIn &msg) const { const int id = msg.readInt32(); - std::string nick = msg.readString(24); + const std::string nick = msg.readString(24); msg.readInt8(); // fail if (!player_node) return; @@ -341,7 +332,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) } } -void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg) +void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg) const { const int id = msg.readInt32(); const int hp = msg.readInt16(); @@ -364,7 +355,7 @@ void PartyHandler::processPartyUpdateHp(Net::MessageIn &msg) } } -void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg) +void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg) const { const int id = msg.readInt32(); // id PartyMember *m = nullptr; @@ -382,14 +373,14 @@ void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg) } } -void PartyHandler::processPartyMessage(Net::MessageIn &msg) +void PartyHandler::processPartyMessage(Net::MessageIn &msg) const { const int msgLength = msg.readInt16() - 8; if (msgLength <= 0) return; const int id = msg.readInt32(); - std::string chatMsg = msg.readString(msgLength); + const std::string chatMsg = msg.readString(msgLength); if (Ea::taParty && Ea::partyTab) { diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index c113a6a3b..62d08034a 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -42,41 +42,39 @@ class PartyHandler : public Net::PartyHandler ~PartyHandler(); - void join(int partyId); + void join(const int partyId) const override; - void requestPartyMembers() const; - - PartyShare getShareExperience() const A_WARN_UNUSED + PartyShare getShareExperience() const override A_WARN_UNUSED { return mShareExp; } - PartyShare getShareItems() const A_WARN_UNUSED + PartyShare getShareItems() const override A_WARN_UNUSED { return mShareItems; } - void reload(); + void reload() const; - void clear(); + void clear() const override; - ChatTab *getTab(); + ChatTab *getTab() override; - virtual void processPartyCreate(Net::MessageIn &msg); + virtual void processPartyCreate(Net::MessageIn &msg) const; - virtual void processPartyInfo(Net::MessageIn &msg); + virtual void processPartyInfo(Net::MessageIn &msg) const; - virtual void processPartyInviteResponse(Net::MessageIn &msg); + virtual void processPartyInviteResponse(Net::MessageIn &msg) const; - virtual void processPartyInvited(Net::MessageIn &msg); + virtual void processPartyInvited(Net::MessageIn &msg) const; virtual void processPartySettings(Net::MessageIn &msg); - virtual void processPartyMove(Net::MessageIn &msg); + virtual void processPartyMove(Net::MessageIn &msg) const; - virtual void processPartyLeave(Net::MessageIn &msg); + virtual void processPartyLeave(Net::MessageIn &msg) const; - virtual void processPartyUpdateHp(Net::MessageIn &msg); + virtual void processPartyUpdateHp(Net::MessageIn &msg) const; - virtual void processPartyUpdateCoords(Net::MessageIn &msg); + virtual void processPartyUpdateCoords(Net::MessageIn &msg) const; - virtual void processPartyMessage(Net::MessageIn &msg); + virtual void processPartyMessage(Net::MessageIn &msg) const; protected: PartyShare mShareExp; |