diff options
author | Treeston <treeston.mmoc@gmail.com> | 2018-09-07 20:31:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 20:31:04 +0200 |
commit | 66a87c4642d25f27ca24254cfeb0a0c4b21036b1 (patch) | |
tree | ccf34eaee0ac1a51e5f971af8ecd67d14c9fc735 /src/server/game/Chat/Chat.cpp | |
parent | 5843724debc3642434c055e5cf6f29a1eaf65358 (diff) |
Scripts/Commands: New argument parsing methodology (PR #22363)
- Detect the arguments accepted by the command handler
- Tokenize out those arguments automatically and feed them to the handler
- Unmatched rest of the string can be accepted by trailing char const* or CommandArgs*
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r-- | src/server/game/Chat/Chat.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index fbf91d9d70d..2bce0e52b8a 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -35,11 +35,6 @@ #include "World.h" #include <boost/algorithm/string/replace.hpp> -ChatCommand::ChatCommand(char const* name, uint32 permission, bool allowConsole, pHandler handler, std::string help, std::vector<ChatCommand> childCommands /*= std::vector<ChatCommand>()*/) - : Name(ASSERT_NOTNULL(name)), Permission(permission), AllowConsole(allowConsole), Handler(handler), Help(std::move(help)), ChildCommands(std::move(childCommands)) -{ -} - // Lazy loading of the command table cache from commands and the // ScriptMgr should be thread safe since the player commands, // cli commands and ScriptMgr updates are all dispatched one after @@ -306,12 +301,12 @@ bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, c } // must be available and have handler - if (!table[i].Handler || !isAvailable(table[i])) + if (!table[i].HasHandler() || !isAvailable(table[i])) continue; SetSentErrorMessage(false); // table[i].Name == "" is special case: send original command to handler - if ((table[i].Handler)(this, table[i].Name[0] != '\0' ? text : oldtext)) + if (table[i](this, table[i].Name[0] != '\0' ? text : oldtext)) { if (!m_session) // ignore console return true; |