mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 23:56:25 +00:00
refactor(Core/Chat): Move SendNotification to ChatHander (#19491)
* refactor(Core/Chat): Move SendNotification to ChatHander * Update Battleground.cpp * fix build * Update src/server/game/Chat/Chat.h
This commit is contained in:
@@ -99,6 +99,23 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatHandler::SendNotification(std::string_view str)
|
||||
{
|
||||
if (!m_session)
|
||||
{
|
||||
LOG_ERROR("chat.chat", "ChatHandler::SendNotification sent without a session. Skipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||
for (std::string_view line : lines)
|
||||
{
|
||||
WorldPacket data(SMSG_NOTIFICATION, line.size() + 1);
|
||||
data << line.data();
|
||||
m_session->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatHandler::SendGMText(std::string_view str)
|
||||
{
|
||||
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||
@@ -157,6 +174,12 @@ void ChatHandler::SendWorldTextOptional(std::string_view str, uint32 flag)
|
||||
|
||||
void ChatHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
|
||||
{
|
||||
if (!m_session)
|
||||
{
|
||||
LOG_ERROR("chat.chat", "ChatHandler::SendSysMessage sent without a session. Skipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string msg{ str };
|
||||
|
||||
// Replace every "|" with "||" in msg
|
||||
|
||||
@@ -51,11 +51,23 @@ public:
|
||||
|
||||
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
|
||||
|
||||
void SendNotification(std::string_view str);
|
||||
template<typename... Args>
|
||||
void SendNotification(uint32 strId, Args&&... args)
|
||||
{
|
||||
SendNotification(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
|
||||
}
|
||||
template<typename... Args>
|
||||
void SendNotification(char const* fmt, Args&&... args)
|
||||
{
|
||||
SendNotification(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
void SendGMText(std::string_view str);
|
||||
template<typename... Args>
|
||||
void SendGMText(uint32 strId, Args&&... args)
|
||||
{
|
||||
// WorldText should be sent to all sessions
|
||||
// GMText should be sent to all sessions
|
||||
SessionMap::const_iterator itr;
|
||||
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user