summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-25 17:43:16 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-25 17:48:01 +0300
commitc1c666d37d924f4ef9c544b7ce25fc3ef7b6dd15 (patch)
treebf2b183127384c9b0b77719c1176db51f917f6f4 /src/net
parentf2a2fe38f1185cbe6acb978b37190aaae76f1b62 (diff)
downloadmv-c1c666d37d924f4ef9c544b7ce25fc3ef7b6dd15.tar.gz
mv-c1c666d37d924f4ef9c544b7ce25fc3ef7b6dd15.tar.bz2
mv-c1c666d37d924f4ef9c544b7ce25fc3ef7b6dd15.tar.xz
mv-c1c666d37d924f4ef9c544b7ce25fc3ef7b6dd15.zip
Replace direct gm commands to gm command functions.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/adminhandler.cpp24
-rw-r--r--src/net/eathena/adminhandler.cpp70
-rw-r--r--src/net/tmwa/adminhandler.cpp13
-rw-r--r--src/net/tmwa/chathandler.cpp3
4 files changed, 40 insertions, 70 deletions
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
index d209cc47f..a45cb2d4c 100644
--- a/src/net/ea/adminhandler.cpp
+++ b/src/net/ea/adminhandler.cpp
@@ -24,11 +24,9 @@
#include "game.h"
-#include "const/gui/chat.h"
-
-#include "net/chathandler.h"
#include "net/serverfeatures.h"
+#include "utils/gmfunctions.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -38,7 +36,7 @@ namespace Ea
void AdminHandler::kickName(const std::string &name) const
{
- chatHandler->talk("@kick " + name, GENERAL_CHANNEL);
+ Gm::runCommand("kick", name);
}
void AdminHandler::ban(const int playerId A_UNUSED) const
@@ -48,7 +46,7 @@ void AdminHandler::ban(const int playerId A_UNUSED) const
void AdminHandler::banName(const std::string &name) const
{
- chatHandler->talk("@ban " + name, GENERAL_CHANNEL);
+ Gm::runCommand("ban", name);
}
void AdminHandler::unban(const int playerId A_UNUSED) const
@@ -58,33 +56,33 @@ void AdminHandler::unban(const int playerId A_UNUSED) const
void AdminHandler::unbanName(const std::string &name) const
{
- chatHandler->talk("@unban " + name, GENERAL_CHANNEL);
+ Gm::runCommand("unban", name);
}
void AdminHandler::reviveName(const std::string &name) const
{
- chatHandler->talk("@revive " + name, GENERAL_CHANNEL);
+ Gm::runCommand("revive", name);
}
void AdminHandler::ipcheckName(const std::string &name) const
{
- chatHandler->talk("@ipcheck " + name, GENERAL_CHANNEL);
+ Gm::runCommand("ipcheck", name);
}
void AdminHandler::createItems(const int id,
const ItemColor color A_UNUSED,
const int amount) const
{
- chatHandler->talk(strprintf("@item %d %d", id, amount),
- GENERAL_CHANNEL);
+ Gm::runCommand("item",
+ strprintf("%d %d", id, amount));
}
void AdminHandler::slide(const int x, const int y) const
{
if (serverFeatures->haveSlide())
{
- chatHandler->talk(strprintf("@slide %d %d", x, y),
- GENERAL_CHANNEL);
+ Gm::runCommand("slide",
+ strprintf("%d %d", x, y));
}
else
{
@@ -94,7 +92,7 @@ void AdminHandler::slide(const int x, const int y) const
void AdminHandler::spawn(const std::string &name) const
{
- chatHandler->talk("@spawn " + name, GENERAL_CHANNEL);
+ Gm::runCommand("spawn", name);
}
} // namespace Ea
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 4c7b776f9..9794a8b51 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -22,15 +22,13 @@
#include "net/eathena/adminhandler.h"
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "net/chathandler.h"
+#include "being/being.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocolout.h"
+#include "utils/gmfunctions.h"
+
#include "debug.h"
extern Net::AdminHandler *adminHandler;
@@ -164,121 +162,97 @@ void AdminHandler::requestStats(const std::string &name) const
void AdminHandler::monsterInfo(const std::string &name) const
{
- chatHandler->talk("@monsterinfo " + name, GENERAL_CHANNEL);
+ Gm::runCommand("monsterinfo", name);
}
void AdminHandler::itemInfo(const std::string &name) const
{
- chatHandler->talk("@iteminfo " + name, GENERAL_CHANNEL);
+ Gm::runCommand("iteminfo", name);
}
void AdminHandler::whoDrops(const std::string &name) const
{
- chatHandler->talk("@whodrops " + name, GENERAL_CHANNEL);
+ Gm::runCommand("whodrops", name);
}
void AdminHandler::mobSearch(const std::string &name) const
{
- chatHandler->talk("@mobsearch " + name, GENERAL_CHANNEL);
+ Gm::runCommand("mobsearch", name);
}
void AdminHandler::mobSpawnSearch(const std::string &name) const
{
- chatHandler->talk("@whereis " + name, GENERAL_CHANNEL);
+ Gm::runCommand("whereis", name);
}
void AdminHandler::playerGmCommands(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@commands", GENERAL_CHANNEL);
- else
- chatHandler->talk("#commands " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("commands", name);
}
void AdminHandler::playerCharGmCommands(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@charcommands", GENERAL_CHANNEL);
- else
- chatHandler->talk("#charcommands " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("charcommands", name);
}
void AdminHandler::showLevel(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@exp", GENERAL_CHANNEL);
- else
- chatHandler->talk("#exp " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("exp", name);
}
void AdminHandler::showStats(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@stats", GENERAL_CHANNEL);
- else
- chatHandler->talk("#stats " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("stats", name);
}
void AdminHandler::showStorageList(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@storagelist", GENERAL_CHANNEL);
- else
- chatHandler->talk("#storagelist " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("storagelist", name);
}
void AdminHandler::showCartList(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@cartlist", GENERAL_CHANNEL);
- else
- chatHandler->talk("#cartlist " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("cartlist", name);
}
void AdminHandler::showInventoryList(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@itemlist", GENERAL_CHANNEL);
- else
- chatHandler->talk("#itemlist " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("itemlist", name);
}
void AdminHandler::locatePlayer(const std::string &name) const
{
- chatHandler->talk("@where " + name, GENERAL_CHANNEL);
+ Gm::runCommand("where", name);
}
void AdminHandler::showAccountInfo(const std::string &name) const
{
- chatHandler->talk("@accinfo " + name, GENERAL_CHANNEL);
+ Gm::runCommand("accinfo", name);
}
void AdminHandler::spawnSlave(const std::string &name) const
{
- chatHandler->talk("@summon " + name, GENERAL_CHANNEL);
+ Gm::runCommand("summon", name);
}
void AdminHandler::spawnClone(const std::string &name) const
{
- chatHandler->talk("@clone " + name, GENERAL_CHANNEL);
+ Gm::runCommand("clone", name);
}
void AdminHandler::spawnSlaveClone(const std::string &name) const
{
- chatHandler->talk("@slaveclone " + name, GENERAL_CHANNEL);
+ Gm::runCommand("slaveclone", name);
}
void AdminHandler::spawnEvilClone(const std::string &name) const
{
- chatHandler->talk("@evilclone " + name, GENERAL_CHANNEL);
+ Gm::runCommand("evilclone", name);
}
void AdminHandler::savePosition(const std::string &name) const
{
- if (name.empty() || (localPlayer && name == localPlayer->getName()))
- chatHandler->talk("@save", GENERAL_CHANNEL);
- else
- chatHandler->talk("#save " + name, GENERAL_CHANNEL);
+ Gm::runCharCommand("save", name);
}
} // namespace EAthena
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index f9180a7d8..264eca1ad 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -22,13 +22,10 @@
#include "net/tmwa/adminhandler.h"
-#include "const/gui/chat.h"
-
-#include "net/chathandler.h"
-
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocolout.h"
+#include "utils/gmfunctions.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -76,8 +73,8 @@ void AdminHandler::kickAll() const
void AdminHandler::warp(const std::string &map, const int x, const int y) const
{
- chatHandler->talk(strprintf(
- "@warp %s %d %d", map.c_str(), x, y), GENERAL_CHANNEL);
+ Gm::runCommand("warp",
+ strprintf("%s %d %d", map.c_str(), x, y));
}
void AdminHandler::resetStats() const
@@ -90,12 +87,12 @@ void AdminHandler::resetSkills() const
void AdminHandler::gotoName(const std::string &name) const
{
- chatHandler->talk("@goto " + name, GENERAL_CHANNEL);
+ Gm::runCommand("goto", name);
}
void AdminHandler::recallName(const std::string &name) const
{
- chatHandler->talk("@recall " + name, GENERAL_CHANNEL);
+ Gm::runCommand("recall", name);
}
void AdminHandler::mute(const Being *const being A_UNUSED,
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index da25c83cf..514b339c8 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -33,6 +33,7 @@
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocolout.h"
+#include "utils/gmfunctions.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -86,7 +87,7 @@ void ChatHandler::channelMessage(const std::string &restrict channel,
if (channel == TRADE_CHANNEL)
talk("\302\202" + text, GENERAL_CHANNEL);
else if (channel == GM_CHANNEL)
- talk("@wgm " + text, GENERAL_CHANNEL);
+ Gm::runCommand("wgm", text);
}
void ChatHandler::who() const