diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-02 00:53:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-04-02 00:53:22 +0300 |
commit | 2f6f5950605e3ffe8054f3a2675f10032ca0aaf6 (patch) | |
tree | 8cbbc807f00bc4aeffc103058d223863c8de643f /src | |
parent | 28165cbeca05b74cf66f121757f21f4cb7cd381e (diff) | |
download | mv-2f6f5950605e3ffe8054f3a2675f10032ca0aaf6.tar.gz mv-2f6f5950605e3ffe8054f3a2675f10032ca0aaf6.tar.bz2 mv-2f6f5950605e3ffe8054f3a2675f10032ca0aaf6.tar.xz mv-2f6f5950605e3ffe8054f3a2675f10032ca0aaf6.zip |
improve guildhandler class.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/socialwindow.cpp | 12 | ||||
-rw-r--r-- | src/net/ea/guildhandler.cpp | 90 | ||||
-rw-r--r-- | src/net/ea/guildhandler.h | 66 | ||||
-rw-r--r-- | src/net/eathena/guildhandler.cpp | 33 | ||||
-rw-r--r-- | src/net/eathena/guildhandler.h | 29 | ||||
-rw-r--r-- | src/net/guildhandler.h | 48 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 32 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.h | 28 |
8 files changed, 172 insertions, 166 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 2b3ec2c3a..6514f5922 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1182,8 +1182,6 @@ public: mBrowserBox->setOpaque(false); mBrowserBox->setLinkHandler(this); - if (Net::getGuildHandler()->isSupported()) - mBrowserBox->addRow(strprintf("@@guild|%s@@", _("Create Guild"))); mBrowserBox->addRow(strprintf("@@party|%s@@", _("Create Party"))); mBrowserBox->addRow("##3---"); mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); @@ -1488,15 +1486,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } else if (eventId == "create") { - if (Net::getGuildHandler()->isSupported()) - { - if (mCreatePopup) - mCreatePopup->show(mCreateButton); - } - else - { - showPartyCreate(); - } + showPartyCreate(); } else if (eventId == "invite" && mTabs->getSelectedTabIndex() > -1) { diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 51996244b..2d3861956 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -46,30 +46,23 @@ GuildHandler::~GuildHandler() guildTab = nullptr; } -void GuildHandler::requestAlliance(int guildId A_UNUSED, - int otherGuildId A_UNUSED) +void GuildHandler::requestAlliance(const int guildId A_UNUSED, + const int otherGuildId A_UNUSED) const { - // TODO } -void GuildHandler::requestAllianceResponse(int guildId A_UNUSED, - int otherGuildId A_UNUSED, - bool response A_UNUSED) +void GuildHandler::requestAllianceResponse(const int guildId A_UNUSED, + const int otherGuildId A_UNUSED, + const bool response A_UNUSED) const { - // TODO } -void GuildHandler::endAlliance(int guildId A_UNUSED, int otherGuildId A_UNUSED) +void GuildHandler::endAlliance(const int guildId A_UNUSED, + const int otherGuildId A_UNUSED) const { - // TODO } -bool GuildHandler::isSupported() -{ - return true; -} - -void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) +void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) const { const int flag = msg.readInt8(); @@ -102,7 +95,7 @@ void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) } } -void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) +void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) const { const int guildId = msg.readInt32(); const int emblem = msg.readInt32(); @@ -139,7 +132,7 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) emblem, posMode, guildName.c_str()); } -void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) +void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) const { const int accountId = msg.readInt32(); // Account ID const int charId = msg.readInt32(); // Char ID @@ -156,7 +149,7 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) } } -void GuildHandler::processGuildMasterOrMember(Net::MessageIn &msg) +void GuildHandler::processGuildMasterOrMember(Net::MessageIn &msg) const { msg.readInt32(); // Type (0x57 for member, 0xd7 for master) } @@ -203,7 +196,7 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) g->setName(name); } -void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) +void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) const { const int length = msg.readInt16(); if (length < 4) @@ -218,7 +211,7 @@ void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) } } -void GuildHandler::processGuildMemberList(Net::MessageIn &msg) +void GuildHandler::processGuildMemberList(Net::MessageIn &msg) const { const int length = msg.readInt16(); if (length < 4) @@ -282,7 +275,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg) } } -void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) +void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) const { if (!taGuild) { @@ -298,12 +291,12 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) for (int i = 0; i < count; i++) { const int id = msg.readInt32(); // ID - std::string name = msg.readString(24); // Position name + const std::string name = msg.readString(24); // Position name taGuild->addPos(id, name); } } -void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg) +void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg) const { const int length = msg.readInt16(); if (length < 4) @@ -319,7 +312,7 @@ void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg) } } -void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg) +void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg) const { msg.readInt16(); // Always 44 msg.readInt32(); // ID @@ -329,7 +322,7 @@ void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg) msg.readString(24); // Name } -void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg) +void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg) const { msg.readInt16(); // Always 16 const int accountId = msg.readInt32(); // Account ID @@ -343,7 +336,7 @@ void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg) } } -void GuildHandler::processGuildEmblem(Net::MessageIn &msg) +void GuildHandler::processGuildEmblem(Net::MessageIn &msg) const { const int length = msg.readInt16(); @@ -354,7 +347,7 @@ void GuildHandler::processGuildEmblem(Net::MessageIn &msg) msg.skip(length - 12); // Emblem data (unknown format) } -void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) +void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) const { const int length = msg.readInt16(); const int count = (length - 6) / 37; @@ -376,10 +369,10 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) } } -void GuildHandler::processGuildNotice(Net::MessageIn &msg) +void GuildHandler::processGuildNotice(Net::MessageIn &msg) const { - std::string msg1 = msg.readString(60); // Mes1 - std::string msg2 = msg.readString(120); // Mes2 + const std::string msg1 = msg.readString(60); // Mes1 + const std::string msg2 = msg.readString(120); // Mes2 if (guildTab) { guildTab->chatLog(msg1, BY_SERVER); @@ -387,16 +380,16 @@ void GuildHandler::processGuildNotice(Net::MessageIn &msg) } } -void GuildHandler::processGuildInvite(Net::MessageIn &msg) +void GuildHandler::processGuildInvite(Net::MessageIn &msg) const { const int guildId = msg.readInt32(); - std::string guildName = msg.readString(24); + const std::string guildName = msg.readString(24); if (socialWindow) socialWindow->showGuildInvite(guildName, guildId, ""); } -void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) +void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) const { const int flag = msg.readInt8(); if (!guildTab) @@ -426,9 +419,9 @@ void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) } } -void GuildHandler::processGuildLeave(Net::MessageIn &msg) +void GuildHandler::processGuildLeave(Net::MessageIn &msg) const { - std::string nick = msg.readString(24); // Name + const std::string nick = msg.readString(24); // Name msg.readString(40); // Message if (taGuild) @@ -469,10 +462,10 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) } } -void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) +void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) const { msg.skip(2); // size (can be many explusions in list) - std::string nick = msg.readString(24); // Name (of expulsed?) + const std::string nick = msg.readString(24); // Name (of expulsed?) msg.skip(24); // acc msg.readString(44); // Message if (taGuild) @@ -513,7 +506,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) } } -void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) +void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) const { const int length = msg.readInt16(); if (length < 4) @@ -529,7 +522,7 @@ void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) } } -void GuildHandler::processGuildMessage(Net::MessageIn &msg) +void GuildHandler::processGuildMessage(Net::MessageIn &msg) const { const int msgLength = msg.readInt16() - 4; @@ -538,11 +531,10 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg) if (guildTab) { std::string chatMsg = msg.readString(msgLength); - const size_t pos = chatMsg.find(" : ", 0); if (pos != std::string::npos) { - std::string sender_name = chatMsg.substr(0, pos); + const std::string sender_name = chatMsg.substr(0, pos); chatMsg.erase(0, pos + 3); trim(chatMsg); guildTab->chatLog(sender_name, chatMsg); @@ -554,7 +546,7 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg) } } -void GuildHandler::processGuildSkillUp(Net::MessageIn &msg) +void GuildHandler::processGuildSkillUp(Net::MessageIn &msg) const { msg.readInt16(); // Skill ID msg.readInt16(); // Level @@ -563,39 +555,39 @@ void GuildHandler::processGuildSkillUp(Net::MessageIn &msg) msg.readInt8(); // unused? (always 1) } -void GuildHandler::processGuildReqAlliance(Net::MessageIn &msg) +void GuildHandler::processGuildReqAlliance(Net::MessageIn &msg) const { msg.readInt32(); // Account ID msg.readString(24); // Name } -void GuildHandler::processGuildReqAllianceAck(Net::MessageIn &msg) +void GuildHandler::processGuildReqAllianceAck(Net::MessageIn &msg) const { msg.readInt32(); // Flag } -void GuildHandler::processGuildDelAlliance(Net::MessageIn &msg) +void GuildHandler::processGuildDelAlliance(Net::MessageIn &msg) const { msg.readInt32(); // Guild ID msg.readInt32(); // Flag } -void GuildHandler::processGuildOppositionAck(Net::MessageIn &msg) +void GuildHandler::processGuildOppositionAck(Net::MessageIn &msg) const { msg.readInt8(); // Flag } -void GuildHandler::processGuildBroken(Net::MessageIn &msg) +void GuildHandler::processGuildBroken(Net::MessageIn &msg) const { msg.readInt32(); // Flag } -void GuildHandler::clear() +void GuildHandler::clear() const { taGuild = nullptr; } -ChatTab *GuildHandler::getTab() +ChatTab *GuildHandler::getTab() const { return guildTab; } diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 65a6973ca..a1a66763c 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -39,70 +39,70 @@ class GuildHandler : public Net::GuildHandler ~GuildHandler(); - void requestAlliance(int guildId, int otherGuildId); + void requestAlliance(const int guildId, + const int otherGuildId) const override; - void requestAllianceResponse(int guildId, int otherGuildId, - bool response); + void requestAllianceResponse(const int guildId, const int otherGuildId, + const bool response) const override; - void endAlliance(int guildId, int otherGuildId); + void endAlliance(const int guildId, + const int otherGuildId) const override; - bool isSupported() A_WARN_UNUSED; + virtual void processGuildCreateResponse(Net::MessageIn &msg) const; - virtual void processGuildCreateResponse(Net::MessageIn &msg); + virtual void processGuildPositionInfo(Net::MessageIn &msg) const; - virtual void processGuildPositionInfo(Net::MessageIn &msg); + virtual void processGuildMemberLogin(Net::MessageIn &msg) const; - virtual void processGuildMemberLogin(Net::MessageIn &msg); - - virtual void processGuildMasterOrMember(Net::MessageIn &msg); + virtual void processGuildMasterOrMember(Net::MessageIn &msg) const; virtual void processGuildBasicInfo(Net::MessageIn &msg); - virtual void processGuildAlianceInfo(Net::MessageIn &msg); + virtual void processGuildAlianceInfo(Net::MessageIn &msg) const; - virtual void processGuildMemberList(Net::MessageIn &msg); + virtual void processGuildMemberList(Net::MessageIn &msg) const; - virtual void processGuildPosNameList(Net::MessageIn &msg); + virtual void processGuildPosNameList(Net::MessageIn &msg) const; - virtual void processGuildPosInfoList(Net::MessageIn &msg); + virtual void processGuildPosInfoList(Net::MessageIn &msg) const; - virtual void processGuildPositionChanged(Net::MessageIn &msg); + virtual void processGuildPositionChanged(Net::MessageIn &msg) const; - virtual void processGuildMemberPosChange(Net::MessageIn &msg); + virtual void processGuildMemberPosChange(Net::MessageIn &msg) const; - virtual void processGuildEmblem(Net::MessageIn &msg); + virtual void processGuildEmblem(Net::MessageIn &msg) const; - virtual void processGuildSkillInfo(Net::MessageIn &msg); + virtual void processGuildSkillInfo(Net::MessageIn &msg) const; - virtual void processGuildNotice(Net::MessageIn &msg); + virtual void processGuildNotice(Net::MessageIn &msg) const; - virtual void processGuildInvite(Net::MessageIn &msg); + virtual void processGuildInvite(Net::MessageIn &msg) const; - virtual void processGuildInviteAck(Net::MessageIn &msg); + virtual void processGuildInviteAck(Net::MessageIn &msg) const; - virtual void processGuildLeave(Net::MessageIn &msg); + virtual void processGuildLeave(Net::MessageIn &msg) const; - virtual void processGuildExpulsion(Net::MessageIn &msg); + virtual void processGuildExpulsion(Net::MessageIn &msg) const; - virtual void processGuildExpulsionList(Net::MessageIn &msg); + virtual void processGuildExpulsionList(Net::MessageIn &msg) const; - virtual void processGuildMessage(Net::MessageIn &msg); + virtual void processGuildMessage(Net::MessageIn &msg) const; - virtual void processGuildSkillUp(Net::MessageIn &msg); + virtual void processGuildSkillUp(Net::MessageIn &msg) const; - virtual void processGuildReqAlliance(Net::MessageIn &msg); + virtual void processGuildReqAlliance(Net::MessageIn &msg) const; - virtual void processGuildReqAllianceAck(Net::MessageIn &msg); + virtual void processGuildReqAllianceAck(Net::MessageIn &msg) const; - virtual void processGuildDelAlliance(Net::MessageIn &msg); + virtual void processGuildDelAlliance(Net::MessageIn &msg) const; - virtual void processGuildOppositionAck(Net::MessageIn &msg); + virtual void processGuildOppositionAck(Net::MessageIn &msg) const; - virtual void processGuildBroken(Net::MessageIn &msg); + virtual void processGuildBroken(Net::MessageIn &msg) const; - void clear(); + void clear() const override; - ChatTab *getTab(); + ChatTab *getTab() const override; protected: bool showBasicInfo; diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 13c0a1f2e..481a74236 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -191,15 +191,15 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) } } -void GuildHandler::create(const std::string &name) +void GuildHandler::create(const std::string &name) const { MessageOut msg(CMSG_GUILD_CREATE); msg.writeInt32(0); // Unused msg.writeString(name, 24); } -void GuildHandler::invite(int guildId A_UNUSED, - const std::string &name A_UNUSED) +void GuildHandler::invite(const int guildId A_UNUSED, + const std::string &name A_UNUSED) const { if (!actorSpriteManager) return; @@ -215,7 +215,8 @@ void GuildHandler::invite(int guildId A_UNUSED, } } -void GuildHandler::invite(int guildId A_UNUSED, const Being *const being) +void GuildHandler::invite(const int guildId A_UNUSED, + const Being *const being) const { if (!being) return; @@ -226,7 +227,8 @@ void GuildHandler::invite(int guildId A_UNUSED, const Being *const being) msg.writeInt32(0); // Unused } -void GuildHandler::inviteResponse(int guildId, bool response) +void GuildHandler::inviteResponse(const int guildId, + const bool response) const { MessageOut msg(CMSG_GUILD_INVITE_REPLY); msg.writeInt32(guildId); @@ -235,7 +237,7 @@ void GuildHandler::inviteResponse(int guildId, bool response) msg.writeInt16(0); // Unused } -void GuildHandler::leave(int guildId) +void GuildHandler::leave(const int guildId) const { if (!player_node) return; @@ -247,7 +249,8 @@ void GuildHandler::leave(int guildId) msg.writeString("", 40); // Message } -void GuildHandler::kick(GuildMember *member, std::string reason) +void GuildHandler::kick(const GuildMember *const member, + const std::string &reason) const { if (!member || !member->getGuild()) return; @@ -259,19 +262,20 @@ void GuildHandler::kick(GuildMember *member, std::string reason) msg.writeString(reason, 40); // Message } -void GuildHandler::chat(int guildId A_UNUSED, const std::string &text) +void GuildHandler::chat(const int guildId A_UNUSED, + const std::string &text) const { if (!player_node) return; - std::string str = std::string(player_node->getName()).append( + const std::string str = std::string(player_node->getName()).append( " : ").append(text); MessageOut msg(CMSG_GUILD_MESSAGE); msg.writeInt16(static_cast<uint16_t>(str.size() + 4)); msg.writeString(str, static_cast<int>(str.length())); } -void GuildHandler::memberList(int guildId A_UNUSED) +void GuildHandler::memberList(const int guildId A_UNUSED) const { // TODO four types of info requests: // 0 = basic info + alliance info @@ -284,7 +288,7 @@ void GuildHandler::memberList(int guildId A_UNUSED) msg.writeInt32(1); // Request member list } -void GuildHandler::info(int guildId A_UNUSED) +void GuildHandler::info(const int guildId A_UNUSED) { // TODO four types of info requests: // 0 = basic info + alliance info @@ -298,7 +302,8 @@ void GuildHandler::info(int guildId A_UNUSED) msg.writeInt32(0); // Request basic info } -void GuildHandler::changeMemberPostion(GuildMember *member, int level) +void GuildHandler::changeMemberPostion(const GuildMember *const member, + const int level) const { if (!member || !member->getGuild()) return; @@ -310,8 +315,8 @@ void GuildHandler::changeMemberPostion(GuildMember *member, int level) msg.writeInt32(level); // pos } -void GuildHandler::changeNotice(int guildId, std::string msg1, - std::string msg2) +void GuildHandler::changeNotice(const int guildId, const std::string &msg1, + const std::string &msg2) const { MessageOut msg(CMSG_GUILD_CHANGE_NOTICE); msg.writeInt32(guildId); diff --git a/src/net/eathena/guildhandler.h b/src/net/eathena/guildhandler.h index 1508895fc..c25e8ff6f 100644 --- a/src/net/eathena/guildhandler.h +++ b/src/net/eathena/guildhandler.h @@ -40,29 +40,34 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler ~GuildHandler(); - void handleMessage(Net::MessageIn &msg); + void handleMessage(Net::MessageIn &msg) override; - void create(const std::string &name); + void create(const std::string &name) const override; - void invite(int guildId, const std::string &name); + void invite(const int guildId, const std::string &name) const override; - void invite(int guildId, const Being *const being); + void invite(const int guildId, + const Being *const being) const override; - void inviteResponse(int guildId, bool response); + void inviteResponse(const int guildId, + const bool response) const override; - void leave(int guildId); + void leave(const int guildId) const override; - void kick(GuildMember *member, std::string reason = ""); + void kick(const GuildMember *const member, + const std::string &reason = "") const override; - void chat(int guildId, const std::string &text); + void chat(const int guildId, const std::string &text) const override; - void memberList(int guildId); + void memberList(const int guildId) const override; - void info(int guildId); + void info(const int guildId) override; - void changeMemberPostion(GuildMember *member, int level); + void changeMemberPostion(const GuildMember *const member, + const int level) const override; - void changeNotice(int guildId, std::string msg1, std::string msg2); + void changeNotice(const int guildId, const std::string &msg1, + const std::string &msg2) const override; }; extern Ea::GuildTab *guildTab; diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h index b1f6bd7bf..27bd9a217 100644 --- a/src/net/guildhandler.h +++ b/src/net/guildhandler.h @@ -40,42 +40,48 @@ class GuildHandler virtual ~GuildHandler() { } - virtual bool isSupported() - { return false; } + virtual void create(const std::string &name) const = 0; - virtual void create(const std::string &name) = 0; + virtual void invite(const int guildId, + const std::string &name) const = 0; - virtual void invite(int guildId, const std::string &name) = 0; + virtual void invite(const int guildId, + const Being *const being) const = 0; - virtual void invite(int guildId, const Being *const being) = 0; + virtual void inviteResponse(const int guildId, + const bool response) const = 0; - virtual void inviteResponse(int guildId, bool response) = 0; + virtual void leave(const int guildId) const = 0; - virtual void leave(int guildId) = 0; + virtual void kick(const GuildMember *const member, + const std::string &reason = "") const = 0; - virtual void kick(GuildMember *member, std::string reason = "") = 0; + virtual void chat(const int guildId, + const std::string &text) const = 0; - virtual void chat(int guildId, const std::string &text) = 0; + virtual void memberList(const int guildId) const = 0; - virtual void memberList(int guildId) = 0; + virtual void info(const int guildId) = 0; - virtual void info(int guildId) = 0; + virtual void changeMemberPostion(const GuildMember *const member, + const int level) const = 0; - virtual void changeMemberPostion(GuildMember *member, int level) = 0; + virtual void requestAlliance(const int guildId, + const int otherGuildId) const = 0; - virtual void requestAlliance(int guildId, int otherGuildId) = 0; + virtual void requestAllianceResponse(const int guildId, + int const otherGuildId, + const bool response) const = 0; - virtual void requestAllianceResponse(int guildId, int otherGuildId, - bool response) = 0; + virtual void endAlliance(const int guildId, + const int otherGuildId) const = 0; - virtual void endAlliance(int guildId, int otherGuildId) = 0; + virtual void changeNotice(const int guildId, const std::string &msg1, + const std::string &msg2) const = 0; - virtual void changeNotice(int guildId, std::string msg1, - std::string msg2) = 0; + virtual void clear() const = 0; - virtual void clear() = 0; - - virtual ChatTab *getTab() = 0; + virtual ChatTab *getTab() const = 0; }; } diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 4e1ceba08..a21ef726f 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -193,15 +193,15 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) BLOCK_END("GuildHandler::handleMessage") } -void GuildHandler::create(const std::string &name) +void GuildHandler::create(const std::string &name) const { MessageOut msg(CMSG_GUILD_CREATE); msg.writeInt32(0); // Unused msg.writeString(name, 24); } -void GuildHandler::invite(int guildId A_UNUSED, - const std::string &name A_UNUSED) +void GuildHandler::invite(const int guildId A_UNUSED, + const std::string &name A_UNUSED) const { if (!actorSpriteManager) return; @@ -217,7 +217,8 @@ void GuildHandler::invite(int guildId A_UNUSED, } } -void GuildHandler::invite(int guildId A_UNUSED, const Being *const being) +void GuildHandler::invite(const int guildId A_UNUSED, + const Being *const being) const { if (!being) return; @@ -228,7 +229,7 @@ void GuildHandler::invite(int guildId A_UNUSED, const Being *const being) msg.writeInt32(0); // Unused } -void GuildHandler::inviteResponse(int guildId, bool response) +void GuildHandler::inviteResponse(const int guildId, const bool response) const { MessageOut msg(CMSG_GUILD_INVITE_REPLY); msg.writeInt32(guildId); @@ -237,7 +238,7 @@ void GuildHandler::inviteResponse(int guildId, bool response) msg.writeInt16(0); // Unused } -void GuildHandler::leave(int guildId) +void GuildHandler::leave(const int guildId) const { if (!player_node) return; @@ -249,7 +250,8 @@ void GuildHandler::leave(int guildId) msg.writeString("", 40); // Message } -void GuildHandler::kick(GuildMember *member, std::string reason) +void GuildHandler::kick(const GuildMember *const member, + const std::string &reason) const { if (!member || !member->getGuild()) return; @@ -261,19 +263,20 @@ void GuildHandler::kick(GuildMember *member, std::string reason) msg.writeString(reason, 40); // Message } -void GuildHandler::chat(int guildId A_UNUSED, const std::string &text) +void GuildHandler::chat(const int guildId A_UNUSED, + const std::string &text) const { if (!player_node) return; - std::string str = std::string(player_node->getName()).append( + const std::string str = std::string(player_node->getName()).append( " : ").append(text); MessageOut msg(CMSG_GUILD_MESSAGE); msg.writeInt16(static_cast<uint16_t>(str.size() + 4)); msg.writeString(str, static_cast<int>(str.length())); } -void GuildHandler::memberList(int guildId A_UNUSED) +void GuildHandler::memberList(const int guildId A_UNUSED) const { // TODO four types of info requests: // 0 = basic info + alliance info @@ -286,7 +289,7 @@ void GuildHandler::memberList(int guildId A_UNUSED) msg.writeInt32(1); // Request member list } -void GuildHandler::info(int guildId A_UNUSED) +void GuildHandler::info(const int guildId A_UNUSED) { // TODO four types of info requests: // 0 = basic info + alliance info @@ -300,7 +303,8 @@ void GuildHandler::info(int guildId A_UNUSED) msg.writeInt32(0); // Request basic info } -void GuildHandler::changeMemberPostion(GuildMember *member, int level) +void GuildHandler::changeMemberPostion(const GuildMember *const member, + const int level) const { if (!member || !member->getGuild()) return; @@ -312,8 +316,8 @@ void GuildHandler::changeMemberPostion(GuildMember *member, int level) msg.writeInt32(level); // pos } -void GuildHandler::changeNotice(int guildId, std::string msg1, - std::string msg2) +void GuildHandler::changeNotice(const int guildId, const std::string &msg1, + const std::string &msg2) const { MessageOut msg(CMSG_GUILD_CHANGE_NOTICE); msg.writeInt32(guildId); diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index 2c2bf4fde..c4c6cf285 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -40,29 +40,33 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler ~GuildHandler(); - void handleMessage(Net::MessageIn &msg); + void handleMessage(Net::MessageIn &msg) override; - void create(const std::string &name); + void create(const std::string &name) const override; - void invite(int guildId, const std::string &name); + void invite(const int guildId, const std::string &name) const override; - void invite(int guildId, const Being *const being); + void invite(const int guildId, + const Being *const being) const override; - void inviteResponse(int guildId, bool response); + void inviteResponse(const int guildId, const bool response) const override; - void leave(int guildId); + void leave(const int guildId) const override; - void kick(GuildMember *member, std::string reason = ""); + void kick(const GuildMember *const member, + const std::string &reason = "") const override; - void chat(int guildId, const std::string &text); + void chat(const int guildId, const std::string &text) const override; - void memberList(int guildId); + void memberList(const int guildId) const override; - void info(int guildId); + void info(const int guildId) override; - void changeMemberPostion(GuildMember *member, int level); + void changeMemberPostion(const GuildMember *const member, + const int level) const override; - void changeNotice(int guildId, std::string msg1, std::string msg2); + void changeNotice(const int guildId, const std::string &msg1, + const std::string &msg2) const override; }; extern Ea::GuildTab *guildTab; |