diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2020-09-20 02:50:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-20 02:50:38 +0200 |
| commit | 1eca51b417678b9a48b28552925d5694105f82bb (patch) | |
| tree | 9ae5150e9efbd4f2ad2364922cab46093ee25419 /src/server/game/Scripting | |
| parent | a724903b8b307516780474dd23977d2a9b502eb5 (diff) | |
[3.3.5] ChatCommands, the other half: chat command resolution refactor (PR #25463)
Diffstat (limited to 'src/server/game/Scripting')
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 22 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 7 |
2 files changed, 12 insertions, 17 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 1eda7e32103..674c9c42ac0 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -16,7 +16,7 @@ */ #include "ScriptMgr.h" -#include "Chat.h" +#include "ChatCommand.h" #include "Config.h" #include "Creature.h" #include "CreatureAIImpl.h" @@ -872,17 +872,17 @@ class ScriptRegistrySwapHooks<CommandScript, Base> public: void BeforeReleaseContext(std::string const& /*context*/) final override { - ChatHandler::invalidateCommandTable(); + Trinity::ChatCommands::InvalidateCommandMap(); } void BeforeSwapContext(bool /*initialize*/) override { - ChatHandler::invalidateCommandTable(); + Trinity::ChatCommands::InvalidateCommandMap(); } void BeforeUnload() final override { - ChatHandler::invalidateCommandTable(); + Trinity::ChatCommands::InvalidateCommandMap(); } }; @@ -1618,22 +1618,16 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(uint32 scriptId) return tmpscript->GetOutdoorPvP(); } -std::vector<ChatCommand> ScriptMgr::GetChatCommands() +Trinity::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands() { - std::vector<ChatCommand> table; + Trinity::ChatCommands::ChatCommandTable table; FOR_SCRIPTS_RET(CommandScript, itr, end, table) { - std::vector<ChatCommand> cmds = itr->second->GetCommands(); - table.insert(table.end(), cmds.begin(), cmds.end()); + Trinity::ChatCommands::ChatCommandTable cmds = itr->second->GetCommands(); + std::move(cmds.begin(), cmds.end(), std::back_inserter(table)); } - // Sort commands in alphabetical order - std::sort(table.begin(), table.end(), [](ChatCommand const& a, ChatCommand const& b) - { - return strcmp(a.Name, b.Name) < 0; - }); - return table; } diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 0f5caa70a30..3069fcc80cf 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -32,7 +32,6 @@ class Battlefield; class Battleground; class BattlegroundMap; class Channel; -class ChatCommand; class Creature; class CreatureAI; class DynamicObject; @@ -74,6 +73,8 @@ struct ItemTemplate; struct MapEntry; struct Position; +namespace Trinity::ChatCommands { struct ChatCommandBuilder; } + enum BattlegroundTypeId : uint32; enum ContentLevels : uint8; enum Difficulty : uint8; @@ -512,7 +513,7 @@ class TC_GAME_API CommandScript : public ScriptObject public: // Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler. - virtual std::vector<ChatCommand> GetCommands() const = 0; + virtual std::vector<Trinity::ChatCommands::ChatCommandBuilder> GetCommands() const = 0; }; class TC_GAME_API WeatherScript : public ScriptObject, public UpdatableScript<Weather> @@ -968,7 +969,7 @@ class TC_GAME_API ScriptMgr public: /* CommandScript */ - std::vector<ChatCommand> GetChatCommands(); + std::vector<Trinity::ChatCommands::ChatCommandBuilder> GetChatCommands(); public: /* WeatherScript */ |
