summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/perserver/default/chatcommands.txt79
-rw-r--r--src/commandhandler.cpp17
-rw-r--r--src/commandhandler.h2
-rw-r--r--src/commands.h173
-rw-r--r--src/gui/chatwindow.cpp2
5 files changed, 108 insertions, 165 deletions
diff --git a/data/perserver/default/chatcommands.txt b/data/perserver/default/chatcommands.txt
index 6fed60596..adcac967f 100644
--- a/data/perserver/default/chatcommands.txt
+++ b/data/perserver/default/chatcommands.txt
@@ -1,83 +1,4 @@
-/all
-/away
-/closeall
-/clear
-/cleangraphics
-/cleanfonts
-/create
-/close
-/cacheinfo
-/erase
-/execute
-/follow
-/heal
-/ignoreall
-/help
-/announce
-/where
-/who
-/msg
-/mail
-/whisper
-/w
-/query
-/ignore
-/unignore
-/join
-/list
-/party
-/createparty
-/createguild
-/me
-/toggle
-/present
-/quit
-/move
-/target
-/invite
-/leave
-/kick
-/item
-/imitation
-/exp
-/ping
-/outfit
-/emote
-/navigate
-/priceload
-/pricesave
-/trade
-/friend
-/befriend
-/disregard
-/neutral
-/raw
-/disconnect
-/undress
-/attack
-/dirs
-/info
-/wait
-/uptime
-/addattack
-/addpriorityattack
-/removeattack
-/addignoreattack
-/blacklist
-/enemy
-/serverignoreall
-/serverunignoreall
-/dumpg
-/dumpt
-/dumpe
-/dumpogl
-/pseudoaway
<PLAYER>
<MONSTER>
<PEOPLE>
<PARTY>
-/setdrop
-/url
-/open
-/enablehighlight
-/disablehighlight
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index d769f121f..8edea1666 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -43,6 +43,23 @@ CommandHandler::CommandHandler() :
}
}
+void CommandHandler::addChatCommands(std::list<std::string> &arr)
+{
+ const int sz = sizeof(commands) / sizeof(CommandInfo);
+ for (int f = 0; f < sz; f ++)
+ {
+ const CommandInfo &info = commands[f];
+ const std::string name = info.name;
+ if (!name.empty())
+ {
+ std::string cmd = std::string("/").append(name);
+ if (info.useArgs)
+ cmd.append(" ");
+ arr.push_back(cmd);
+ }
+ }
+}
+
void CommandHandler::handleCommands(const std::string &command,
ChatTab *const tab)
{
diff --git a/src/commandhandler.h b/src/commandhandler.h
index a655d8d32..9ddc567e8 100644
--- a/src/commandhandler.h
+++ b/src/commandhandler.h
@@ -55,6 +55,8 @@ class CommandHandler final
~CommandHandler()
{ }
+ static void addChatCommands(std::list<std::string> &arr);
+
/**
* Parse and handle the given command.
*/
diff --git a/src/commands.h b/src/commands.h
index 78263afd2..fca679726 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -44,6 +44,7 @@ struct CommandInfo
const char *name;
CommandFuncPtr func;
int actionId;
+ bool useArgs;
};
namespace Commands
@@ -213,96 +214,96 @@ enum
COMMAND_SETHOME,
COMMAND_MAGICATTACK,
COMMAND_HACK,
- END_COMMANDS,
+ END_COMMANDS
};
static const CommandInfo commands[] =
{
- {"closeall", &Commands::closeAll, -1},
- {"ignoreall", &Commands::ignoreAll, -1},
- {"help", &Commands::help, -1},
- {"announce", &Commands::announce, -1},
- {"where", &Commands::where, -1},
- {"who", &Commands::who, -1},
- {"msg", Commands::msg, -1},
- {"whisper", Commands::msg, -1},
- {"w", &Commands::msg, -1},
- {"query", Commands::query, -1},
- {"q", &Commands::query, -1},
- {"ignore", &Commands::ignore, -1},
- {"unignore", &Commands::unignore, -1},
- {"friend", Commands::beFriend, -1},
- {"befriend", &Commands::beFriend, -1},
- {"disregard", &Commands::disregard, -1},
- {"neutral", &Commands::neutral, -1},
- {"blacklist", &Commands::blackList, -1},
- {"enemy", &Commands::enemy, -1},
- {"erase", &Commands::erase, -1},
- {"clear", &Commands::clear, -1},
- {"cleangraphics", &Commands::cleanGraphics, -1},
- {"cleanfonts", &Commands::cleanFonts, -1},
- {"createparty", &Commands::createParty, -1},
- {"createguild", &Commands::createGuild, -1},
- {"party", &Commands::party, -1},
- {"me", &Commands::me, -1},
- {"toggle", &Commands::toggle, -1},
- {"present", &Commands::present, -1},
- {"quit", &Commands::quit, -1},
- {"all", &Commands::showAll, -1},
- {"move", &Commands::move, -1},
- {"target", &Commands::target, -1},
- {"atkhuman", &Commands::attackHuman, -1},
- {"outfit", &Commands::outfit, -1},
- {"emote", &Commands::emote, -1},
- {"away", &Commands::away, -1},
- {"pseudoaway", &Commands::pseudoAway, -1},
- {"follow", &Commands::follow, -1},
- {"heal", &Commands::heal, -1},
- {"navigate", &Commands::navigate, -1},
- {"imitation", &Commands::imitation, -1},
- {"mail", &Commands::mail, -1},
- {"trade", &Commands::trade, -1},
- {"priceload", &Commands::priceLoad, -1},
- {"pricesave", &Commands::priceSave, -1},
- {"cacheinfo", &Commands::cacheInfo, -1},
- {"disconnect", &Commands::disconnect, -1},
- {"undress", &Commands::undress, -1},
- {"attack", &Commands::attack, -1},
- {"dirs", &Commands::dirs, -1},
- {"info", &Commands::info, -1},
- {"wait", &Commands::wait, -1},
- {"uptime", &Commands::uptime, -1},
- {"addpriorityattack", &Commands::addPriorityAttack, -1},
- {"addattack", &Commands::addAttack, -1},
- {"removeattack", Commands::removeAttack, -1},
- {"removeignoreattack", &Commands::removeAttack, -1},
- {"addignoreattack", &Commands::addIgnoreAttack, -1},
- {"dump", &Commands::dump, -1},
- {"serverignoreall", &Commands::serverIgnoreAll, -1},
- {"serverunignoreall", &Commands::serverUnIgnoreAll, -1},
- {"setdrop", &Commands::setDrop, -1},
- {"error", &Commands::error, -1},
- {"dumpg", &Commands::dumpGraphics, -1},
- {"dumpe", &Commands::dumpEnvironment, -1},
- {"dumpt", &Commands::dumpTests, -1},
- {"dumpogl", &Commands::dumpOGL, -1},
- {"url", &Commands::url, -1},
- {"open", &Commands::open, -1},
- {"execute", &Commands::execute, -1},
- {"testsdlfont", &Commands::testsdlfont, -1},
- {"enablehighlight", &Commands::enableHighlight, -1},
- {"disablehighlight", &Commands::disableHighlight, -1},
- {"", &Commands::dontRemoveName, -1},
- {"", &Commands::removeName, -1},
- {"disableaway", &Commands::disableAway, -1},
- {"enableaway", &Commands::enableAway, -1},
- {"drop", nullptr, Input::KEY_QUICK_DROP},
- {"dropn", nullptr, Input::KEY_QUICK_DROPN},
- {"movetotarget", nullptr, Input::KEY_MOVE_TO_TARGET},
- {"movetohome", nullptr, Input::KEY_MOVE_TO_HOME},
- {"sethome", nullptr, Input::KEY_SET_HOME},
- {"magicattack", nullptr, Input::KEY_MAGIC_ATTACK},
- {"hack", &Commands::hack, -1}
+ {"closeall", &Commands::closeAll, -1, false},
+ {"ignoreall", &Commands::ignoreAll, -1, false},
+ {"help", &Commands::help, -1, false},
+ {"announce", &Commands::announce, -1, true},
+ {"where", &Commands::where, -1, false},
+ {"who", &Commands::who, -1, false},
+ {"msg", Commands::msg, -1, true},
+ {"whisper", Commands::msg, -1, true},
+ {"w", &Commands::msg, -1, true},
+ {"query", Commands::query, -1, true},
+ {"q", &Commands::query, -1, true},
+ {"ignore", &Commands::ignore, -1, true},
+ {"unignore", &Commands::unignore, -1, true},
+ {"friend", Commands::beFriend, -1, true},
+ {"befriend", &Commands::beFriend, -1, true},
+ {"disregard", &Commands::disregard, -1, true},
+ {"neutral", &Commands::neutral, -1, true},
+ {"blacklist", &Commands::blackList, -1, true},
+ {"enemy", &Commands::enemy, -1, true},
+ {"erase", &Commands::erase, -1, true},
+ {"clear", &Commands::clear, -1, true},
+ {"cleangraphics", &Commands::cleanGraphics, -1, false},
+ {"cleanfonts", &Commands::cleanFonts, -1, false},
+ {"createparty", &Commands::createParty, -1, true},
+ {"createguild", &Commands::createGuild, -1, true},
+ {"party", &Commands::party, -1, true},
+ {"me", &Commands::me, -1, true},
+ {"toggle", &Commands::toggle, -1, false},
+ {"present", &Commands::present, -1, false},
+ {"quit", &Commands::quit, -1, false},
+ {"all", &Commands::showAll, -1, false},
+ {"move", &Commands::move, -1, true},
+ {"target", &Commands::target, -1, true},
+ {"atkhuman", &Commands::attackHuman, -1, true},
+ {"outfit", &Commands::outfit, -1, true},
+ {"emote", &Commands::emote, -1, true},
+ {"away", &Commands::away, -1, true},
+ {"pseudoaway", &Commands::pseudoAway, -1, true},
+ {"follow", &Commands::follow, -1, true},
+ {"heal", &Commands::heal, -1, true},
+ {"navigate", &Commands::navigate, -1, true},
+ {"imitation", &Commands::imitation, -1, true},
+ {"mail", &Commands::mail, -1, true},
+ {"trade", &Commands::trade, -1, true},
+ {"priceload", &Commands::priceLoad, -1, false},
+ {"pricesave", &Commands::priceSave, -1, false},
+ {"cacheinfo", &Commands::cacheInfo, -1, false},
+ {"disconnect", &Commands::disconnect, -1, false},
+ {"undress", &Commands::undress, -1, true},
+ {"attack", &Commands::attack, -1, true},
+ {"dirs", &Commands::dirs, -1, false},
+ {"info", &Commands::info, -1, false},
+ {"wait", &Commands::wait, -1, true},
+ {"uptime", &Commands::uptime, -1, false},
+ {"addpriorityattack", &Commands::addPriorityAttack, -1, true},
+ {"addattack", &Commands::addAttack, -1, true},
+ {"removeattack", Commands::removeAttack, -1, true},
+ {"removeignoreattack", &Commands::removeAttack, -1, true},
+ {"addignoreattack", &Commands::addIgnoreAttack, -1, true},
+ {"dump", &Commands::dump, -1, false},
+ {"serverignoreall", &Commands::serverIgnoreAll, -1, false},
+ {"serverunignoreall", &Commands::serverUnIgnoreAll, -1, false},
+ {"setdrop", &Commands::setDrop, -1, true},
+ {"error", &Commands::error, -1, false},
+ {"dumpg", &Commands::dumpGraphics, -1, false},
+ {"dumpe", &Commands::dumpEnvironment, -1, false},
+ {"dumpt", &Commands::dumpTests, -1, false},
+ {"dumpogl", &Commands::dumpOGL, -1, false},
+ {"url", &Commands::url, -1, true},
+ {"open", &Commands::open, -1, true},
+ {"execute", &Commands::execute, -1, true},
+ {"testsdlfont", &Commands::testsdlfont, -1, false},
+ {"enablehighlight", &Commands::enableHighlight, -1, false},
+ {"disablehighlight", &Commands::disableHighlight, -1, false},
+ {"", &Commands::dontRemoveName, -1, false},
+ {"", &Commands::removeName, -1, false},
+ {"disableaway", &Commands::disableAway, -1, false},
+ {"enableaway", &Commands::enableAway, -1, false},
+ {"drop", nullptr, Input::KEY_QUICK_DROP, false},
+ {"dropn", nullptr, Input::KEY_QUICK_DROPN, false},
+ {"movetotarget", nullptr, Input::KEY_MOVE_TO_TARGET, false},
+ {"movetohome", nullptr, Input::KEY_MOVE_TO_HOME, false},
+ {"sethome", nullptr, Input::KEY_SET_HOME, false},
+ {"magicattack", nullptr, Input::KEY_MAGIC_ATTACK, false},
+ {"hack", &Commands::hack, -1, true}
};
#undef decHandler
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 0e043ea71..5d0c76b91 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -24,6 +24,7 @@
#include "actorspritemanager.h"
#include "client.h"
+#include "commandhandler.h"
#include "commands.h"
#include "configuration.h"
#include "game.h"
@@ -322,6 +323,7 @@ void ChatWindow::loadCommandsFile(const std::string &name)
void ChatWindow::fillCommands()
{
loadCommandsFile("chatcommands.txt");
+ CommandHandler::addChatCommands(mCommands);
}
void ChatWindow::loadGMCommands()