summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-27 19:41:58 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-27 19:41:58 +0300
commita23b30e3a3051393c8abd309be7376daf699a527 (patch)
tree44a5ce6c04839de3178390b7984b5db80a75959b /src/net
parentd3044d1572e42a28d21590aff4499896cd2e2b92 (diff)
downloadmanaverse-a23b30e3a3051393c8abd309be7376daf699a527.tar.gz
manaverse-a23b30e3a3051393c8abd309be7376daf699a527.tar.bz2
manaverse-a23b30e3a3051393c8abd309be7376daf699a527.tar.xz
manaverse-a23b30e3a3051393c8abd309be7376daf699a527.zip
Move receive code from markethandler into separate file.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/markethandler.cpp45
-rw-r--r--src/net/eathena/markethandler.h7
-rw-r--r--src/net/eathena/marketrecv.cpp83
-rw-r--r--src/net/eathena/marketrecv.h41
4 files changed, 128 insertions, 48 deletions
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index d0e8ff6ce..4e304b4ba 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -30,6 +30,7 @@
#include "gui/widgets/createwidget.h"
+#include "net/eathena/marketrecv.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -40,8 +41,6 @@ extern Net::MarketHandler *marketHandler;
namespace EAthena
{
-BuyDialog *MarketHandler::mBuyDialog = nullptr;
-
MarketHandler::MarketHandler() :
MessageHandler()
{
@@ -53,7 +52,7 @@ MarketHandler::MarketHandler() :
};
handledMessages = _messages;
marketHandler = this;
- mBuyDialog = nullptr;
+ MarketRecv::mBuyDialog = nullptr;
}
void MarketHandler::handleMessage(Net::MessageIn &msg)
@@ -61,11 +60,11 @@ void MarketHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_NPC_MARKET_OPEN:
- processMarketOpen(msg);
+ MarketRecv::processMarketOpen(msg);
break;
case SMSG_NPC_MARKET_BUY_ACK:
- processMarketBuyAck(msg);
+ MarketRecv::processMarketBuyAck(msg);
break;
default:
@@ -73,42 +72,6 @@ void MarketHandler::handleMessage(Net::MessageIn &msg)
}
}
-void MarketHandler::processMarketOpen(Net::MessageIn &msg)
-{
- const int len = (msg.readInt16("len") - 4) / 13;
-
- CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Market, BeingId));
- mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (int f = 0; f < len; f ++)
- {
- const int itemId = msg.readInt16("item id");
- const int type = msg.readUInt8("type");
- const int value = msg.readInt32("price");
- const int amount = msg.readInt32("amount");
- msg.readInt16("view");
- const ItemColor color = ItemColor_one;
- mBuyDialog->addItem(itemId, type, color, amount, value);
- }
- mBuyDialog->sort();
-}
-
-void MarketHandler::processMarketBuyAck(Net::MessageIn &msg)
-{
- const int len = (msg.readInt16("len") - 5) / 8;
- const int res = msg.readUInt8("result");
- for (int f = 0; f < len; f ++)
- {
- msg.readInt16("item id");
- msg.readInt16("amount");
- msg.readInt32("price");
- }
- if (res)
- NotifyManager::notify(NotifyTypes::BUY_DONE);
- else
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
-}
-
void MarketHandler::close()
{
createOutPacket(CMSG_NPC_MARKET_CLOSE);
diff --git a/src/net/eathena/markethandler.h b/src/net/eathena/markethandler.h
index e58ac1e68..3a843e4fd 100644
--- a/src/net/eathena/markethandler.h
+++ b/src/net/eathena/markethandler.h
@@ -45,13 +45,6 @@ class MarketHandler final : public MessageHandler,
const int type,
const ItemColor color,
const int amount) const override final;
-
- protected:
- static void processMarketOpen(Net::MessageIn &msg);
-
- static void processMarketBuyAck(Net::MessageIn &msg);
-
- static BuyDialog *mBuyDialog;
};
} // namespace EAthena
diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp
new file mode 100644
index 000000000..2c8a448ae
--- /dev/null
+++ b/src/net/eathena/marketrecv.cpp
@@ -0,0 +1,83 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/eathena/marketrecv.h"
+
+#include "notifymanager.h"
+
+#include "being/playerinfo.h"
+
+#include "enums/resources/notifytypes.h"
+
+#include "gui/windows/buydialog.h"
+
+#include "gui/widgets/createwidget.h"
+
+#include "net/eathena/messageout.h"
+#include "net/eathena/protocol.h"
+
+#include "debug.h"
+
+namespace EAthena
+{
+
+namespace MarketRecv
+{
+ BuyDialog *mBuyDialog = nullptr;
+} // namespace MarketRecv
+
+
+void MarketRecv::processMarketOpen(Net::MessageIn &msg)
+{
+ const int len = (msg.readInt16("len") - 4) / 13;
+
+ CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Market, BeingId));
+ mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
+
+ for (int f = 0; f < len; f ++)
+ {
+ const int itemId = msg.readInt16("item id");
+ const int type = msg.readUInt8("type");
+ const int value = msg.readInt32("price");
+ const int amount = msg.readInt32("amount");
+ msg.readInt16("view");
+ const ItemColor color = ItemColor_one;
+ mBuyDialog->addItem(itemId, type, color, amount, value);
+ }
+ mBuyDialog->sort();
+}
+
+void MarketRecv::processMarketBuyAck(Net::MessageIn &msg)
+{
+ const int len = (msg.readInt16("len") - 5) / 8;
+ const int res = msg.readUInt8("result");
+ for (int f = 0; f < len; f ++)
+ {
+ msg.readInt16("item id");
+ msg.readInt16("amount");
+ msg.readInt32("price");
+ }
+ if (res)
+ NotifyManager::notify(NotifyTypes::BUY_DONE);
+ else
+ NotifyManager::notify(NotifyTypes::BUY_FAILED);
+}
+
+} // namespace EAthena
diff --git a/src/net/eathena/marketrecv.h b/src/net/eathena/marketrecv.h
new file mode 100644
index 000000000..3686e5187
--- /dev/null
+++ b/src/net/eathena/marketrecv.h
@@ -0,0 +1,41 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_MARKETRECV_H
+#define NET_EATHENA_MARKETRECV_H
+
+#include "net/markethandler.h"
+
+#include "net/eathena/messagehandler.h"
+
+class BuyDialog;
+
+namespace EAthena
+{
+ namespace MarketRecv
+ {
+ extern BuyDialog *mBuyDialog;
+
+ void processMarketOpen(Net::MessageIn &msg);
+ void processMarketBuyAck(Net::MessageIn &msg);
+ } // namespace MarketRecv
+} // namespace EAthena
+
+#endif // NET_EATHENA_MARKETRECV_H