From 0c681b6509d4b517dc2e65a152753224df745605 Mon Sep 17 00:00:00 2001 From: Treeston Date: Fri, 7 Sep 2018 20:31:04 +0200 Subject: 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* (cherry picked from commit 66a87c4642d25f27ca24254cfeb0a0c4b21036b1) --- src/server/game/Chat/Chat.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/server/game/Chat/Chat.cpp') diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 4cc184ae55f..2d180a6b1b9 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -38,11 +38,6 @@ #include "WorldSession.h" #include -ChatCommand::ChatCommand(char const* name, uint32 permission, bool allowConsole, pHandler handler, std::string help, std::vector childCommands /*= std::vector()*/) - : 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 @@ -309,12 +304,12 @@ bool ChatHandler::ExecuteCommandInTable(std::vector 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; -- cgit v1.2.3