summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-28 22:10:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-28 22:10:30 +0300
commit15b9391da7ba4c307311d7dae6abc81a4b2bf25c (patch)
tree22abbcd556824073008de3493a42839848cef969 /src
parentcd0883a1704c1b514b8b7317358949d43e230644 (diff)
downloadmv-15b9391da7ba4c307311d7dae6abc81a4b2bf25c.tar.gz
mv-15b9391da7ba4c307311d7dae6abc81a4b2bf25c.tar.bz2
mv-15b9391da7ba4c307311d7dae6abc81a4b2bf25c.tar.xz
mv-15b9391da7ba4c307311d7dae6abc81a4b2bf25c.zip
Add chat command /npcmove. Also add it to npc context menu.
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp19
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/dyetool/actions/commands.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/popups/popupmenu.cpp9
-rw-r--r--src/input/inputactionmap.h6
-rw-r--r--src/net/adminhandler.h4
-rw-r--r--src/net/eathena/adminhandler.cpp12
-rw-r--r--src/net/eathena/adminhandler.h4
-rw-r--r--src/net/tmwa/adminhandler.cpp6
-rw-r--r--src/net/tmwa/adminhandler.h16
11 files changed, 73 insertions, 6 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 69acd89cf..ec377be79 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -68,6 +68,7 @@
#include "utils/chatutils.h"
#include "utils/gettext.h"
#include "utils/gmfunctions.h"
+#include "utils/parameters.h"
#include "utils/process.h"
#include "debug.h"
@@ -1472,4 +1473,22 @@ impHandler(commandUnjail)
return true;
}
+impHandler(commandNpcMove)
+{
+ const std::string args = event.args;
+ if (args.empty())
+ return false;
+ StringVect pars;
+ if (!splitParameters(pars, args, " ,", '\"'))
+ return false;
+
+ if (pars.size() != 3)
+ return false;
+
+ adminHandler->npcMove(pars[0],
+ atoi(pars[1].c_str()),
+ atoi(pars[2].c_str()));
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 883b13d7b..f05921487 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -131,6 +131,7 @@ namespace Actions
decHandler(commandKill);
decHandler(commandJail);
decHandler(commandUnjail);
+ decHandler(commandNpcMove);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index cfd21fdd0..4d8906489 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -131,5 +131,6 @@ impHandlerVoid(commandNuke)
impHandlerVoid(commandKill)
impHandlerVoid(commandJail)
impHandlerVoid(commandUnjail)
+impHandlerVoid(commandNpcMove)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 641408b66..c59ae7ca1 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -660,6 +660,7 @@ enumStart(InputAction)
COMMAND_KILL,
COMMAND_JAIL,
COMMAND_UNJAIL,
+ COMMAND_NPC_MOVE,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 7ad1a63f3..5099cb5d7 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1514,6 +1514,7 @@ void PopupMenu::handleLink(const std::string &link,
{
std::string cmd = link.substr(1);
replaceAll(cmd, "'NAME'", mNick);
+ replaceAll(cmd, "'ENAME'", escapeString(mNick));
replaceAll(cmd, "'X'", toString(mX));
replaceAll(cmd, "'Y'", toString(mY));
replaceAll(cmd, "'BEINGID'", toString(toInt(mBeingId, int)));
@@ -1523,6 +1524,9 @@ void PopupMenu::handleLink(const std::string &link,
replaceAll(cmd, "'BEINGTYPEID'", toString(CAST_S32(mType)));
replaceAll(cmd, "'BEINGSUBTYPEID'", toString(CAST_S32(mSubType)));
replaceAll(cmd, "'PLAYER'", localPlayer->getName());
+ replaceAll(cmd, "'EPLAYER'", escapeString(localPlayer->getName()));
+ replaceAll(cmd, "'PLAYERX'", toString(localPlayer->getTileX()));
+ replaceAll(cmd, "'PLAYERY'", toString(localPlayer->getTileY()));
if (mItemIndex >= 0)
replaceAll(cmd, "'INVINDEX'", toString(mItemIndex));
else
@@ -1549,6 +1553,7 @@ void PopupMenu::handleLink(const std::string &link,
}
}
replaceAll(cmd, "'CARDS'", cards);
+ replaceAll(cmd, "'ECARDS'", escapeString(cards));
const size_t pos = cmd.find(' ');
const std::string type(cmd, 0, pos);
std::string args(cmd, pos == std::string::npos ? cmd.size() : pos + 1);
@@ -2882,6 +2887,10 @@ void PopupMenu::showNpcGMCommands()
const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
if (!legacy)
{
+ mBrowserBox->addRow("/npcmove 'NAME' 'PLAYERX' 'PLAYERY'",
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: warp npc to player location
+ _("Recall"));
mBrowserBox->addRow("##3---");
// TRANSLATORS: popup menu item
// TRANSLATORS: warp to npc
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 80bbe090a..40b2c0c4c 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5449,6 +5449,12 @@ static const InputActionData inputActionData
"unjail",
UseArgs_true,
Protected_true},
+ {"keyCommandNpcMove",
+ defaultAction(&Actions::commandNpcMove),
+ InputCondition::INGAME,
+ "npcmove|movenpc|warpnpc|npcwarp",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index 000938240..8674a341d 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -162,6 +162,10 @@ class AdminHandler notfinal
virtual void jail(const std::string &name) const = 0;
virtual void unjail(const std::string &name) const = 0;
+
+ virtual void npcMove(const std::string &name,
+ const int x,
+ const int y) const = 0;
};
} // namespace Net
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 1ee373043..cc1465ee0 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -28,6 +28,7 @@
#include "net/eathena/protocolout.h"
#include "utils/gmfunctions.h"
+#include "utils/stringutils.h"
#include "debug.h"
@@ -325,4 +326,15 @@ void AdminHandler::unjail(const std::string &name) const
Gm::runCommand("unjail", name);
}
+void AdminHandler::npcMove(const std::string &name,
+ const int x,
+ const int y) const
+{
+ Gm::runCommand("npcmove",
+ strprintf("%d %d %s",
+ x,
+ y,
+ name.c_str()));
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h
index 995669f76..60103ea24 100644
--- a/src/net/eathena/adminhandler.h
+++ b/src/net/eathena/adminhandler.h
@@ -138,6 +138,10 @@ class AdminHandler final : public Ea::AdminHandler
void unjail(const std::string &name) const override final;
+ void npcMove(const std::string &name,
+ const int x,
+ const int y) const override final;
+
protected:
static std::string mStatsName;
};
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index 7de0cb247..2dd1464c5 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -257,4 +257,10 @@ void AdminHandler::unjail(const std::string &name A_UNUSED) const
{
}
+void AdminHandler::npcMove(const std::string &name A_UNUSED,
+ const int x A_UNUSED,
+ const int y A_UNUSED) const
+{
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index c45437113..3bed8949c 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/adminhandler.h
@@ -137,19 +137,23 @@ class AdminHandler final : public Ea::AdminHandler
void alive(const std::string &name) const override final;
- void disguise(const std::string &name) const override final;
+ void disguise(const std::string &name) const override final A_CONST;
- void immortal(const std::string &name) const override final;
+ void immortal(const std::string &name) const override final A_CONST;
void hide(const std::string &name) const override final;
- void nuke(const std::string &name) const override final;
+ void nuke(const std::string &name) const override final A_CONST;
- void kill(const std::string &name) const override final;
+ void kill(const std::string &name) const override final A_CONST;
- void jail(const std::string &name) const override final;
+ void jail(const std::string &name) const override final A_CONST;
- void unjail(const std::string &name) const override final;
+ void unjail(const std::string &name) const override final A_CONST;
+
+ void npcMove(const std::string &name,
+ const int x,
+ const int y) const override final A_CONST;
};
} // namespace TmwAthena