From 64a067458ea169b9ff5b9a78ed1a011da86e8bdf Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Thu, 25 Feb 2016 20:25:03 +0300
Subject: Add chat command /killable. Also add it to player context menu.

---
 src/actions/commands.cpp         | 6 ++++++
 src/actions/commands.h           | 1 +
 src/dyetool/actions/commands.cpp | 1 +
 src/enums/input/inputaction.h    | 1 +
 src/gui/popups/popupmenu.cpp     | 3 +++
 src/input/inputactionmap.h       | 6 ++++++
 src/net/adminhandler.h           | 2 ++
 src/net/eathena/adminhandler.cpp | 5 +++++
 src/net/eathena/adminhandler.h   | 2 ++
 src/net/tmwa/adminhandler.cpp    | 4 ++++
 src/net/tmwa/adminhandler.h      | 2 ++
 11 files changed, 33 insertions(+)

diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 6c7cb1d8f..426c89da7 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -1402,4 +1402,10 @@ impHandler(commandKiller)
     return true;
 }
 
+impHandler(commandKillable)
+{
+    adminHandler->killable(event.args);
+    return true;
+}
+
 }  // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 9328f1d2c..19581facc 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -121,6 +121,7 @@ namespace Actions
     decHandler(commandRandomWarp);
     decHandler(commandGotoNpc);
     decHandler(commandKiller);
+    decHandler(commandKillable);
 }  // namespace Actions
 
 #undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index a87b76c5e..b1ff43838 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -121,5 +121,6 @@ impHandlerVoid(commandLoadPosition)
 impHandlerVoid(commandRandomWarp)
 impHandlerVoid(commandGotoNpc)
 impHandlerVoid(commandKiller)
+impHandlerVoid(commandKillable)
 
 }  // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index edfc88f34..c838648a4 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -650,6 +650,7 @@ enumStart(InputAction)
     COMMAND_RANDOM_WARP,
     COMMAND_GOTO_NPC,
     COMMAND_KILLER,
+    COMMAND_KILLABLE,
     TOTAL
 }
 enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index f5bc3d32d..b8923bd7e 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -2749,6 +2749,9 @@ void PopupMenu::showPlayerGMCommands()
         // TRANSLATORS: set player as killer
         mBrowserBox->addRow("/killer 'NAME'", _("Killer"));
         // TRANSLATORS: popup menu item
+        // TRANSLATORS: set player as killable
+        mBrowserBox->addRow("/killable 'NAME'", _("Killable"));
+        // TRANSLATORS: popup menu item
         // TRANSLATORS: set player save position
         mBrowserBox->addRow("/savepos 'NAME'", _("Set save"));
         // TRANSLATORS: popup menu item
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 93f1e73bb..6c0975015 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5389,6 +5389,12 @@ static const InputActionData inputActionData
         "setkiller|killer",
         UseArgs_true,
         Protected_true},
+    {"keyCommandKillable",
+        defaultAction(&Actions::commandKillable),
+        InputCondition::INGAME,
+        "setkillable|killable",
+        UseArgs_true,
+        Protected_true},
 };
 
 #undef defaultAction
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index ae8a55e73..6814f36ea 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -144,6 +144,8 @@ class AdminHandler notfinal
         virtual void gotoNpc(const std::string &name) const = 0;
 
         virtual void killer(const std::string &name) const = 0;
+
+        virtual void killable(const std::string &name) const = 0;
 };
 
 }  // namespace Net
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 25104c076..270c20070 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -275,4 +275,9 @@ void AdminHandler::killer(const std::string &name) const
     Gm::runCharCommand("killer", name);
 }
 
+void AdminHandler::killable(const std::string &name) const
+{
+    Gm::runCharCommand("killable", name);
+}
+
 }  // namespace EAthena
diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h
index 24dbf9b8a..6e6906fcf 100644
--- a/src/net/eathena/adminhandler.h
+++ b/src/net/eathena/adminhandler.h
@@ -118,6 +118,8 @@ class AdminHandler final : public Ea::AdminHandler
 
         void killer(const std::string &name) const override final;
 
+        void killable(const std::string &name) const override final;
+
     protected:
         static std::string mStatsName;
 };
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index 1b2d2919a..5b3645786 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -215,4 +215,8 @@ void AdminHandler::killer(const std::string &name A_UNUSED) const
 {
 }
 
+void AdminHandler::killable(const std::string &name A_UNUSED) const
+{
+}
+
 }  // namespace TmwAthena
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index 22deeeb08..607ea8ed1 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/adminhandler.h
@@ -130,6 +130,8 @@ class AdminHandler final : public Ea::AdminHandler
         void gotoNpc(const std::string &name) const override final A_CONST;
 
         void killer(const std::string &name) const override final A_CONST;
+
+        void killable(const std::string &name) const override final A_CONST;
 };
 
 }  // namespace TmwAthena
-- 
cgit v1.2.3-70-g09d2