feat(Core/Chat): new argument parsing and unify chat hyperlink parsing (#6243)

This commit is contained in:
Kargatum
2021-10-23 15:15:42 +07:00
committed by GitHub
parent 1101f9dd2a
commit bc9473482e
90 changed files with 4280 additions and 2508 deletions

View File

@@ -1056,22 +1056,16 @@ OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
return tmpscript->GetOutdoorPvP();
}
std::vector<ChatCommand> ScriptMgr::GetChatCommands()
Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands()
{
std::vector<ChatCommand> table;
Acore::ChatCommands::ChatCommandTable table;
FOR_SCRIPTS_RET(CommandScript, itr, end, table)
FOR_SCRIPTS(CommandScript, itr, end)
{
std::vector<ChatCommand> cmds = itr->second->GetCommands();
table.insert(table.end(), cmds.begin(), cmds.end());
Acore::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(), [](const ChatCommand & a, const ChatCommand & b)
{
return strcmp(a.Name, b.Name) < 0;
});
return table;
}

View File

@@ -41,7 +41,6 @@ class Battleground;
class BattlegroundMap;
class BattlegroundQueue;
class Channel;
class ChatCommand;
class Creature;
class CreatureAI;
class DynamicObject;
@@ -81,6 +80,11 @@ struct OutdoorPvPData;
struct GroupQueueInfo;
struct TargetInfo;
namespace Acore::ChatCommands
{
struct ChatCommandBuilder;
}
#define VISIBLE_RANGE 166.0f //MAX visible range (size of grid)
// Check out our guide on how to create new hooks in our wiki! https://www.azerothcore.org/wiki/hooks-script
@@ -579,7 +583,7 @@ protected:
public:
// Should return a pointer to a valid command table (ChatCommand array) to be used by ChatHandler.
[[nodiscard]] virtual std::vector<ChatCommand> GetCommands() const = 0;
[[nodiscard]] virtual std::vector<Acore::ChatCommands::ChatCommandBuilder> GetCommands() const = 0;
};
class WeatherScript : public ScriptObject, public UpdatableScript<Weather>
@@ -1566,7 +1570,7 @@ public: /* OutdoorPvPScript */
OutdoorPvP* CreateOutdoorPvP(OutdoorPvPData const* data);
public: /* CommandScript */
std::vector<ChatCommand> GetChatCommands();
std::vector<Acore::ChatCommands::ChatCommandBuilder> GetChatCommands();
public: /* WeatherScript */
void OnWeatherChange(Weather* weather, WeatherState state, float grade);