From 5d7a02cee16478f23488495b3d031013eacea108 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Sun, 15 Feb 2015 12:25:28 +0300
Subject: allow unpublish buying store shop.

---
 src/gui/windows/shopwindow.cpp         | 25 ++++++++++++++++++-------
 src/net/eathena/buyingstorehandler.cpp |  1 +
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index bed828f0a..da8a4e41b 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -286,13 +286,21 @@ void ShopWindow::action(const ActionEvent &event)
     {
         if (isBuySelected)
         {
-            std::vector<ShopItem*> &items = mBuyShopItems->items();
-            if (!items.empty())
+            if (mEnableBuyingStore)
             {
-                buyingStoreHandler->create(mSellShopName,
-                    PlayerInfo::getAttribute(Attributes::MONEY),
-                    true,
-                    items);
+                buyingStoreHandler->close();
+                BuyingStoreModeListener::distributeEvent(false);
+            }
+            else
+            {
+                std::vector<ShopItem*> &items = mBuyShopItems->items();
+                if (!items.empty())
+                {
+                    buyingStoreHandler->create(mSellShopName,
+                        PlayerInfo::getAttribute(Attributes::MONEY),
+                        true,
+                        items);
+                }
             }
         }
         else
@@ -414,7 +422,10 @@ void ShopWindow::updateButtonsAndLabels()
             && mBuyShopItems->getNumberOfElements() > 0;
         if (mPublishButton)
         {
-            mPublishButton->setCaption(_("Publish"));
+            if (mEnableBuyingStore)
+                mPublishButton->setCaption(_("Unpublish"));
+            else
+                mPublishButton->setCaption(_("Publish"));
             mPublishButton->adjustSize();
             if (mBuyShopSize > 0)
                 mPublishButton->setEnabled(true);
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
index e0cd402a7..18e933c56 100644
--- a/src/net/eathena/buyingstorehandler.cpp
+++ b/src/net/eathena/buyingstorehandler.cpp
@@ -261,6 +261,7 @@ void BuyingStoreHandler::create(const std::string &name,
 void BuyingStoreHandler::close() const
 {
     createOutPacket(CMSG_BUYINGSTORE_CLOSE);
+    PlayerInfo::enableVending(false);
 }
 
 void BuyingStoreHandler::open(const Being *const being) const
-- 
cgit v1.2.3-70-g09d2