aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Chat/Chat.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-09-07 20:31:04 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-25 00:03:23 +0200
commit0c681b6509d4b517dc2e65a152753224df745605 (patch)
tree61c77765713f13d5d7006ef90e6c0a392ee6328a /src/server/game/Chat/Chat.cpp
parent42f366648f6b65753b3719f66b406e110ec9a871 (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* (cherry picked from commit 66a87c4642d25f27ca24254cfeb0a0c4b21036b1)
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
-rw-r--r--src/server/game/Chat/Chat.cpp9
1 files changed, 2 insertions, 7 deletions
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 <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
@@ -309,12 +304,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;