From 75802940ea0f10c4ecce5ab55140c38a164ba574 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Tue, 29 Dec 2015 02:21:53 +0300
Subject: Move shopitem into item directory.

---
 src/CMakeLists.txt                        |   4 +-
 src/Makefile.am                           |   4 +-
 src/gui/models/shopitems.cpp              |   2 +-
 src/gui/widgets/selldialog.cpp            |   3 +-
 src/gui/widgets/shoplistbox.cpp           |   3 +-
 src/gui/windows/buyingstoreselldialog.cpp |   3 +-
 src/gui/windows/eggselectiondialog.cpp    |   4 +-
 src/gui/windows/insertcarddialog.cpp      |   4 +-
 src/gui/windows/shopwindow.cpp            |   3 +-
 src/net/buysellhandler.h                  |   2 +-
 src/net/eathena/buyingstorehandler.cpp    |   4 +-
 src/net/eathena/markethandler.cpp         |   4 +-
 src/net/eathena/npchandler.cpp            |   4 +-
 src/net/eathena/vendinghandler.cpp        |   4 +-
 src/net/eathena/vendingrecv.cpp           |   3 +-
 src/resources/item/shopitem.cpp           | 166 ++++++++++++++++++++++++++++
 src/resources/item/shopitem.h             | 178 ++++++++++++++++++++++++++++++
 src/shopitem.cpp                          | 166 ----------------------------
 src/shopitem.h                            | 178 ------------------------------
 19 files changed, 372 insertions(+), 367 deletions(-)
 create mode 100644 src/resources/item/shopitem.cpp
 create mode 100644 src/resources/item/shopitem.h
 delete mode 100644 src/shopitem.cpp
 delete mode 100644 src/shopitem.h

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 08df3344a..b483657e9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1117,8 +1117,8 @@ SET(SRCS
     sdlshared.h
     settings.cpp
     settings.h
-    shopitem.cpp
-    shopitem.h
+    resources/item/shopitem.cpp
+    resources/item/shopitem.h
     gui/shortcut/shortcutbase.cpp
     gui/shortcut/shortcutbase.h
     resources/animation/simpleanimation.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 02310a8e5..a555b0a06 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -755,8 +755,8 @@ manaplus_SOURCES += main.cpp \
 	      enums/being/pickup.h \
 	      beingequipbackend.cpp \
 	      beingequipbackend.h \
-	      shopitem.cpp \
-	      shopitem.h \
+	      resources/item/shopitem.cpp \
+	      resources/item/shopitem.h \
 	      flooritem.cpp \
 	      flooritem.h \
 	      game.cpp \
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 05c4a5e6c..f121fb8d6 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -22,7 +22,7 @@
 
 #include "gui/models/shopitems.h"
 
-#include "shopitem.h"
+#include "resources/item/shopitem.h"
 
 #include "utils/dtor.h"
 
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 8488e4157..2e6e20b86 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -22,7 +22,6 @@
 
 #include "gui/widgets/selldialog.h"
 
-#include "shopitem.h"
 #include "units.h"
 
 #include "gui/windows/setupwindow.h"
@@ -43,6 +42,8 @@
 #include "utils/gettext.h"
 #include "utils/stringutils.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 SellDialog::DialogList SellDialog::instances;
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 6cdf58d2e..e10011f16 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -23,7 +23,6 @@
 #include "gui/widgets/shoplistbox.h"
 
 #include "settings.h"
-#include "shopitem.h"
 
 #include "being/playerinfo.h"
 
@@ -38,6 +37,8 @@
 
 #include "resources/image.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 const int ITEM_ICON_SIZE = 32;
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
index a93ee53f6..c4425b6aa 100644
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ b/src/gui/windows/buyingstoreselldialog.cpp
@@ -24,7 +24,6 @@
 
 #include "actormanager.h"
 #include "inventory.h"
-#include "shopitem.h"
 
 #include "being/playerinfo.h"
 
@@ -34,6 +33,8 @@
 
 #include "net/buyingstorehandler.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 BuyingStoreSellDialog::BuyingStoreSellDialog(const BeingId accountId,
diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp
index 81c283b8c..7d5b4b239 100644
--- a/src/gui/windows/eggselectiondialog.cpp
+++ b/src/gui/windows/eggselectiondialog.cpp
@@ -22,8 +22,6 @@
 
 #include "gui/windows/eggselectiondialog.h"
 
-#include "shopitem.h"
-
 #include "gui/models/shopitems.h"
 
 #include "gui/widgets/button.h"
@@ -33,6 +31,8 @@
 
 #include "utils/gettext.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 EggSelectionDialog::EggSelectionDialog() :
diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp
index 1c8800f88..fad378485 100644
--- a/src/gui/windows/insertcarddialog.cpp
+++ b/src/gui/windows/insertcarddialog.cpp
@@ -22,8 +22,6 @@
 
 #include "gui/windows/insertcarddialog.h"
 
-#include "shopitem.h"
-
 #include "gui/models/shopitems.h"
 
 #include "gui/widgets/button.h"
@@ -34,6 +32,8 @@
 #include "utils/gettext.h"
 #include "utils/stringutils.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 InsertCardDialog::InsertCardDialog(const int itemIndex,
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 19a7e31b8..127f0fbcd 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -62,7 +62,6 @@
 #include "configuration.h"
 #include "inventory.h"
 #include "settings.h"
-#include "shopitem.h"
 
 #include "being/localplayer.h"
 #include "being/playerinfo.h"
@@ -87,6 +86,8 @@
 #include "resources/iteminfo.h"
 #endif
 
+#include "resources/item/shopitem.h"
+
 #include <sys/stat.h>
 
 #include <sstream>
diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h
index 7e7472ce6..48d76d67b 100644
--- a/src/net/buysellhandler.h
+++ b/src/net/buysellhandler.h
@@ -23,7 +23,7 @@
 #ifndef NET_BUYSELLHANDLER_H
 #define NET_BUYSELLHANDLER_H
 
-#include "shopitem.h"
+#include "resources/item/shopitem.h"
 
 namespace Net
 {
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index 8ff7f65bb..163e0bd79 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -20,8 +20,6 @@
 
 #include "net/eathena/buyingstorehandler.h"
 
-#include "shopitem.h"
-
 #include "being/being.h"
 #include "being/playerinfo.h"
 
@@ -30,6 +28,8 @@
 #include "net/eathena/messageout.h"
 #include "net/eathena/protocolout.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 extern Net::BuyingStoreHandler *buyingStoreHandler;
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
index 47aa05418..2f582c763 100644
--- a/src/net/eathena/markethandler.cpp
+++ b/src/net/eathena/markethandler.cpp
@@ -18,14 +18,14 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "shopitem.h"
-
 #include "net/eathena/markethandler.h"
 
 #include "net/eathena/marketrecv.h"
 #include "net/eathena/messageout.h"
 #include "net/eathena/protocolout.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 extern Net::MarketHandler *marketHandler;
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
index 5a267c25e..a55e59aa7 100644
--- a/src/net/eathena/npchandler.cpp
+++ b/src/net/eathena/npchandler.cpp
@@ -22,8 +22,6 @@
 
 #include "net/eathena/npchandler.h"
 
-#include "shopitem.h"
-
 #include "being/localplayer.h"
 
 #include "const/net/inventory.h"
@@ -39,6 +37,8 @@
 #include "net/eathena/messageout.h"
 #include "net/eathena/protocolout.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 extern Net::NpcHandler *npcHandler;
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
index 5a0661ae4..c448b627b 100644
--- a/src/net/eathena/vendinghandler.cpp
+++ b/src/net/eathena/vendinghandler.cpp
@@ -20,8 +20,6 @@
 
 #include "net/eathena/vendinghandler.h"
 
-#include "shopitem.h"
-
 #include "being/being.h"
 #include "being/playerinfo.h"
 
@@ -31,6 +29,8 @@
 #include "net/eathena/protocolout.h"
 #include "net/eathena/vendingrecv.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 extern Net::VendingHandler *vendingHandler;
diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp
index 146f2102e..8ba684e0c 100644
--- a/src/net/eathena/vendingrecv.cpp
+++ b/src/net/eathena/vendingrecv.cpp
@@ -22,7 +22,6 @@
 
 #include "actormanager.h"
 #include "itemcolormanager.h"
-#include "shopitem.h"
 
 #include "being/localplayer.h"
 #include "being/playerinfo.h"
@@ -36,6 +35,8 @@
 
 #include "net/messagein.h"
 
+#include "resources/item/shopitem.h"
+
 #include "debug.h"
 
 extern int packetVersion;
diff --git a/src/resources/item/shopitem.cpp b/src/resources/item/shopitem.cpp
new file mode 100644
index 000000000..78a29065d
--- /dev/null
+++ b/src/resources/item/shopitem.cpp
@@ -0,0 +1,166 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2004-2009  The Mana World Development Team
+ *  Copyright (C) 2009-2010  The Mana Developers
+ *  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 "resources/item/shopitem.h"
+
+#include "units.h"
+
+#include "resources/iteminfo.h"
+
+#include "utils/stringutils.h"
+
+#include "net/serverfeatures.h"
+
+#include "debug.h"
+
+ShopItem::ShopItem(const int inventoryIndex,
+                   const int id,
+                   const int type,
+                   const ItemColor color,
+                   const int quantity,
+                   const int price) :
+    Item(id, type, 0, 0, color,
+         Identified_true,
+         Damaged_false,
+         Favorite_false,
+         Equipm_false,
+         Equipped_false),
+    mDisplayName(),
+    mDuplicates(),
+    mPrice(price),
+    mUsedQuantity(0),
+    mShowQuantity(true),
+    mVisible(true),
+    mDisabled(false)
+{
+    updateDisplayName(quantity);
+    setInvIndex(inventoryIndex);
+    addDuplicate(inventoryIndex, quantity);
+}
+
+ShopItem::ShopItem(const int id,
+                   const int type,
+                   const ItemColor color,
+                   const int price) :
+    Item(id, type, 0, 0, color,
+         Identified_true,
+         Damaged_false,
+         Favorite_false,
+         Equipm_false,
+         Equipped_false),
+    mDisplayName(),
+    mDuplicates(),
+    mPrice(price),
+    mUsedQuantity(0),
+    mShowQuantity(false),
+    mVisible(true),
+    mDisabled(false)
+{
+    updateDisplayName(0);
+    setInvIndex(-1);
+    addDuplicate(-1, 0);
+}
+
+ShopItem::~ShopItem()
+{
+    /** Clear all remaining duplicates on Object destruction. */
+    while (!mDuplicates.empty())
+    {
+        delete mDuplicates.top();
+        mDuplicates.pop();
+    }
+}
+
+void ShopItem::updateDisplayName(const int quantity)
+{
+    if (serverFeatures->haveItemColors())
+        mDisplayName = std::string(getInfo().getName(mColor));
+    else
+        mDisplayName = std::string(getInfo().getName());
+    if (mPrice)
+    {
+        mDisplayName.append(" (").append(
+            Units::formatCurrency(mPrice)).append(") ");
+    }
+    if (mShowQuantity && quantity > 1)
+        mDisplayName.append("[").append(toString(quantity)).append("]");
+    if (mUsedQuantity > 0)
+        mDisplayName.append(" +").append(toString(mUsedQuantity));
+}
+
+void ShopItem::update()
+{
+    updateDisplayName(mQuantity);
+}
+
+void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
+{
+    DuplicateItem *const di = new DuplicateItem;
+    di->inventoryIndex = inventoryIndex;
+    di->quantity = quantity;
+    mDuplicates.push(di);
+    mQuantity += quantity;
+}
+
+void ShopItem::addDuplicate()
+{
+    DuplicateItem *const di = new DuplicateItem;
+    di->inventoryIndex = -1;
+    di->quantity = 0;
+    mDuplicates.push(di);
+}
+
+int ShopItem::sellCurrentDuplicate(const int quantity)
+{
+    DuplicateItem* dupl = mDuplicates.top();
+    if (!dupl)
+        return 0;
+
+    const int sellCount = quantity <= dupl->quantity
+        ? quantity : dupl->quantity;
+    dupl->quantity -= sellCount;
+    mQuantity -= sellCount;
+    if (dupl->quantity == 0)
+    {
+        delete dupl;
+        mDuplicates.pop();
+    }
+    return sellCount;
+}
+
+void ShopItem::increaseUsedQuantity(const int amount)
+{
+    if (mShowQuantity && mQuantity)
+    {
+        if (mQuantity < mUsedQuantity + amount ||
+            mUsedQuantity + amount < 0)
+        {
+            return;
+        }
+    }
+    else if (mUsedQuantity + amount < 0)
+    {
+        return;
+    }
+
+    mUsedQuantity += amount;
+}
diff --git a/src/resources/item/shopitem.h b/src/resources/item/shopitem.h
new file mode 100644
index 000000000..e5f9efe0d
--- /dev/null
+++ b/src/resources/item/shopitem.h
@@ -0,0 +1,178 @@
+/*
+ *  The ManaPlus Client
+ *  Copyright (C) 2004-2009  The Mana World Development Team
+ *  Copyright (C) 2009-2010  The Mana Developers
+ *  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 RESOURCES_ITEM_SHOPITEM_H
+#define RESOURCES_ITEM_SHOPITEM_H
+
+#include "resources/item/item.h"
+
+#include <stack>
+
+#include "localconsts.h"
+
+/**
+ * Represents an item in a shop inventory. It can store quantity and inventory
+ * indices of duplicate entries in the shop as well.
+ */
+class ShopItem final : public Item
+{
+    public:
+        /**
+         * Constructor. Creates a new ShopItem.
+         *
+         * @param inventoryIndex the inventory index of the item
+         * @param id the id of the item
+         * @param quantity number of available copies of the item
+         * @param price price of the item
+         */
+        ShopItem(const int inventoryIndex,
+                 const int id,
+                 const int type,
+                 const ItemColor color,
+                 const int quantity,
+                 const int price);
+
+        /**
+         * Constructor. Creates a new ShopItem. Inventory index will be set to
+         * -1 and quantity to 0.
+         *
+         * @param id the id of the item
+         * @param price price of the item
+         */
+        ShopItem(const int id,
+                 const int type,
+                 const ItemColor color,
+                 const int price);
+
+        A_DELETE_COPY(ShopItem)
+
+        /**
+         * Destructor.
+         */
+        ~ShopItem();
+
+        /**
+         * Add a duplicate. Id and price will be taken from this item.
+         *
+         * @param inventoryIndex the inventory index of the item
+         * @param quantity number of available copies of the item
+         */
+        void addDuplicate(const int inventoryIndex, const int quantity);
+
+        /**
+         * Add a duplicate. Id and price will be taken from this item.
+         * Needed for compatibility with ShopDuplicateItems (see) class
+         * documentation).
+         */
+        void addDuplicate();
+
+        void update();
+
+        /**
+         * Gets the quantity of the currently topmost duplicate.
+         *
+         * @return the quantity of the currently topmost duplicate
+         */
+        int getCurrentQuantity() const A_WARN_UNUSED
+        {
+            return mDuplicates.empty() ? 0 : mDuplicates.top()->quantity;
+        }
+
+        /**
+         * Gets the inventory index of the currently topmost duplicate.
+         *
+         * @return the inventory index of the currently topmost duplicate
+         */
+        int getCurrentInvIndex() const A_WARN_UNUSED
+        {
+            return mDuplicates.empty() ? mInvIndex :
+                   mDuplicates.top()->inventoryIndex;
+        }
+
+        /**
+         * Reduces the quantity of the topmost duplicate by the specified
+         * amount. Also reduces the total quantity of this DuplicateItem.
+         * Empty duplicates are automatically removed.
+         *
+         * If the amount is bigger than the quantity of the current topmost,
+         * only sell as much as possible. Returns the amount actually sold (do
+         * not ignore the return value!)
+         *
+         * @return the amount, that actually was sold.
+         */
+        int sellCurrentDuplicate(const int quantity);
+
+        /**
+         * Gets the price of the item.
+         *
+         * @return the price of the item
+         */
+        int getPrice() const A_WARN_UNUSED
+        { return mPrice; }
+
+        /**
+         * Gets the display name for the item in the shop list.
+         *
+         * @return the display name for the item in the shop list
+         */
+        const std::string &getDisplayName() const A_WARN_UNUSED
+        { return mDisplayName; }
+
+        void setVisible(const bool b)
+        { mVisible = b; }
+
+        bool isVisible() const
+        { return mVisible; }
+
+        void increaseUsedQuantity(const int amount);
+
+        int getUsedQuantity() const A_WARN_UNUSED
+        { return mUsedQuantity; }
+
+        void setDisabled(const bool b)
+        { mDisabled = b; }
+
+        bool getDisabled() const A_WARN_UNUSED
+        { return mDisabled; }
+
+    protected:
+        void updateDisplayName(const int quantity);
+
+        std::string mDisplayName;
+
+        /**
+         * Struct to keep track of duplicates.
+         */
+        typedef struct
+        {
+            int inventoryIndex;
+            int quantity;
+        } DuplicateItem;
+        std::stack<DuplicateItem*> mDuplicates; /** <-- Stores duplicates */
+        int mPrice;
+        int mUsedQuantity;
+        bool mShowQuantity;
+        bool mVisible;
+        bool mDisabled;
+};
+
+#endif  // RESOURCES_ITEM_SHOPITEM_H
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
deleted file mode 100644
index e31179772..000000000
--- a/src/shopitem.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- *  The ManaPlus Client
- *  Copyright (C) 2004-2009  The Mana World Development Team
- *  Copyright (C) 2009-2010  The Mana Developers
- *  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 "shopitem.h"
-
-#include "units.h"
-
-#include "resources/iteminfo.h"
-
-#include "utils/stringutils.h"
-
-#include "net/serverfeatures.h"
-
-#include "debug.h"
-
-ShopItem::ShopItem(const int inventoryIndex,
-                   const int id,
-                   const int type,
-                   const ItemColor color,
-                   const int quantity,
-                   const int price) :
-    Item(id, type, 0, 0, color,
-         Identified_true,
-         Damaged_false,
-         Favorite_false,
-         Equipm_false,
-         Equipped_false),
-    mDisplayName(),
-    mDuplicates(),
-    mPrice(price),
-    mUsedQuantity(0),
-    mShowQuantity(true),
-    mVisible(true),
-    mDisabled(false)
-{
-    updateDisplayName(quantity);
-    setInvIndex(inventoryIndex);
-    addDuplicate(inventoryIndex, quantity);
-}
-
-ShopItem::ShopItem(const int id,
-                   const int type,
-                   const ItemColor color,
-                   const int price) :
-    Item(id, type, 0, 0, color,
-         Identified_true,
-         Damaged_false,
-         Favorite_false,
-         Equipm_false,
-         Equipped_false),
-    mDisplayName(),
-    mDuplicates(),
-    mPrice(price),
-    mUsedQuantity(0),
-    mShowQuantity(false),
-    mVisible(true),
-    mDisabled(false)
-{
-    updateDisplayName(0);
-    setInvIndex(-1);
-    addDuplicate(-1, 0);
-}
-
-ShopItem::~ShopItem()
-{
-    /** Clear all remaining duplicates on Object destruction. */
-    while (!mDuplicates.empty())
-    {
-        delete mDuplicates.top();
-        mDuplicates.pop();
-    }
-}
-
-void ShopItem::updateDisplayName(const int quantity)
-{
-    if (serverFeatures->haveItemColors())
-        mDisplayName = std::string(getInfo().getName(mColor));
-    else
-        mDisplayName = std::string(getInfo().getName());
-    if (mPrice)
-    {
-        mDisplayName.append(" (").append(
-            Units::formatCurrency(mPrice)).append(") ");
-    }
-    if (mShowQuantity && quantity > 1)
-        mDisplayName.append("[").append(toString(quantity)).append("]");
-    if (mUsedQuantity > 0)
-        mDisplayName.append(" +").append(toString(mUsedQuantity));
-}
-
-void ShopItem::update()
-{
-    updateDisplayName(mQuantity);
-}
-
-void ShopItem::addDuplicate(const int inventoryIndex, const int quantity)
-{
-    DuplicateItem *const di = new DuplicateItem;
-    di->inventoryIndex = inventoryIndex;
-    di->quantity = quantity;
-    mDuplicates.push(di);
-    mQuantity += quantity;
-}
-
-void ShopItem::addDuplicate()
-{
-    DuplicateItem *const di = new DuplicateItem;
-    di->inventoryIndex = -1;
-    di->quantity = 0;
-    mDuplicates.push(di);
-}
-
-int ShopItem::sellCurrentDuplicate(const int quantity)
-{
-    DuplicateItem* dupl = mDuplicates.top();
-    if (!dupl)
-        return 0;
-
-    const int sellCount = quantity <= dupl->quantity
-        ? quantity : dupl->quantity;
-    dupl->quantity -= sellCount;
-    mQuantity -= sellCount;
-    if (dupl->quantity == 0)
-    {
-        delete dupl;
-        mDuplicates.pop();
-    }
-    return sellCount;
-}
-
-void ShopItem::increaseUsedQuantity(const int amount)
-{
-    if (mShowQuantity && mQuantity)
-    {
-        if (mQuantity < mUsedQuantity + amount ||
-            mUsedQuantity + amount < 0)
-        {
-            return;
-        }
-    }
-    else if (mUsedQuantity + amount < 0)
-    {
-        return;
-    }
-
-    mUsedQuantity += amount;
-}
diff --git a/src/shopitem.h b/src/shopitem.h
deleted file mode 100644
index cfafbec50..000000000
--- a/src/shopitem.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- *  The ManaPlus Client
- *  Copyright (C) 2004-2009  The Mana World Development Team
- *  Copyright (C) 2009-2010  The Mana Developers
- *  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 SHOPITEM_H
-#define SHOPITEM_H
-
-#include "resources/item/item.h"
-
-#include <stack>
-
-#include "localconsts.h"
-
-/**
- * Represents an item in a shop inventory. It can store quantity and inventory
- * indices of duplicate entries in the shop as well.
- */
-class ShopItem final : public Item
-{
-    public:
-        /**
-         * Constructor. Creates a new ShopItem.
-         *
-         * @param inventoryIndex the inventory index of the item
-         * @param id the id of the item
-         * @param quantity number of available copies of the item
-         * @param price price of the item
-         */
-        ShopItem(const int inventoryIndex,
-                 const int id,
-                 const int type,
-                 const ItemColor color,
-                 const int quantity,
-                 const int price);
-
-        /**
-         * Constructor. Creates a new ShopItem. Inventory index will be set to
-         * -1 and quantity to 0.
-         *
-         * @param id the id of the item
-         * @param price price of the item
-         */
-        ShopItem(const int id,
-                 const int type,
-                 const ItemColor color,
-                 const int price);
-
-        A_DELETE_COPY(ShopItem)
-
-        /**
-         * Destructor.
-         */
-        ~ShopItem();
-
-        /**
-         * Add a duplicate. Id and price will be taken from this item.
-         *
-         * @param inventoryIndex the inventory index of the item
-         * @param quantity number of available copies of the item
-         */
-        void addDuplicate(const int inventoryIndex, const int quantity);
-
-        /**
-         * Add a duplicate. Id and price will be taken from this item.
-         * Needed for compatibility with ShopDuplicateItems (see) class
-         * documentation).
-         */
-        void addDuplicate();
-
-        void update();
-
-        /**
-         * Gets the quantity of the currently topmost duplicate.
-         *
-         * @return the quantity of the currently topmost duplicate
-         */
-        int getCurrentQuantity() const A_WARN_UNUSED
-        {
-            return mDuplicates.empty() ? 0 : mDuplicates.top()->quantity;
-        }
-
-        /**
-         * Gets the inventory index of the currently topmost duplicate.
-         *
-         * @return the inventory index of the currently topmost duplicate
-         */
-        int getCurrentInvIndex() const A_WARN_UNUSED
-        {
-            return mDuplicates.empty() ? mInvIndex :
-                   mDuplicates.top()->inventoryIndex;
-        }
-
-        /**
-         * Reduces the quantity of the topmost duplicate by the specified
-         * amount. Also reduces the total quantity of this DuplicateItem.
-         * Empty duplicates are automatically removed.
-         *
-         * If the amount is bigger than the quantity of the current topmost,
-         * only sell as much as possible. Returns the amount actually sold (do
-         * not ignore the return value!)
-         *
-         * @return the amount, that actually was sold.
-         */
-        int sellCurrentDuplicate(const int quantity);
-
-        /**
-         * Gets the price of the item.
-         *
-         * @return the price of the item
-         */
-        int getPrice() const A_WARN_UNUSED
-        { return mPrice; }
-
-        /**
-         * Gets the display name for the item in the shop list.
-         *
-         * @return the display name for the item in the shop list
-         */
-        const std::string &getDisplayName() const A_WARN_UNUSED
-        { return mDisplayName; }
-
-        void setVisible(const bool b)
-        { mVisible = b; }
-
-        bool isVisible() const
-        { return mVisible; }
-
-        void increaseUsedQuantity(const int amount);
-
-        int getUsedQuantity() const A_WARN_UNUSED
-        { return mUsedQuantity; }
-
-        void setDisabled(const bool b)
-        { mDisabled = b; }
-
-        bool getDisabled() const A_WARN_UNUSED
-        { return mDisabled; }
-
-    protected:
-        void updateDisplayName(const int quantity);
-
-        std::string mDisplayName;
-
-        /**
-         * Struct to keep track of duplicates.
-         */
-        typedef struct
-        {
-            int inventoryIndex;
-            int quantity;
-        } DuplicateItem;
-        std::stack<DuplicateItem*> mDuplicates; /** <-- Stores duplicates */
-        int mPrice;
-        int mUsedQuantity;
-        bool mShowQuantity;
-        bool mVisible;
-        bool mDisabled;
-};
-
-#endif  // SHOPITEM_H
-- 
cgit v1.2.3-70-g09d2