summaryrefslogtreecommitdiff
path: root/src/net/ea
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-27 00:10:16 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-27 00:10:16 +0300
commit18d8872333e2e433ce7b9e7be71706de37933097 (patch)
treedea07c5b7dcd29a3105b42b64ce0414e45f36b10 /src/net/ea
parent170b469cbcf4adcd82604a6b2efd5a0630ef3fb5 (diff)
downloadmanaplus-18d8872333e2e433ce7b9e7be71706de37933097.tar.gz
manaplus-18d8872333e2e433ce7b9e7be71706de37933097.tar.bz2
manaplus-18d8872333e2e433ce7b9e7be71706de37933097.tar.xz
manaplus-18d8872333e2e433ce7b9e7be71706de37933097.zip
improve some network handlers classes.
Diffstat (limited to 'src/net/ea')
-rw-r--r--src/net/ea/adminhandler.h14
-rw-r--r--src/net/ea/buysellhandler.cpp21
-rw-r--r--src/net/ea/buysellhandler.h17
3 files changed, 25 insertions, 27 deletions
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;