Core/Commands: Refactor chat command internals to slightly reduce template bloat

* Replace std::enable_if with concept constraints
* Move code not dependent on template arguments out of template function bodies
* Reduce number of ChatCommandResult copies made during parsing
* Changed ChatCommandTable subcommands argument from std::vector<> const& to std::span<> and convert command definitions to arrays
* Allow ChatHandler arguments to be const
This commit is contained in:
Shauren
2026-03-27 20:02:12 +01:00
parent b81a6d122b
commit 4b6e6e1fec
55 changed files with 550 additions and 476 deletions
+4 -4
View File
@@ -1787,14 +1787,14 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(uint32 scriptId, Map* map)
return tmpscript->GetOutdoorPvP(map);
}
Trinity::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands()
std::vector<Trinity::ChatCommands::ChatCommandBuilder> ScriptMgr::GetChatCommands()
{
Trinity::ChatCommands::ChatCommandTable table;
std::vector<Trinity::ChatCommands::ChatCommandBuilder> table;
FOR_SCRIPTS(CommandScript, itr, end)
{
Trinity::ChatCommands::ChatCommandTable cmds = itr->second->GetCommands();
std::move(cmds.begin(), cmds.end(), std::back_inserter(table));
std::span<Trinity::ChatCommands::ChatCommandBuilder const> cmds = itr->second->GetCommands();
table.insert(table.end(), cmds.begin(), cmds.end());
}
return table;