diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-27 00:10:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-27 00:10:16 +0300 |
commit | 18d8872333e2e433ce7b9e7be71706de37933097 (patch) | |
tree | dea07c5b7dcd29a3105b42b64ce0414e45f36b10 /src | |
parent | 170b469cbcf4adcd82604a6b2efd5a0630ef3fb5 (diff) | |
download | plus-18d8872333e2e433ce7b9e7be71706de37933097.tar.gz plus-18d8872333e2e433ce7b9e7be71706de37933097.tar.bz2 plus-18d8872333e2e433ce7b9e7be71706de37933097.tar.xz plus-18d8872333e2e433ce7b9e7be71706de37933097.zip |
improve some network handlers classes.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/buysellhandler.h | 8 | ||||
-rw-r--r-- | src/net/ea/adminhandler.h | 14 | ||||
-rw-r--r-- | src/net/ea/buysellhandler.cpp | 21 | ||||
-rw-r--r-- | src/net/ea/buysellhandler.h | 17 | ||||
-rw-r--r-- | src/net/eathena/adminhandler.h | 10 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 11 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.h | 10 | ||||
-rw-r--r-- | src/net/eathena/buysellhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/buysellhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/adminhandler.h | 10 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.h | 6 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.h | 2 |
13 files changed, 50 insertions, 65 deletions
diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h index e358ad299..1f5578ed7 100644 --- a/src/net/buysellhandler.h +++ b/src/net/buysellhandler.h @@ -38,17 +38,17 @@ class BuySellHandler virtual void handleMessage(Net::MessageIn &msg) = 0; - virtual void requestSellList(std::string nick) = 0; + virtual void requestSellList(const std::string &nick) const = 0; - virtual void requestBuyList(std::string nick) = 0; + virtual void requestBuyList(const std::string &nick) const = 0; virtual void sendBuyRequest(const std::string &nick, const ShopItem *const item, - const int amount) = 0; + const int amount) const = 0; virtual void sendSellRequest(const std::string &nick, const ShopItem *const item, - const int amount) = 0; + const int amount) const = 0; }; } // namespace Net diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h index 4100ce4fc..fa2addfea 100644 --- a/src/net/ea/adminhandler.h +++ b/src/net/ea/adminhandler.h @@ -40,21 +40,21 @@ class AdminHandler : public Net::AdminHandler virtual ~AdminHandler() { } - virtual void kickName(const std::string &name) const; + virtual void kickName(const std::string &name) const override; - virtual void ban(const int playerId) const; + virtual void ban(const int playerId) const override; - virtual void banName(const std::string &name) const; + virtual void banName(const std::string &name) const override; - virtual void unban(const int playerId) const; + virtual void unban(const int playerId) const override; - virtual void unbanName(const std::string &name) const; + virtual void unbanName(const std::string &name) const override; virtual void mute(const int playerId, const int type, - const int limit) const; + const int limit) const override; virtual void warp(const std::string &map, - const int x, const int y) const; + const int x, const int y) const override; }; } // namespace Ea diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index d1cf17007..a0d7d03dd 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -50,12 +50,12 @@ BuySellHandler::BuySellHandler() : { } -void BuySellHandler::requestSellList(std::string nick) +void BuySellHandler::requestSellList(const std::string &nick) const { if (nick.empty() != 0 || !shopWindow) return; - std::string data = "!selllist " + toString(tick_time); + const std::string data = "!selllist " + toString(tick_time); shopWindow->setAcceptPlayer(nick); if (config.getBoolValue("hideShopMessages")) @@ -69,12 +69,12 @@ void BuySellHandler::requestSellList(std::string nick) } } -void BuySellHandler::requestBuyList(std::string nick) +void BuySellHandler::requestBuyList(const std::string &nick) const { if (nick.empty() || !shopWindow) return; - std::string data = "!buylist " + toString(tick_time); + const std::string data = "!buylist " + toString(tick_time); shopWindow->setAcceptPlayer(nick); if (config.getBoolValue("hideShopMessages")) @@ -90,14 +90,14 @@ void BuySellHandler::requestBuyList(std::string nick) void BuySellHandler::sendBuyRequest(const std::string &nick, const ShopItem *const item, - const int amount) + const int amount) const { if (!chatWindow || nick.empty() || !item || amount < 1 || amount > item->getQuantity()) { return; } - std::string data = strprintf("!buyitem %d %d %d", + const std::string data = strprintf("!buyitem %d %d %d", item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) @@ -108,7 +108,7 @@ void BuySellHandler::sendBuyRequest(const std::string &nick, void BuySellHandler::sendSellRequest(const std::string &nick, const ShopItem *const item, - const int amount) + const int amount) const { if (!chatWindow || nick.empty() || !item || amount < 1 || amount > item->getQuantity()) @@ -116,7 +116,7 @@ void BuySellHandler::sendSellRequest(const std::string &nick, return; } - std::string data = strprintf("!sellitem %d %d %d", + const std::string data = strprintf("!sellitem %d %d %d", item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) @@ -134,7 +134,8 @@ void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg) } } -void BuySellHandler::processNpcSell(Net::MessageIn &msg, int offset) +void BuySellHandler::processNpcSell(Net::MessageIn &msg, + const int offset) const { msg.readInt16(); // length const int n_items = (msg.getLength() - 4) / 10; @@ -162,7 +163,7 @@ void BuySellHandler::processNpcSell(Net::MessageIn &msg, int offset) } } -void BuySellHandler::processNpcBuyResponse(Net::MessageIn &msg) +void BuySellHandler::processNpcBuyResponse(Net::MessageIn &msg) const { if (msg.readInt8() == 0) { diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h index 54fe6ebf7..2240872b9 100644 --- a/src/net/ea/buysellhandler.h +++ b/src/net/ea/buysellhandler.h @@ -41,27 +41,24 @@ class BuySellHandler : public Net::BuySellHandler A_DELETE_COPY(BuySellHandler) - virtual void requestSellList(std::string nick); + virtual void requestSellList(const std::string &nick) const override; - virtual void requestBuyList(std::string nick); + virtual void requestBuyList(const std::string &nick) const override; virtual void sendBuyRequest(const std::string &nick, const ShopItem *const item, - const int amount); + const int amount) const override; virtual void sendSellRequest(const std::string &nick, const ShopItem *const item, - const int amount); + const int amount) const override; virtual void processNpcBuySellChoice(Net::MessageIn &msg); - virtual void processNpcBuy(Net::MessageIn &msg) = 0; + virtual void processNpcSell(Net::MessageIn &msg, + const int offset) const; - virtual void processNpcSell(Net::MessageIn &msg, int offset); - - virtual void processNpcBuyResponse(Net::MessageIn &msg); - - virtual void processNpcSellResponse(Net::MessageIn &msg) = 0; + virtual void processNpcBuyResponse(Net::MessageIn &msg) const; protected: int mNpcId; diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h index cbbb9d374..9efc4acf5 100644 --- a/src/net/eathena/adminhandler.h +++ b/src/net/eathena/adminhandler.h @@ -40,15 +40,15 @@ class AdminHandler final : public MessageHandler, public Ea::AdminHandler A_DELETE_COPY(AdminHandler) - void handleMessage(Net::MessageIn &msg); + void handleMessage(Net::MessageIn &msg) override; - void announce(const std::string &text) const; + void announce(const std::string &text) const override; - void localAnnounce(const std::string &text) const; + void localAnnounce(const std::string &text) const override; - void hide(const bool h) const; + void hide(const bool h) const override; - void kick(const int playerId) const; + void kick(const int playerId) const override; }; } // namespace EAthena diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 8f012b2f1..98c24559a 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -835,15 +835,4 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, } -void BeingHandler::processBeingSpawn(Net::MessageIn &msg) -{ - // skipping this packet - mSpawnId = msg.readInt32(); // id - msg.readInt16(); // speed - msg.readInt16(); // opt1 - msg.readInt16(); // opt2 - msg.readInt16(); // option - msg.readInt16(); // disguise -} - } // namespace EAthena diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index ac266f3b7..360d8ca2b 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -40,16 +40,14 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler A_DELETE_COPY(BeingHandler) - virtual void handleMessage(Net::MessageIn &msg); + virtual void handleMessage(Net::MessageIn &msg) override; - virtual void requestNameById(const int id) const; + virtual void requestNameById(const int id) const override; - virtual void undress(Being *const being) const; + virtual void undress(Being *const being) const override; void processBeingVisibleOrMove(Net::MessageIn &msg, - const bool visible); - - void processBeingSpawn(Net::MessageIn &msg); + const bool visible) override; protected: virtual void processBeingChangeLook(Net::MessageIn &msg, diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp index fff2e2cef..b96d2c382 100644 --- a/src/net/eathena/buysellhandler.cpp +++ b/src/net/eathena/buysellhandler.cpp @@ -117,7 +117,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) } } -void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) +void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) const { switch (msg.readInt8()) { diff --git a/src/net/eathena/buysellhandler.h b/src/net/eathena/buysellhandler.h index c7bc5736c..0a1042174 100644 --- a/src/net/eathena/buysellhandler.h +++ b/src/net/eathena/buysellhandler.h @@ -43,7 +43,7 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler virtual void processNpcBuy(Net::MessageIn &msg); - virtual void processNpcSellResponse(Net::MessageIn &msg); + virtual void processNpcSellResponse(Net::MessageIn &msg) const; }; } // namespace EAthena diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 15bb42e88..07f3fbd8e 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -40,15 +40,15 @@ class AdminHandler final : public MessageHandler, public Ea::AdminHandler A_DELETE_COPY(AdminHandler) - void handleMessage(Net::MessageIn &msg); + void handleMessage(Net::MessageIn &msg) override; - void announce(const std::string &text) const; + void announce(const std::string &text) const override; - void localAnnounce(const std::string &text) const; + void localAnnounce(const std::string &text) const override; - void hide(const bool h) const; + void hide(const bool h) const override; - void kick(const int playerId) const; + void kick(const int playerId) const override; }; } // namespace TmwAthena diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index 3d6716a0f..39b868b24 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -40,11 +40,11 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler A_DELETE_COPY(BeingHandler) - virtual void handleMessage(Net::MessageIn &msg); + virtual void handleMessage(Net::MessageIn &msg) override; - virtual void requestNameById(const int id) const; + virtual void requestNameById(const int id) const override; - virtual void undress(Being *const being) const; + virtual void undress(Being *const being) const override; protected: virtual void processBeingChangeLook(Net::MessageIn &msg, diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 6e70fc364..5d173ae17 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -123,7 +123,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) } } -void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) +void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) const { switch (msg.readInt8()) { diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index 0e8b6b470..aa1092ffc 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -43,7 +43,7 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler virtual void processNpcBuy(Net::MessageIn &msg); - virtual void processNpcSellResponse(Net::MessageIn &msg); + virtual void processNpcSellResponse(Net::MessageIn &msg) const; }; } // namespace TmwAthena |