From a7f88de7bbea019bf443da0aa31b03d2273739df Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Feb 2016 23:24:54 +0300 Subject: Add chat command /hidenpc. Also add it to npc context menu. --- src/actions/commands.cpp | 9 +++++++++ src/actions/commands.h | 1 + src/dyetool/actions/commands.cpp | 1 + src/enums/input/inputaction.h | 1 + src/gui/popups/popupmenu.cpp | 11 +++++++---- 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, 40 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index ec377be79..52855d06e 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1491,4 +1491,13 @@ impHandler(commandNpcMove) return true; } +impHandler(commandNpcHide) +{ + const std::string args = event.args; + if (args.empty()) + return false; + adminHandler->hideNpc(args); + return true; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index f05921487..735338270 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -132,6 +132,7 @@ namespace Actions decHandler(commandJail); decHandler(commandUnjail); decHandler(commandNpcMove); + decHandler(commandNpcHide); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 4d8906489..d458e21ab 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -132,5 +132,6 @@ impHandlerVoid(commandKill) impHandlerVoid(commandJail) impHandlerVoid(commandUnjail) impHandlerVoid(commandNpcMove) +impHandlerVoid(commandNpcHide) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index c59ae7ca1..6e8f41368 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -661,6 +661,7 @@ enumStart(InputAction) COMMAND_JAIL, COMMAND_UNJAIL, COMMAND_NPC_MOVE, + COMMAND_NPC_HIDE, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index f3b87cbf9..76e684766 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -2907,17 +2907,20 @@ void PopupMenu::showNpcGMCommands() const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA; if (!legacy) { + // TRANSLATORS: popup menu item + // TRANSLATORS: hide npc + mBrowserBox->addRow("/hidenpc 'EXTNAME'", _("Hide")); + mBrowserBox->addRow("##3---"); mBrowserBox->addRow("/npcmove 'EEXTNAME' 'PLAYERX' 'PLAYERY'", // TRANSLATORS: popup menu item // TRANSLATORS: warp npc to player location _("Recall")); - mBrowserBox->addRow("##3---"); - // TRANSLATORS: popup menu item - // TRANSLATORS: warp to npc - mBrowserBox->addRow("/gotonpc 'EXTNAME'", _("Goto")); // TRANSLATORS: popup menu item // TRANSLATORS: disguise to npc mBrowserBox->addRow("/disguise 'BEINGSUBTYPEID'", _("Disguise")); + // TRANSLATORS: popup menu item + // TRANSLATORS: warp to npc + mBrowserBox->addRow("/gotonpc 'EXTNAME'", _("Goto")); } } } diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 40b2c0c4c..d93ccf960 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5455,6 +5455,12 @@ static const InputActionData inputActionData "npcmove|movenpc|warpnpc|npcwarp", UseArgs_true, Protected_true}, + {"keyCommandNpcHide", + defaultAction(&Actions::commandNpcHide), + InputCondition::INGAME, + "npchide|hidenpc", + UseArgs_true, + Protected_true}, }; #undef defaultAction diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h index 8674a341d..8f74a4693 100644 --- a/src/net/adminhandler.h +++ b/src/net/adminhandler.h @@ -166,6 +166,8 @@ class AdminHandler notfinal virtual void npcMove(const std::string &name, const int x, const int y) const = 0; + + virtual void hideNpc(const std::string &name) const = 0; }; } // namespace Net diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp index cc1465ee0..d80cf3171 100644 --- a/src/net/eathena/adminhandler.cpp +++ b/src/net/eathena/adminhandler.cpp @@ -337,4 +337,9 @@ void AdminHandler::npcMove(const std::string &name, name.c_str())); } +void AdminHandler::hideNpc(const std::string &name) const +{ + Gm::runCommand("hidenpc", name); +} + } // namespace EAthena diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h index 60103ea24..36b40e12e 100644 --- a/src/net/eathena/adminhandler.h +++ b/src/net/eathena/adminhandler.h @@ -142,6 +142,8 @@ class AdminHandler final : public Ea::AdminHandler const int x, const int y) const override final; + void hideNpc(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 2dd1464c5..af89a91f8 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -263,4 +263,8 @@ void AdminHandler::npcMove(const std::string &name A_UNUSED, { } +void AdminHandler::hideNpc(const std::string &name A_UNUSED) const +{ +} + } // namespace TmwAthena diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 3bed8949c..5a0233ab5 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -154,6 +154,8 @@ class AdminHandler final : public Ea::AdminHandler void npcMove(const std::string &name, const int x, const int y) const override final A_CONST; + + void hideNpc(const std::string &name) const override final A_CONST; }; } // namespace TmwAthena -- cgit v1.2.3-60-g2f50