mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
feat(Core/Chat): new argument parsing and unify chat hyperlink parsing (#6243)
This commit is contained in:
@@ -35,28 +35,22 @@ class WorldSession;
|
||||
class Player;
|
||||
|
||||
/// Storage class for commands issued for delayed execution
|
||||
struct CliCommandHolder
|
||||
struct AC_GAME_API CliCommandHolder
|
||||
{
|
||||
typedef void Print(void*, const char*);
|
||||
typedef void CommandFinished(void*, bool success);
|
||||
using Print = void(*)(void*, std::string_view);
|
||||
using CommandFinished = void(*)(void*, bool success);
|
||||
|
||||
void* m_callbackArg;
|
||||
char* m_command;
|
||||
Print* m_print;
|
||||
Print m_print;
|
||||
CommandFinished m_commandFinished;
|
||||
|
||||
CommandFinished* m_commandFinished;
|
||||
CliCommandHolder(void* callbackArg, char const* command, Print zprint, CommandFinished commandFinished);
|
||||
~CliCommandHolder();
|
||||
|
||||
CliCommandHolder(void* callbackArg, const char* command, Print* zprint, CommandFinished* commandFinished)
|
||||
: m_callbackArg(callbackArg), m_print(zprint), m_commandFinished(commandFinished)
|
||||
{
|
||||
// TODO: fix Codacy warning
|
||||
// "Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126)."
|
||||
size_t len = strlen(command) + 1;
|
||||
m_command = new char[len];
|
||||
memcpy(m_command, command, len);
|
||||
}
|
||||
|
||||
~CliCommandHolder() { delete[] m_command; }
|
||||
private:
|
||||
CliCommandHolder(CliCommandHolder const& right) = delete;
|
||||
CliCommandHolder& operator=(CliCommandHolder const& right) = delete;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32, WorldSession*> SessionMap;
|
||||
|
||||
@@ -1944,6 +1944,9 @@ void World::SetInitialWorldSettings()
|
||||
LOG_INFO("server.loading", " ");
|
||||
sObjectMgr->InitializeSpellInfoPrecomputedData();
|
||||
|
||||
LOG_INFO("server.loading", "Initialize commands...");
|
||||
Acore::ChatCommands::LoadCommandMap();
|
||||
|
||||
///- Initialize game time and timers
|
||||
LOG_INFO("server.loading", "Initialize game time and timers");
|
||||
LOG_INFO("server.loading", " ");
|
||||
@@ -2760,7 +2763,7 @@ void World::UpdateSessions(uint32 diff)
|
||||
// This handles the issued and queued CLI commands
|
||||
void World::ProcessCliCommands()
|
||||
{
|
||||
CliCommandHolder::Print* zprint = nullptr;
|
||||
CliCommandHolder::Print zprint = nullptr;
|
||||
void* callbackArg = nullptr;
|
||||
CliCommandHolder* command = nullptr;
|
||||
while (cliCmdQueue.next(command))
|
||||
@@ -3505,3 +3508,13 @@ void World::FinalizePlayerWorldSession(WorldSession* session)
|
||||
session->SendClientCacheVersion(cacheVersion);
|
||||
session->SendTutorialsData();
|
||||
}
|
||||
|
||||
CliCommandHolder::CliCommandHolder(void* callbackArg, char const* command, Print zprint, CommandFinished commandFinished)
|
||||
: m_callbackArg(callbackArg), m_command(strdup(command)), m_print(zprint), m_commandFinished(commandFinished)
|
||||
{
|
||||
}
|
||||
|
||||
CliCommandHolder::~CliCommandHolder()
|
||||
{
|
||||
free(m_command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user