From 38f418870341b9f6c95a1b6cb16b6ad5c2d0a12f Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Tue, 14 May 2019 21:38:35 +0300
Subject: Add packet CMSG_REFINE_ADD_ITEM 0x0aa1

---
 src/CMakeLists.txt                 |  5 ++++
 src/Makefile.am                    |  5 ++++
 src/net/eathena/generalhandler.cpp |  4 +++
 src/net/eathena/generalhandler.h   |  2 ++
 src/net/eathena/packetsout.inc     | 15 +++++++++++
 src/net/eathena/refinehandler.cpp  | 53 ++++++++++++++++++++++++++++++++++++++
 src/net/eathena/refinehandler.h    | 42 ++++++++++++++++++++++++++++++
 src/net/net.cpp                    |  2 ++
 src/net/refinehandler.h            | 49 +++++++++++++++++++++++++++++++++++
 src/net/tmwa/generalhandler.cpp    |  3 +++
 src/net/tmwa/generalhandler.h      |  2 ++
 src/net/tmwa/refinehandler.cpp     | 43 +++++++++++++++++++++++++++++++
 src/net/tmwa/refinehandler.h       | 42 ++++++++++++++++++++++++++++++
 13 files changed, 267 insertions(+)
 create mode 100644 src/net/eathena/refinehandler.cpp
 create mode 100644 src/net/eathena/refinehandler.h
 create mode 100644 src/net/refinehandler.h
 create mode 100644 src/net/tmwa/refinehandler.cpp
 create mode 100644 src/net/tmwa/refinehandler.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5bd02a1a4..84526df9b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1590,6 +1590,7 @@ SET(SRCS
     net/maphandler.h
     net/markethandler.h
     net/mercenaryhandler.h
+    net/refinehandler.h
     net/roulettehandler.h
     net/searchstorehandler.h
     net/vendinghandler.h
@@ -1749,6 +1750,8 @@ SET(SRCS
     net/eathena/questrecv.cpp
     net/eathena/questrecv.h
     net/eathena/recvpackets.inc
+    net/eathena/refinehandler.cpp
+    net/eathena/refinehandler.h
     net/eathena/refinerecv.cpp
     net/eathena/refinerecv.h
     net/eathena/roulettehandler.cpp
@@ -2165,6 +2168,8 @@ SET(SRCS_TMWA
     net/tmwa/barterhandler.h
     net/tmwa/mercenaryhandler.cpp
     net/tmwa/mercenaryhandler.h
+    net/tmwa/refinehandler.cpp
+    net/tmwa/refinehandler.h
     net/tmwa/roulettehandler.cpp
     net/tmwa/roulettehandler.h
     net/tmwa/searchstorehandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index f73597d0b..d2279b33c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1838,6 +1838,8 @@ SRC += \
 	      net/tmwa/barterhandler.h \
 	      net/tmwa/mercenaryhandler.cpp \
 	      net/tmwa/mercenaryhandler.h \
+	      net/tmwa/refinehandler.cpp \
+	      net/tmwa/refinehandler.h \
 	      net/tmwa/roulettehandler.cpp \
 	      net/tmwa/roulettehandler.h \
 	      net/tmwa/searchstorehandler.cpp \
@@ -1904,6 +1906,7 @@ SRC += gui/windows/bankwindow.cpp \
 	      net/maphandler.h \
 	      net/markethandler.h \
 	      net/mercenaryhandler.h \
+	      net/refinehandler.h \
 	      net/roulettehandler.h \
 	      net/searchstorehandler.h \
 	      net/vendinghandler.h \
@@ -2063,6 +2066,8 @@ SRC += gui/windows/bankwindow.cpp \
 	      net/eathena/questrecv.cpp \
 	      net/eathena/questrecv.h \
 	      net/eathena/recvpackets.inc \
+	      net/eathena/refinehandler.cpp \
+	      net/eathena/refinehandler.h \
 	      net/eathena/refinerecv.cpp \
 	      net/eathena/refinerecv.h \
 	      net/eathena/roulettehandler.cpp \
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index acb53d8b6..d3729ef9f 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -64,6 +64,8 @@
 #include "net/eathena/partyhandler.h"
 #include "net/eathena/pethandler.h"
 #include "net/eathena/playerhandler.h"
+#include "net/eathena/refinehandler.h"
+#include "net/eathena/refinehandler.h"
 #include "net/eathena/roulettehandler.h"
 #include "net/eathena/searchstorehandler.h"
 #include "net/eathena/serverfeatures.h"
@@ -118,6 +120,7 @@ GeneralHandler::GeneralHandler() :
     mMarketHandler(new MarketHandler),
     mBarterHandler(new BarterHandler),
     mVendingHandler(new VendingHandler),
+    mRefineHandler(new RefineHandler),
     mRouletteHandler(new RouletteHandler),
     mSearchStoreHandler(new SearchStoreHandler)
 {
@@ -166,6 +169,7 @@ GeneralHandler::~GeneralHandler()
     delete2(mMarketHandler)
     delete2(mBarterHandler)
     delete2(mVendingHandler)
+    delete2(mRefineHandler)
     delete2(mRouletteHandler)
     delete2(mSearchStoreHandler)
 }
diff --git a/src/net/eathena/generalhandler.h b/src/net/eathena/generalhandler.h
index 509b01fcb..d50299ff4 100644
--- a/src/net/eathena/generalhandler.h
+++ b/src/net/eathena/generalhandler.h
@@ -64,6 +64,7 @@ class Mail2Handler;
 class MapHandler;
 class MarketHandler;
 class MercenaryHandler;
+class RefineHandler;
 class RouletteHandler;
 class SearchStoreHandler;
 class VendingHandler;
@@ -133,6 +134,7 @@ class GeneralHandler final : public Net::GeneralHandler
         MarketHandler *mMarketHandler;
         BarterHandler *mBarterHandler;
         VendingHandler *mVendingHandler;
+        RefineHandler *mRefineHandler;
         RouletteHandler *mRouletteHandler;
         SearchStoreHandler *mSearchStoreHandler;
 };
diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc
index 7c1a19e3a..d2d50a402 100644
--- a/src/net/eathena/packetsout.inc
+++ b/src/net/eathena/packetsout.inc
@@ -358,6 +358,7 @@ packet(CMSG_CLIENT_VERSION,               0x0000,   0, nullptr);
 packet(CMSG_PLAYER_STYLE_CLOSE,           0x0000,   0, nullptr);
 packet(CMSG_MAP_PING2,                    0x0000,   0, nullptr);
 packet(CMSG_ADMIN_RESET_COOLDOWNS,        0x0000,   0, nullptr);
+packet(CMSG_REFINE_ADD_ITEM,              0x0000,   0, nullptr);
 #else
 // 20040713
 if (packetVersion >= 20040713)
@@ -1396,6 +1397,18 @@ if (packetVersion >= 20160525)
     packet(CMSG_CAMERA_INFO,              0x0a77,  15, clif->pCameraInfo);
 }
 
+// 20161005 main
+if (packetVersionMain >= 20161005)
+{
+    packet(CMSG_REFINE_ADD_ITEM,          0x0aa1,   4, clif->pAddItemRefineryUI);
+}
+
+// 20161005 re
+if (packetVersionRe >= 20161005)
+{
+    packet(CMSG_REFINE_ADD_ITEM,          0x0aa1,   4, clif->pAddItemRefineryUI);
+}
+
 // 20170419
 if (packetVersion >= 20170419)
 {
@@ -1403,9 +1416,11 @@ if (packetVersion >= 20170419)
     packet(CMSG_MAIL2_REFRESH_MAIL_LIST,  0x0ac1,  26, clif->pRodexRefreshMaillist);
 }
 
+// zero
 if (packets_zero >= true)
 {
     packet(CMSG_PRIVATE_AIRSHIP_REQUEST,  0x0a49,  20, clif->pPrivateAirshipRequest);
+    packet(CMSG_REFINE_ADD_ITEM,          0x0aa1,   4, clif->pAddItemRefineryUI);
 }
 
 // 20171214 zero
diff --git a/src/net/eathena/refinehandler.cpp b/src/net/eathena/refinehandler.cpp
new file mode 100644
index 000000000..c6b3e0d25
--- /dev/null
+++ b/src/net/eathena/refinehandler.cpp
@@ -0,0 +1,53 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2011-2019  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/refinehandler.h"
+
+#include "const/net/inventory.h"
+
+#include "net/eathena/messageout.h"
+#include "net/eathena/protocolout.h"
+
+#include "debug.h"
+
+namespace EAthena
+{
+
+RefineHandler::RefineHandler() :
+    Net::RefineHandler()
+{
+    refineHandler = this;
+}
+
+RefineHandler::~RefineHandler()
+{
+    refineHandler = nullptr;
+}
+
+void RefineHandler::addItem(const Item *const item) const
+{
+    if (item == nullptr)
+        return;
+    createOutPacket(CMSG_REFINE_ADD_ITEM);
+    outMsg.writeInt16(CAST_S16(
+        item->getInvIndex() + INVENTORY_OFFSET), "inv index");
+}
+
+}  // namespace EAthena
diff --git a/src/net/eathena/refinehandler.h b/src/net/eathena/refinehandler.h
new file mode 100644
index 000000000..0c02fae99
--- /dev/null
+++ b/src/net/eathena/refinehandler.h
@@ -0,0 +1,42 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2011-2019  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_REFINEHANDLER_H
+#define NET_EATHENA_REFINEHANDLER_H
+
+#include "net/refinehandler.h"
+
+namespace EAthena
+{
+class RefineHandler final : public Net::RefineHandler
+{
+    public:
+        RefineHandler();
+
+        A_DELETE_COPY(RefineHandler)
+
+        ~RefineHandler() override final;
+
+        void addItem(const Item *const item) const override final;
+};
+
+}  // namespace EAthena
+
+#endif  // NET_EATHENA_REFINEHANDLER_H
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 03f59c2b8..fafc24cfe 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -58,6 +58,7 @@ namespace Net
     class MarketHandler;
     class MercenaryHandler;
     class SearchStoreHandler;
+    class RefineHandler;
     class RouletteHandler;
     class VendingHandler;
     class AdminHandler;
@@ -114,6 +115,7 @@ Net::MapHandler *mapHandler = nullptr;
 Net::MarketHandler *marketHandler = nullptr;
 Net::BarterHandler *barterHandler = nullptr;
 Net::MercenaryHandler *mercenaryHandler = nullptr;
+Net::RefineHandler *refineHandler = nullptr;
 Net::RouletteHandler *rouletteHandler = nullptr;
 Net::SearchStoreHandler *searchStoreHandler = nullptr;
 Net::VendingHandler *vendingHandler = nullptr;
diff --git a/src/net/refinehandler.h b/src/net/refinehandler.h
new file mode 100644
index 000000000..1b3498e22
--- /dev/null
+++ b/src/net/refinehandler.h
@@ -0,0 +1,49 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2011-2019  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_REFINEHANDLER_H
+#define NET_REFINEHANDLER_H
+
+#include "resources/item/item.h"
+
+#include "localconsts.h"
+
+namespace Net
+{
+
+class RefineHandler notfinal
+{
+    public:
+        RefineHandler()
+        { }
+
+        A_DELETE_COPY(RefineHandler)
+
+        virtual ~RefineHandler()
+        { }
+
+        virtual void addItem(const Item *const item) const = 0;
+};
+
+}  // namespace Net
+
+extern Net::RefineHandler *refineHandler;
+
+#endif  // NET_REFINEHANDLER_H
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 16b2445bf..6b6e4e9bd 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -67,6 +67,7 @@
 #include "net/tmwa/maphandler.h"
 #include "net/tmwa/markethandler.h"
 #include "net/tmwa/mercenaryhandler.h"
+#include "net/tmwa/refinehandler.h"
 #include "net/tmwa/roulettehandler.h"
 #include "net/tmwa/searchstorehandler.h"
 #include "net/tmwa/vendinghandler.h"
@@ -116,6 +117,7 @@ GeneralHandler::GeneralHandler() :
     mMarketHandler(new MarketHandler),
     mBarterHandler(new BarterHandler),
     mMercenaryHandler(new MercenaryHandler),
+    mRefineHandler(new RefineHandler),
     mRouletteHandler(new RouletteHandler),
     mSearchStoreHandler(new SearchStoreHandler),
     mVendingHandler(new VendingHandler)
@@ -164,6 +166,7 @@ GeneralHandler::~GeneralHandler()
     delete2(mMarketHandler)
     delete2(mBarterHandler)
     delete2(mMercenaryHandler)
+    delete2(mRefineHandler)
     delete2(mRouletteHandler)
     delete2(mSearchStoreHandler)
     delete2(mVendingHandler)
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index b2ded08a5..05a28930b 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -63,6 +63,7 @@ class MailHandler;
 class MapHandler;
 class MarketHandler;
 class MercenaryHandler;
+class RefineHandler;
 class RouletteHandler;
 class SearchStoreHandler;
 class VendingHandler;
@@ -131,6 +132,7 @@ class GeneralHandler final : public Net::GeneralHandler
         MarketHandler *mMarketHandler;
         BarterHandler *mBarterHandler;
         MercenaryHandler *mMercenaryHandler;
+        RefineHandler *mRefineHandler;
         RouletteHandler *mRouletteHandler;
         SearchStoreHandler *mSearchStoreHandler;
         VendingHandler *mVendingHandler;
diff --git a/src/net/tmwa/refinehandler.cpp b/src/net/tmwa/refinehandler.cpp
new file mode 100644
index 000000000..af0705303
--- /dev/null
+++ b/src/net/tmwa/refinehandler.cpp
@@ -0,0 +1,43 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2011-2019  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/tmwa/refinehandler.h"
+
+#include "debug.h"
+
+namespace TmwAthena
+{
+
+RefineHandler::RefineHandler() :
+    Net::RefineHandler()
+{
+    refineHandler = this;
+}
+
+RefineHandler::~RefineHandler()
+{
+    refineHandler = nullptr;
+}
+
+void RefineHandler::addItem(const Item *const item A_UNUSED) const
+{
+}
+
+}  // namespace TmwAthena
diff --git a/src/net/tmwa/refinehandler.h b/src/net/tmwa/refinehandler.h
new file mode 100644
index 000000000..d5ae231ab
--- /dev/null
+++ b/src/net/tmwa/refinehandler.h
@@ -0,0 +1,42 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2011-2019  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_TMWA_REFINEHANDLER_H
+#define NET_TMWA_REFINEHANDLER_H
+
+#include "net/refinehandler.h"
+
+namespace TmwAthena
+{
+class RefineHandler final : public Net::RefineHandler
+{
+    public:
+        RefineHandler();
+
+        A_DELETE_COPY(RefineHandler)
+
+        ~RefineHandler() override final;
+
+        void addItem(const Item *const item) const override final;
+};
+
+}  // namespace TmwAthena
+
+#endif  // NET_TMWA_REFINEHANDLER_H
-- 
cgit v1.2.3-70-g09d2