summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-24 22:47:15 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-24 22:47:15 +0300
commit7ffba524847fa15cff8764b8274b5aedfa08bf79 (patch)
treec19f145069919583c7fca506f51e3f5727de3a88 /src
parent7ac081450de48581d6141c90f504130c42cb5341 (diff)
downloadplus-7ffba524847fa15cff8764b8274b5aedfa08bf79.tar.gz
plus-7ffba524847fa15cff8764b8274b5aedfa08bf79.tar.bz2
plus-7ffba524847fa15cff8764b8274b5aedfa08bf79.tar.xz
plus-7ffba524847fa15cff8764b8274b5aedfa08bf79.zip
Move receive code from cashshophandler into separate file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/net/eathena/cashshophandler.cpp94
-rw-r--r--src/net/eathena/cashshophandler.h15
-rw-r--r--src/net/eathena/cashshoprecv.cpp119
-rw-r--r--src/net/eathena/cashshoprecv.h47
6 files changed, 178 insertions, 101 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3a4ae9271..6ebbaf146 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1540,6 +1540,8 @@ SET(SRCS_EATHENA
net/eathena/battlegroundhandler.h
net/eathena/cashshophandler.cpp
net/eathena/cashshophandler.h
+ net/eathena/cashshoprecv.cpp
+ net/eathena/cashshoprecv.h
net/eathena/beingrecv.cpp
net/eathena/beingrecv.h
net/eathena/beinghandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index d4943398d..fdf9611da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1386,6 +1386,8 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \
net/eathena/battlegroundhandler.h \
net/eathena/cashshophandler.cpp \
net/eathena/cashshophandler.h \
+ net/eathena/cashshoprecv.cpp \
+ net/eathena/cashshoprecv.h \
net/eathena/beingrecv.cpp \
net/eathena/beingrecv.h \
net/eathena/beinghandler.cpp \
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 012923424..7390ae600 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -26,6 +26,7 @@
#include "gui/widgets/createwidget.h"
+#include "net/eathena/cashshoprecv.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -36,8 +37,6 @@ extern Net::CashShopHandler *cashShopHandler;
namespace EAthena
{
-BuyDialog *CashShopHandler::mBuyDialog = nullptr;
-
CashShopHandler::CashShopHandler() :
MessageHandler()
{
@@ -53,7 +52,7 @@ CashShopHandler::CashShopHandler() :
};
handledMessages = _messages;
cashShopHandler = this;
- mBuyDialog = nullptr;
+ CashShopRecv::mBuyDialog = nullptr;
}
void CashShopHandler::handleMessage(Net::MessageIn &msg)
@@ -61,27 +60,27 @@ void CashShopHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_NPC_CASH_SHOP_OPEN:
- processCashShopOpen(msg);
+ CashShopRecv::processCashShopOpen(msg);
break;
case SMSG_NPC_CASH_BUY_ACK:
- processCashShopBuyAck(msg);
+ CashShopRecv::processCashShopBuyAck(msg);
break;
case SMSG_NPC_CASH_POINTS:
- processCashShopPoints(msg);
+ CashShopRecv::processCashShopPoints(msg);
break;
case SMSG_NPC_CASH_BUY:
- processCashShopBuy(msg);
+ CashShopRecv::processCashShopBuy(msg);
break;
case SMSG_NPC_CASH_TAB_PRICE_LIST:
- processCashShopTabPriceList(msg);
+ CashShopRecv::processCashShopTabPriceList(msg);
break;
case SMSG_NPC_CASH_SCHEDULE:
- processCashShopSchedule(msg);
+ CashShopRecv::processCashShopSchedule(msg);
break;
default:
@@ -89,83 +88,6 @@ void CashShopHandler::handleMessage(Net::MessageIn &msg)
}
}
-void CashShopHandler::processCashShopOpen(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 12) / 11;
-
- CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Cash, BeingId));
- mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
-
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("price");
- const int value = msg.readInt32("discount price");
- const int type = msg.readUInt8("item type");
- const int itemId = msg.readInt16("item id");
- const ItemColor color = ItemColor_one;
- mBuyDialog->addItem(itemId, type, color, 0, value);
- }
- mBuyDialog->sort();
-}
-
-void CashShopHandler::processCashShopBuyAck(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
- msg.readInt16("error");
-}
-
-void CashShopHandler::processCashShopPoints(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
-}
-
-void CashShopHandler::processCashShopBuy(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- msg.readInt32("id");
- msg.readInt16("result");
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
-}
-
-void CashShopHandler::processCashShopTabPriceList(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- const int count = (msg.readInt16("len") - 10) / 6;
- msg.readInt32("tab");
- const int itemsCount = msg.readInt16("count");
- if (count != itemsCount)
- logger->log("error: wrong list count");
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item id");
- msg.readInt32("price");
- }
-}
-
-void CashShopHandler::processCashShopSchedule(Net::MessageIn &msg)
-{
- UNIMPLIMENTEDPACKET;
- const int count = (msg.readInt16("len") - 8) / 6;
- const int itemsCount = msg.readInt16("count");
- msg.readInt16("tab");
- if (count != itemsCount)
- logger->log("error: wrong list count");
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item id");
- msg.readInt32("price");
- }
-}
-
void CashShopHandler::buyItem(const int points,
const int itemId,
const ItemColor color A_UNUSED,
diff --git a/src/net/eathena/cashshophandler.h b/src/net/eathena/cashshophandler.h
index 851b62527..fd776c923 100644
--- a/src/net/eathena/cashshophandler.h
+++ b/src/net/eathena/cashshophandler.h
@@ -53,21 +53,6 @@ class CashShopHandler final : public MessageHandler,
void requestTab(const int tab) const override final;
void schedule() const override final;
-
- protected:
- static void processCashShopOpen(Net::MessageIn &msg);
-
- static void processCashShopBuyAck(Net::MessageIn &msg);
-
- static void processCashShopPoints(Net::MessageIn &msg);
-
- static void processCashShopBuy(Net::MessageIn &msg);
-
- static void processCashShopTabPriceList(Net::MessageIn &msg);
-
- static void processCashShopSchedule(Net::MessageIn &msg);
-
- static BuyDialog *mBuyDialog;
};
} // namespace EAthena
diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp
new file mode 100644
index 000000000..a25a44406
--- /dev/null
+++ b/src/net/eathena/cashshoprecv.cpp
@@ -0,0 +1,119 @@
+/*
+ * 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/cashshoprecv.h"
+
+#include "being/playerinfo.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 CashShopRecv
+{
+ BuyDialog *mBuyDialog;
+}
+
+void CashShopRecv::processCashShopOpen(Net::MessageIn &msg)
+{
+ const int count = (msg.readInt16("len") - 12) / 11;
+
+ CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Cash, BeingId));
+ mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
+
+ msg.readInt32("cash points");
+ msg.readInt32("kafra points");
+ for (int f = 0; f < count; f ++)
+ {
+ msg.readInt32("price");
+ const int value = msg.readInt32("discount price");
+ const int type = msg.readUInt8("item type");
+ const int itemId = msg.readInt16("item id");
+ const ItemColor color = ItemColor_one;
+ mBuyDialog->addItem(itemId, type, color, 0, value);
+ }
+ mBuyDialog->sort();
+}
+
+void CashShopRecv::processCashShopBuyAck(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ msg.readInt32("cash points");
+ msg.readInt32("kafra points");
+ msg.readInt16("error");
+}
+
+void CashShopRecv::processCashShopPoints(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ msg.readInt32("cash points");
+ msg.readInt32("kafra points");
+}
+
+void CashShopRecv::processCashShopBuy(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ msg.readInt32("id");
+ msg.readInt16("result");
+ msg.readInt32("cash points");
+ msg.readInt32("kafra points");
+}
+
+void CashShopRecv::processCashShopTabPriceList(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ const int count = (msg.readInt16("len") - 10) / 6;
+ msg.readInt32("tab");
+ const int itemsCount = msg.readInt16("count");
+ if (count != itemsCount)
+ logger->log("error: wrong list count");
+
+ for (int f = 0; f < count; f ++)
+ {
+ msg.readInt16("item id");
+ msg.readInt32("price");
+ }
+}
+
+void CashShopRecv::processCashShopSchedule(Net::MessageIn &msg)
+{
+ UNIMPLIMENTEDPACKET;
+ const int count = (msg.readInt16("len") - 8) / 6;
+ const int itemsCount = msg.readInt16("count");
+ msg.readInt16("tab");
+ if (count != itemsCount)
+ logger->log("error: wrong list count");
+
+ for (int f = 0; f < count; f ++)
+ {
+ msg.readInt16("item id");
+ msg.readInt32("price");
+ }
+}
+
+} // namespace EAthena
diff --git a/src/net/eathena/cashshoprecv.h b/src/net/eathena/cashshoprecv.h
new file mode 100644
index 000000000..1dee0df5f
--- /dev/null
+++ b/src/net/eathena/cashshoprecv.h
@@ -0,0 +1,47 @@
+/*
+ * 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_CASHSHOPRECV_H
+#define NET_EATHENA_CASHSHOPRECV_H
+
+#ifdef EATHENA_SUPPORT
+
+#include "net/cashshophandler.h"
+
+#include "net/eathena/messagehandler.h"
+
+class BuyDialog;
+
+namespace EAthena
+{
+ namespace CashShopRecv
+ {
+ extern BuyDialog *mBuyDialog;
+ void processCashShopOpen(Net::MessageIn &msg);
+ void processCashShopBuyAck(Net::MessageIn &msg);
+ void processCashShopPoints(Net::MessageIn &msg);
+ void processCashShopBuy(Net::MessageIn &msg);
+ void processCashShopTabPriceList(Net::MessageIn &msg);
+ void processCashShopSchedule(Net::MessageIn &msg);
+ } // namespace CashShopRecv
+} // namespace EAthena
+
+#endif // EATHENA_SUPPORT
+#endif // NET_EATHENA_CASHSHOPRECV_H