From 30b2f0350767d4d0e78d27b9a1fd33e2095171b9 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 8 Feb 2012 04:54:13 +0300
Subject: Add chat command /setdrop N to set change drop counter.

---
 src/commandhandler.cpp |  9 +++++++++
 src/commandhandler.h   |  2 ++
 src/gui/chatwindow.cpp |  1 +
 src/localplayer.cpp    | 10 ++++++++++
 src/localplayer.h      |  2 ++
 5 files changed, 24 insertions(+)

(limited to 'src')

diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index 4022d8d58..9f832c021 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -201,6 +201,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
         handleServerIgnoreAll(args, tab);
     else if (type == "serverunignoreall")
         handleServerUnIgnoreAll(args, tab);
+    else if (type == "setdrop")
+        handleSetDrop(args, tab);
     else if (type == "dumpg")
         handleDumpGraphics(args, tab);
     else if (type == "dumpt")
@@ -1187,6 +1189,13 @@ void CommandHandler::outStringNormal(ChatTab *tab, const std::string &str,
     }
 }
 
+void CommandHandler::handleSetDrop(const std::string &args,
+                                   ChatTab *tab A_UNUSED)
+{
+    if (player_node)
+        player_node->setQuickDropCounter(atoi(args.c_str()));
+}
+
 #ifdef DEBUG_DUMP_LEAKS
 void showRes(std::string str, ResourceManager::Resources *res);
 
diff --git a/src/commandhandler.h b/src/commandhandler.h
index 16e5e94ce..cd25c234a 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -295,6 +295,8 @@ class CommandHandler
 
         void handleServerUnIgnoreAll(const std::string &args, ChatTab *tab);
 
+        void handleSetDrop(const std::string &args, ChatTab *tab);
+
         void handleDump(const std::string &args, ChatTab *tab);
 
         void handleDumpGraphics(const std::string &args, ChatTab *tab);
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 4fa608f35..69e4d703f 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -311,6 +311,7 @@ void ChatWindow::fillCommands()
     mCommands.push_back("<MONSTER>");
     mCommands.push_back("<PEOPLE>");
     mCommands.push_back("<PARTY>");
+    mCommands.push_back("/setdrop ");
 }
 
 void ChatWindow::loadGMCommands()
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 6dd55dace..01e8c1ae8 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -2067,6 +2067,16 @@ std::string LocalPlayer::getQuickDropCounterString()
     }
 }
 
+void LocalPlayer::setQuickDropCounter(int n)
+{
+    if (n < 1 || n >= (signed)quickDropCounterSize)
+        return;
+    mQuickDropCounter = n;
+    config.setValue("quickDropCounter", mQuickDropCounter);
+    if (miniStatusWindow)
+        miniStatusWindow->updateStatus();
+}
+
 const unsigned pickUpTypeSize = 7;
 
 void LocalPlayer::changePickUpType()
diff --git a/src/localplayer.h b/src/localplayer.h
index bf65096b5..03b3a2538 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -256,6 +256,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
         int getQuickDropCounter() const
         { return mQuickDropCounter; }
 
+        void setQuickDropCounter(int n);
+
         void changeQuickDropCounter();
 
         int getMoveState() const
-- 
cgit v1.2.3-70-g09d2